Laszlo Ersek
2022-Apr-19 15:24 UTC
[Libguestfs] [v2v PATCH 2/2] input: -i vmx: Add support for SATA hard disks
See also: - virt-v2v commit 75872bf282d7 ("input: -i vmx: Add support for NVMe devices", 2022-04-08), - libvirt commit 2214fe90442c ("vmx: start parsing SATA disks", 2020-10-14). Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1883802 Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- input/parse_domain_from_vmx.ml | 35 ++++++- tests/test-v2v-i-vmx-7.expected | 23 ++++ tests/test-v2v-i-vmx-7.vmx | 110 ++++++++++++++++++++ tests/test-v2v-i-vmx.sh | 3 +- 4 files changed, 166 insertions(+), 5 deletions(-) diff --git a/input/parse_domain_from_vmx.ml b/input/parse_domain_from_vmx.ml index 5f5946f01a27..947ca41485ce 100644 --- a/input/parse_domain_from_vmx.ml +++ b/input/parse_domain_from_vmx.ml @@ -107,6 +107,7 @@ let rec find_disks vmx vmx_source (fun i (source, filename) -> { source with s_disk_id = i }, filename) (find_scsi_disks vmx vmx_source @ find_nvme_disks vmx vmx_source @ + find_sata_disks vmx vmx_source @ find_ide_disks vmx vmx_source) (* Find all SCSI hard disks. @@ -154,6 +155,30 @@ and find_nvme_disks vmx vmx_source get_nvme_controller_target is_nvme_controller_target nvme_device_types nvme_controller +(* Find all SATA hard disks. + * + * In the VMX file: + * sata0.pciSlotNumber = "33" + * sata0:3.fileName = "win2019_1.vmdk" + * + * The "deviceType" field must be absent; that field is only used for various + * CD-ROM types. + *) +and find_sata_disks vmx vmx_source + let get_sata_controller_target ns + sscanf ns "sata%d:%d" (fun c t -> c, t) + in + let is_sata_controller_target ns + try ignore (get_sata_controller_target ns); true + with Scanf.Scan_failure _ | End_of_file | Failure _ -> false + in + let sata_device_types = [ None ] in + let sata_controller = Source_SATA in + + find_hdds vmx vmx_source + get_sata_controller_target is_sata_controller_target + sata_device_types sata_controller + (* Find all IDE hard disks. * * In the VMX file: @@ -178,12 +203,14 @@ and find_ide_disks vmx vmx_source and find_hdds vmx vmx_source get_controller_target is_controller_target device_types controller - (* Find namespaces matching '(ide|scsi|nvme)X:Y' with suitable deviceType. *) + (* Find namespaces matching '(ide|scsi|nvme|sata)X:Y' with suitable + * deviceType. + *) let hdds Parse_vmx.select_namespaces ( function | [ns] -> - (* Check the namespace is '(ide|scsi|nvme)X:Y' *) + (* Check the namespace is '(ide|scsi|nvme|sata)X:Y' *) if not (is_controller_target ns) then false else ( (* Check the deviceType is one we are looking for. *) @@ -220,8 +247,8 @@ and find_hdds vmx vmx_source * ide1:0.deviceType = "cdrom-image" * ide1:0.fileName = "boot.iso" * - * XXX This only supports IDE CD-ROMs, but we could support SCSI - * CD-ROMs and floppies in future. + * XXX This only supports IDE CD-ROMs, but we could support SCSI CD-ROMs, SATA + * CD-ROMs, and floppies in future. *) and find_removables vmx let get_ide_controller_target ns diff --git a/tests/test-v2v-i-vmx-7.expected b/tests/test-v2v-i-vmx-7.expected new file mode 100644 index 000000000000..dd50510e5630 --- /dev/null +++ b/tests/test-v2v-i-vmx-7.expected @@ -0,0 +1,23 @@ + +Source guest information (--print-source option): + + source name: win2019 +hypervisor type: vmware + VM genid: 2f0de9ad-5b7c-f4de-d53f-23b1115d28b9 + memory: 4294967296 (bytes) + nr vCPUs: 2 + CPU vendor: + CPU model: + CPU topology: + CPU features: + firmware: uefi + display: + sound: +disks: + 0 [scsi] + 1 [sata] +removable media: + +NICs: + Network "VM Network" mac: 00:0c:29:46:9b:0b [vmxnet3] + diff --git a/tests/test-v2v-i-vmx-7.vmx b/tests/test-v2v-i-vmx-7.vmx new file mode 100755 index 000000000000..c2577a529894 --- /dev/null +++ b/tests/test-v2v-i-vmx-7.vmx @@ -0,0 +1,110 @@ +.encoding = "UTF-8" +config.version = "8" +virtualHW.version = "17" +vmci0.present = "TRUE" +floppy0.present = "FALSE" +numvcpus = "2" +memSize = "4096" +bios.bootRetry.delay = "10" +firmware = "efi" +powerType.suspend = "soft" +tools.upgrade.policy = "manual" +sched.cpu.units = "mhz" +sched.cpu.affinity = "all" +vm.createDate = "1649413453022013" +scsi0.virtualDev = "lsisas1068" +scsi0.present = "TRUE" +sata0.present = "TRUE" +usb_xhci.present = "TRUE" +scsi0:0.deviceType = "scsi-hardDisk" +scsi0:0.fileName = "win2019.vmdk" +sched.scsi0:0.shares = "normal" +sched.scsi0:0.throughputCap = "off" +scsi0:0.present = "TRUE" +ethernet0.virtualDev = "vmxnet3" +ethernet0.networkName = "VM Network" +ethernet0.addressType = "generated" +ethernet0.wakeOnPcktRcv = "FALSE" +ethernet0.present = "TRUE" +sata0:0.deviceType = "cdrom-image" +sata0:0.fileName = "/vmfs/volumes/624d796f-52b87554-ccba-a4ae111c9b1b/iso/en-us_windows_server_2019_updated_aug_2021_x64_dvd_a6431a28.iso" +sata0:0.present = "TRUE" +displayName = "win2019" +guestOS = "windows2019srv-64" +uefi.secureBoot.enabled = "TRUE" +toolScripts.afterPowerOn = "TRUE" +toolScripts.afterResume = "TRUE" +toolScripts.beforeSuspend = "TRUE" +toolScripts.beforePowerOff = "TRUE" +tools.syncTime = "FALSE" +uuid.bios = "56 4d 6c 27 96 ea 12 07-6f 0b b1 1d 81 46 9b 0b" +uuid.location = "56 4d 6c 27 96 ea 12 07-6f 0b b1 1d 81 46 9b 0b" +vc.uuid = "52 bb 00 73 da d0 a0 c7-ad 14 03 81 13 03 ed fe" +sched.cpu.min = "0" +sched.cpu.shares = "normal" +sched.mem.min = "0" +sched.mem.minSize = "0" +sched.mem.shares = "normal" +ethernet0.generatedAddress = "00:0c:29:46:9b:0b" +vmci0.id = "-2126079221" +cleanShutdown = "TRUE" +sata0:0.startConnected = "TRUE" +extendedConfigFile = "win2019.vmxf" +ethernet0.uptCompatibility = "TRUE" +sata0:3.fileName = "win2019_1.vmdk" +sched.sata0:3.shares = "normal" +sched.sata0:3.throughputCap = "off" +sata0:3.present = "TRUE" +tools.guest.desktop.autolock = "FALSE" +nvram = "win2019.nvram" +pciBridge0.present = "TRUE" +svga.present = "TRUE" +pciBridge4.present = "TRUE" +pciBridge4.virtualDev = "pcieRootPort" +pciBridge4.functions = "8" +pciBridge5.present = "TRUE" +pciBridge5.virtualDev = "pcieRootPort" +pciBridge5.functions = "8" +pciBridge6.present = "TRUE" +pciBridge6.virtualDev = "pcieRootPort" +pciBridge6.functions = "8" +pciBridge7.present = "TRUE" +pciBridge7.virtualDev = "pcieRootPort" +pciBridge7.functions = "8" +hpet0.present = "TRUE" +RemoteDisplay.maxConnections = "-1" +sched.cpu.latencySensitivity = "normal" +svga.autodetect = "TRUE" +disk.EnableUUID = "TRUE" +numa.autosize.cookie = "20012" +numa.autosize.vcpu.maxPerVirtualNode = "2" +sched.swap.derivedName = "/vmfs/volumes/624d796f-52b87554-ccba-a4ae111c9b1b/win2019/win2019-645c6913.vswp" +vm.genidX = "-5104727847056752683" +pciBridge0.pciSlotNumber = "17" +pciBridge4.pciSlotNumber = "21" +pciBridge5.pciSlotNumber = "22" +pciBridge6.pciSlotNumber = "23" +pciBridge7.pciSlotNumber = "24" +scsi0.pciSlotNumber = "160" +ethernet0.pciSlotNumber = "192" +usb_xhci.pciSlotNumber = "224" +vmci0.pciSlotNumber = "32" +sata0.pciSlotNumber = "33" +scsi0.sasWWID = "50 05 05 67 96 ea 12 00" +vmotion.checkpointFBSize = "4194304" +vmotion.checkpointSVGAPrimarySize = "16777216" +vmotion.svga.mobMaxSize = "16777216" +vmotion.svga.graphicsMemoryKB = "16384" +ethernet0.generatedAddressOffset = "0" +monitor.phys_bits_used = "45" +softPowerOff = "TRUE" +toolsInstallManager.lastInstallError = "0" +toolsInstallManager.updateCounter = "3" +svga.guestBackedPrimaryAware = "TRUE" +tools.remindInstall = "FALSE" +vm.genid = "-802103094701856339" +usb_xhci:4.present = "TRUE" +usb_xhci:4.deviceType = "hid" +usb_xhci:4.port = "4" +usb_xhci:4.parent = "-1" +migrate.hostLog = "./win2019-645c6913.hlog" diff --git a/tests/test-v2v-i-vmx.sh b/tests/test-v2v-i-vmx.sh index d74ddfaaf8fb..eff27e3d8e9f 100755 --- a/tests/test-v2v-i-vmx.sh +++ b/tests/test-v2v-i-vmx.sh @@ -43,10 +43,11 @@ fns="BZ1308535_21disks.vmdk Fedora-20.vmdk RHEL-7.1-UEFI.vmdk Windows-7-x64.vmdk for fn in BZ1308535_21disks_{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}.vmdk; do fns="$fns $fn" done +fns="$fns win2019.vmdk win2019_1.vmdk" for fn in $fns; do qemu-img create -f vmdk $fn 512; done -for i in 1 2 3 4 5 6; do +for i in 1 2 3 4 5 6 7; do $VG virt-v2v --debug-gc \ -i vmx test-v2v-i-vmx-$i.vmx \ --print-source > test-v2v-i-vmx-$i.actual -- 2.19.1.3.g30247aa5d201
Richard W.M. Jones
2022-Apr-20 16:36 UTC
[Libguestfs] [v2v PATCH 2/2] input: -i vmx: Add support for SATA hard disks
On Tue, Apr 19, 2022 at 05:24:15PM +0200, Laszlo Ersek wrote:> See also: > > - virt-v2v commit 75872bf282d7 ("input: -i vmx: Add support for NVMe > devices", 2022-04-08), > > - libvirt commit 2214fe90442c ("vmx: start parsing SATA disks", > 2020-10-14). > > Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1883802 > Signed-off-by: Laszlo Ersek <lersek at redhat.com> > --- > input/parse_domain_from_vmx.ml | 35 ++++++- > tests/test-v2v-i-vmx-7.expected | 23 ++++ > tests/test-v2v-i-vmx-7.vmx | 110 ++++++++++++++++++++ > tests/test-v2v-i-vmx.sh | 3 +- > 4 files changed, 166 insertions(+), 5 deletions(-) > > diff --git a/input/parse_domain_from_vmx.ml b/input/parse_domain_from_vmx.ml > index 5f5946f01a27..947ca41485ce 100644 > --- a/input/parse_domain_from_vmx.ml > +++ b/input/parse_domain_from_vmx.ml > @@ -107,6 +107,7 @@ let rec find_disks vmx vmx_source > (fun i (source, filename) -> { source with s_disk_id = i }, filename) > (find_scsi_disks vmx vmx_source @ > find_nvme_disks vmx vmx_source @ > + find_sata_disks vmx vmx_source @ > find_ide_disks vmx vmx_source) > > (* Find all SCSI hard disks. > @@ -154,6 +155,30 @@ and find_nvme_disks vmx vmx_source > get_nvme_controller_target is_nvme_controller_target > nvme_device_types nvme_controller > > +(* Find all SATA hard disks. > + * > + * In the VMX file: > + * sata0.pciSlotNumber = "33" > + * sata0:3.fileName = "win2019_1.vmdk" > + * > + * The "deviceType" field must be absent; that field is only used for various > + * CD-ROM types. > + *) > +and find_sata_disks vmx vmx_source > + let get_sata_controller_target ns > + sscanf ns "sata%d:%d" (fun c t -> c, t) > + in > + let is_sata_controller_target ns > + try ignore (get_sata_controller_target ns); true > + with Scanf.Scan_failure _ | End_of_file | Failure _ -> false > + in > + let sata_device_types = [ None ] in > + let sata_controller = Source_SATA in > + > + find_hdds vmx vmx_source > + get_sata_controller_target is_sata_controller_target > + sata_device_types sata_controller > + > (* Find all IDE hard disks. > * > * In the VMX file: > @@ -178,12 +203,14 @@ and find_ide_disks vmx vmx_source > and find_hdds vmx vmx_source > get_controller_target is_controller_target > device_types controller > - (* Find namespaces matching '(ide|scsi|nvme)X:Y' with suitable deviceType. *) > + (* Find namespaces matching '(ide|scsi|nvme|sata)X:Y' with suitable > + * deviceType. > + *) > let hdds > Parse_vmx.select_namespaces ( > function > | [ns] -> > - (* Check the namespace is '(ide|scsi|nvme)X:Y' *) > + (* Check the namespace is '(ide|scsi|nvme|sata)X:Y' *) > if not (is_controller_target ns) then false > else ( > (* Check the deviceType is one we are looking for. *) > @@ -220,8 +247,8 @@ and find_hdds vmx vmx_source > * ide1:0.deviceType = "cdrom-image" > * ide1:0.fileName = "boot.iso" > * > - * XXX This only supports IDE CD-ROMs, but we could support SCSI > - * CD-ROMs and floppies in future. > + * XXX This only supports IDE CD-ROMs, but we could support SCSI CD-ROMs, SATA > + * CD-ROMs, and floppies in future. > *) > and find_removables vmx > let get_ide_controller_target ns > diff --git a/tests/test-v2v-i-vmx-7.expected b/tests/test-v2v-i-vmx-7.expected > new file mode 100644 > index 000000000000..dd50510e5630 > --- /dev/null > +++ b/tests/test-v2v-i-vmx-7.expected > @@ -0,0 +1,23 @@ > + > +Source guest information (--print-source option): > + > + source name: win2019 > +hypervisor type: vmware > + VM genid: 2f0de9ad-5b7c-f4de-d53f-23b1115d28b9 > + memory: 4294967296 (bytes) > + nr vCPUs: 2 > + CPU vendor: > + CPU model: > + CPU topology: > + CPU features: > + firmware: uefi > + display: > + sound: > +disks: > + 0 [scsi] > + 1 [sata] > +removable media: > + > +NICs: > + Network "VM Network" mac: 00:0c:29:46:9b:0b [vmxnet3] > + > diff --git a/tests/test-v2v-i-vmx-7.vmx b/tests/test-v2v-i-vmx-7.vmx > new file mode 100755 > index 000000000000..c2577a529894 > --- /dev/null > +++ b/tests/test-v2v-i-vmx-7.vmx > @@ -0,0 +1,110 @@ > +.encoding = "UTF-8" > +config.version = "8" > +virtualHW.version = "17" > +vmci0.present = "TRUE" > +floppy0.present = "FALSE" > +numvcpus = "2" > +memSize = "4096" > +bios.bootRetry.delay = "10" > +firmware = "efi" > +powerType.suspend = "soft" > +tools.upgrade.policy = "manual" > +sched.cpu.units = "mhz" > +sched.cpu.affinity = "all" > +vm.createDate = "1649413453022013" > +scsi0.virtualDev = "lsisas1068" > +scsi0.present = "TRUE" > +sata0.present = "TRUE" > +usb_xhci.present = "TRUE" > +scsi0:0.deviceType = "scsi-hardDisk" > +scsi0:0.fileName = "win2019.vmdk" > +sched.scsi0:0.shares = "normal" > +sched.scsi0:0.throughputCap = "off" > +scsi0:0.present = "TRUE" > +ethernet0.virtualDev = "vmxnet3" > +ethernet0.networkName = "VM Network" > +ethernet0.addressType = "generated" > +ethernet0.wakeOnPcktRcv = "FALSE" > +ethernet0.present = "TRUE" > +sata0:0.deviceType = "cdrom-image" > +sata0:0.fileName = "/vmfs/volumes/624d796f-52b87554-ccba-a4ae111c9b1b/iso/en-us_windows_server_2019_updated_aug_2021_x64_dvd_a6431a28.iso" > +sata0:0.present = "TRUE" > +displayName = "win2019" > +guestOS = "windows2019srv-64" > +uefi.secureBoot.enabled = "TRUE" > +toolScripts.afterPowerOn = "TRUE" > +toolScripts.afterResume = "TRUE" > +toolScripts.beforeSuspend = "TRUE" > +toolScripts.beforePowerOff = "TRUE" > +tools.syncTime = "FALSE" > +uuid.bios = "56 4d 6c 27 96 ea 12 07-6f 0b b1 1d 81 46 9b 0b" > +uuid.location = "56 4d 6c 27 96 ea 12 07-6f 0b b1 1d 81 46 9b 0b" > +vc.uuid = "52 bb 00 73 da d0 a0 c7-ad 14 03 81 13 03 ed fe" > +sched.cpu.min = "0" > +sched.cpu.shares = "normal" > +sched.mem.min = "0" > +sched.mem.minSize = "0" > +sched.mem.shares = "normal" > +ethernet0.generatedAddress = "00:0c:29:46:9b:0b" > +vmci0.id = "-2126079221" > +cleanShutdown = "TRUE" > +sata0:0.startConnected = "TRUE" > +extendedConfigFile = "win2019.vmxf" > +ethernet0.uptCompatibility = "TRUE" > +sata0:3.fileName = "win2019_1.vmdk" > +sched.sata0:3.shares = "normal" > +sched.sata0:3.throughputCap = "off" > +sata0:3.present = "TRUE" > +tools.guest.desktop.autolock = "FALSE" > +nvram = "win2019.nvram" > +pciBridge0.present = "TRUE" > +svga.present = "TRUE" > +pciBridge4.present = "TRUE" > +pciBridge4.virtualDev = "pcieRootPort" > +pciBridge4.functions = "8" > +pciBridge5.present = "TRUE" > +pciBridge5.virtualDev = "pcieRootPort" > +pciBridge5.functions = "8" > +pciBridge6.present = "TRUE" > +pciBridge6.virtualDev = "pcieRootPort" > +pciBridge6.functions = "8" > +pciBridge7.present = "TRUE" > +pciBridge7.virtualDev = "pcieRootPort" > +pciBridge7.functions = "8" > +hpet0.present = "TRUE" > +RemoteDisplay.maxConnections = "-1" > +sched.cpu.latencySensitivity = "normal" > +svga.autodetect = "TRUE" > +disk.EnableUUID = "TRUE" > +numa.autosize.cookie = "20012" > +numa.autosize.vcpu.maxPerVirtualNode = "2" > +sched.swap.derivedName = "/vmfs/volumes/624d796f-52b87554-ccba-a4ae111c9b1b/win2019/win2019-645c6913.vswp" > +vm.genidX = "-5104727847056752683" > +pciBridge0.pciSlotNumber = "17" > +pciBridge4.pciSlotNumber = "21" > +pciBridge5.pciSlotNumber = "22" > +pciBridge6.pciSlotNumber = "23" > +pciBridge7.pciSlotNumber = "24" > +scsi0.pciSlotNumber = "160" > +ethernet0.pciSlotNumber = "192" > +usb_xhci.pciSlotNumber = "224" > +vmci0.pciSlotNumber = "32" > +sata0.pciSlotNumber = "33" > +scsi0.sasWWID = "50 05 05 67 96 ea 12 00" > +vmotion.checkpointFBSize = "4194304" > +vmotion.checkpointSVGAPrimarySize = "16777216" > +vmotion.svga.mobMaxSize = "16777216" > +vmotion.svga.graphicsMemoryKB = "16384" > +ethernet0.generatedAddressOffset = "0" > +monitor.phys_bits_used = "45" > +softPowerOff = "TRUE" > +toolsInstallManager.lastInstallError = "0" > +toolsInstallManager.updateCounter = "3" > +svga.guestBackedPrimaryAware = "TRUE" > +tools.remindInstall = "FALSE" > +vm.genid = "-802103094701856339" > +usb_xhci:4.present = "TRUE" > +usb_xhci:4.deviceType = "hid" > +usb_xhci:4.port = "4" > +usb_xhci:4.parent = "-1" > +migrate.hostLog = "./win2019-645c6913.hlog" > diff --git a/tests/test-v2v-i-vmx.sh b/tests/test-v2v-i-vmx.sh > index d74ddfaaf8fb..eff27e3d8e9f 100755 > --- a/tests/test-v2v-i-vmx.sh > +++ b/tests/test-v2v-i-vmx.sh > @@ -43,10 +43,11 @@ fns="BZ1308535_21disks.vmdk Fedora-20.vmdk RHEL-7.1-UEFI.vmdk Windows-7-x64.vmdk > for fn in BZ1308535_21disks_{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}.vmdk; do > fns="$fns $fn" > done > +fns="$fns win2019.vmdk win2019_1.vmdk" > > for fn in $fns; do qemu-img create -f vmdk $fn 512; done > > -for i in 1 2 3 4 5 6; do > +for i in 1 2 3 4 5 6 7; do > $VG virt-v2v --debug-gc \ > -i vmx test-v2v-i-vmx-$i.vmx \ > --print-source > test-v2v-i-vmx-$i.actualReviewed-by: Richard W.M. Jones <rjones at redhat.com> Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org