Parallels / vagrant-parallels

Vagrant Parallels Provider
https://parallels.github.io/vagrant-parallels
MIT License
996 stars 87 forks source link

Parallels vm.provider creating duplicate disks when using --device-add #411

Closed lonedevel closed 2 years ago

lonedevel commented 2 years ago

I'm trying to create multi-node environment for distributed database testing. The database can run on multiple VMs and I'm trying to configure each with a separate separate disk and mount point for the database content.

In my Vagrantfile I'm only calling the provider.customize option once, yet I see 2 new SATA hdd definitions in each VM configuration that have the same size (128GB). I attached debug output log from the vagrant up command.

Here is the Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.box = "bento/ubuntu-18.04"
  config.vm.provider "parallels" do |prl|
    prl.update_guest_tools = true
    prl.memory = "8192"
    prl.customize ["set", :id, "--device-add", "hdd", "--size", "128G"]
  end
  (1..3).each do |i|
    node_num = i.to_s.rjust(2, '0')
    node_name = "mynode-#{node_num}"
    config.vm.define "#{node_name}" do |node|
      node.vm.hostname = "#{node_name}"
      node.vm.provider "parallels" do |prl|
        prl.name = "#{node_name}"
      end
      node.vm.provision "shell", inline: <<-SHELL
        apt-get update -y
        SHELL
      end
   end
end

Here is the VM Configuration.

prlctl list --info mynode-01
INFO
ID: {5745b6ac-58f2-4a25-8b47-7ce9e06584d1}
Name: mynode-01
Description:
Type: VM
State: running
OS: ubuntu
Template: no
Uptime: 00:20:21 (since 2022-01-05 21:35:52)
Home path: /Volumes/Vela/Parallels/mynode-01.pvm/config.pvs
Home: /Volumes/Vela/Parallels/mynode-01.pvm/
GuestTools: state=installed version=17.1.1-51537
Mouse and Keyboard:
  Smart mouse optimized for games: auto
  Sticky mouse: off
  Smooth scrolling: off
  Keyboard optimization mode: auto
USB and Bluetooth:
  Automatic sharing cameras: off
  Automatic sharing bluetooth: off
  Automatic sharing smart cards: off
  Support USB 3.0: on
Startup and Shutdown:
  Autostart: off
  Autostart delay: 0
  Autostop: suspend
  Startup view: headless
  On shutdown: close
  On window close: keep-running
  Pause idle: off
  Undo disks: off
Optimization:
  Faster virtual machine: on
  Hypervisor type: apple
  Adaptive hypervisor: off
  Disabled Windows logo: on
  Auto compress virtual disks: off
  Nested virtualization: off
  PMU virtualization: off
  Longer battery life: on
  Show battery status: on
  Resource quota: unlimited
Travel mode:
  Enter condition: never
  Enter threshold: 30
  Quit condition: never
Security:
  Encrypted: no
  TPM enabled: no
  TPM type: off
  Custom password protection: off
  Configuration is locked: off
  Protected: no
  Archived: no
Smart Guard: (-)
Modality:
  Opacity (percentage): 50
  Stay on top: on
  Show on all spaces : on
  Capture mouse clicks: on
Fullscreen:
  Use all displays: off
  Activate spaces on click: on
  Optimize for games: off
  Gamma control: on
  Scale view mode: auto
Coherence:
  Show Windows systray in Mac menu: on
  Auto-switch to full screen: on
  Disable aero: off
  Hide minimized windows: off
Time Synchronization: (+)
  Smart mode: off
  Interval (in seconds): 60
  Timezone synchronization disabled: on
Expiration: (-)
Boot order: hdd0 cdrom0 net0 hdd1 hdd2
BIOS type: legacy
Allow select boot device: off
External boot device:
SMBIOS settings:
  BIOS Version:
  System serial number:
  Board Manufacturer:
Hardware:
  cpu cpus=2 auto=off VT-x accl=high mode=64 type=x86
  memory size=8192Mb auto=off
  video adapter-type=virtio size=64Mb 3d-acceleration=highest vertical-sync=on high-resolution=off high-resolution-in-guest=on native-scaling-in-guest=off automatic-video-memory=on
  memory_quota auto=yes
  hdd0 (+) sata:0 image='/Volumes/Vela/Parallels/mynode-01.pvm/harddisk1.hdd' type='expanded' 65536Mb online-compact=off
  hdd1 (+) sata:2 image='/Volumes/Vela/Parallels/mynode-01.pvm/harddisk2.hdd' type='expanded' 131072Mb online-compact=off
  hdd2 (+) sata:3 image='/Volumes/Vela/Parallels/mynode-01.pvm/harddisk3.hdd' type='expanded' 131072Mb online-compact=off
  cdrom0 (+) sata:1 image='' state=disconnected
  usb (+)
  net0 (+) type=shared mac=001C42438844 card=virtio
  sound0 (+) output='Default' mixer='Default'
Host Shared Folders: (-)
  vagrant (+) path='/Users/rmichaud/Development/multinode' mode='rw'
Host defined sharing: Off
Shared Profile: (-)
Shared Applications: (+)
  Host-to-guest apps sharing: off
  Guest-to-host apps sharing: off
  Show guest apps folder in Dock: off
  Show guest notifications: on
  Bounce dock icon when app flashes: on
SmartMount: (-)
Miscellaneous Sharing:
  Shared clipboard: on
  Shared cloud: off
Advanced:
  VM hostname synchronization: off
  Public SSH keys synchronization: off
  Show developer tools: off
  Swipe from edges: off
  Share host location: on

Grepping the debug.log for the specific prlctl command yields:

grep "\"--device-add\", \"hdd\"" debug.log
 INFO subprocess: Starting process: ["/usr/local/bin/prlctl", "set", "8155c51a-b7ea-462a-9031-1c7918485e1e", "--device-add", "hdd", "--size", "128G"]
 INFO subprocess: Starting process: ["/usr/local/bin/prlctl", "set", "815f609e-93f8-4bc3-b415-3e5b1a5c0bed", "--device-add", "hdd", "--size", "128G"]
 INFO subprocess: Starting process: ["/usr/local/bin/prlctl", "set", "5745b6ac-58f2-4a25-8b47-7ce9e06584d1", "--device-add", "hdd", "--size", "128G"]
 INFO subprocess: Starting process: ["/usr/local/bin/prlctl", "set", "8155c51a-b7ea-462a-9031-1c7918485e1e", "--device-add", "hdd", "--size", "128G"]
 INFO subprocess: Starting process: ["/usr/local/bin/prlctl", "set", "815f609e-93f8-4bc3-b415-3e5b1a5c0bed", "--device-add", "hdd", "--size", "128G"]
 INFO subprocess: Starting process: ["/usr/local/bin/prlctl", "set", "5745b6ac-58f2-4a25-8b47-7ce9e06584d1", "--device-add", "hdd", "--size", "128G"]

debug.log

legal90 commented 2 years ago

Hi @lonedevel ,

Sorry for a late reply. The disk is added twice because the VM is getting rebooted during the initial vagrant up run (due to prl.update_guest_tools = true) and you have a configuration which makes prl.customize command to run on every boot:

    prl.customize ["set", :id, "--device-add", "hdd", "--size", "128G"]

^ This is a default behavior. In your case you definitely need to run it only once, after the VM is created, so please add "post-import" to that line :

    prl.customize "post-import" ["set", :id, "--device-add", "hdd", "--size", "128G"]

See more details in docs: https://parallels.github.io/vagrant-parallels/docs/configuration.html

lonedevel commented 2 years ago

Thank you @legal90! Much appreciated!