Richard W.M. Jones
2017-Oct-11 12:50 UTC
[Libguestfs] [PATCH 0/2] v2v: -i vmx: Allow deviceType field to be completely omitted.
A colleague found some VMX files which omit the deviceType field. This allows -i vmx mode to parse them. Rich.
Richard W.M. Jones
2017-Oct-11 12:50 UTC
[Libguestfs] [PATCH 1/2] v2v: -i vmx: Allow deviceType field to be completely omitted.
Microsoft make some VMX files available here which we could not parse. These files lack the expected ‘scsi0:0.deviceType’ field: https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/ According to http://faq.sanbarrow.com/index.php?action=artikel&cat=7&id=54&artlang=en this is permitted. Also several other deviceType values may be found. Allow such VMX to be parsed. Thanks: Tom Sorensen --- v2v/input_vmx.ml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/v2v/input_vmx.ml b/v2v/input_vmx.ml index 649e86cac..c50217b9e 100644 --- a/v2v/input_vmx.ml +++ b/v2v/input_vmx.ml @@ -34,7 +34,8 @@ let rec find_disks vmx vmx_filename * * In the VMX file: * scsi0.virtualDev = "pvscsi" # or may be "lsilogic" etc. - * scsi0:0.deviceType = "scsi-hardDisk" + * scsi0:0.deviceType = "disk" | "plainDisk" | "rawDisk" | "scsi-hardDisk" + * | omitted * scsi0:0.fileName = "guest.vmdk" *) and find_scsi_disks vmx vmx_filename @@ -45,7 +46,8 @@ and find_scsi_disks vmx vmx_filename try ignore (get_scsi_controller_target ns); true with Scanf.Scan_failure _ | End_of_file | Failure _ -> false in - let scsi_device_types = [ "scsi-harddisk" ] in + let scsi_device_types = [ Some "disk"; Some "plaindisk"; Some "rawdisk"; + Some "scsi-harddisk"; None ] in let scsi_controller = Source_SCSI in find_hdds vmx vmx_filename @@ -66,7 +68,7 @@ and find_ide_disks vmx vmx_filename try ignore (get_ide_controller_target ns); true with Scanf.Scan_failure _ | End_of_file | Failure _ -> false in - let ide_device_types = [ "ata-harddisk" ] in + let ide_device_types = [ Some "ata-harddisk" ] in let ide_controller = Source_IDE in find_hdds vmx vmx_filename @@ -85,11 +87,9 @@ and find_hdds vmx vmx_filename if not (is_controller_target ns) then false else ( (* Check the deviceType is one we are looking for. *) - match Parse_vmx.get_string vmx [ns; "deviceType"] with - | Some str -> - let str = String.lowercase_ascii str in - List.mem str device_types - | None -> false + let dt = Parse_vmx.get_string vmx [ns; "deviceType"] in + let dt = Option.map String.lowercase_ascii dt in + List.mem dt device_types ) | _ -> false ) vmx in -- 2.13.2
Richard W.M. Jones
2017-Oct-11 12:50 UTC
[Libguestfs] [PATCH 2/2] v2v: -i vmx: Add a test case which lacks scsi0:0.deviceType = "scsi-hardDisk"
VMX file from: https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/ Thanks: Tom Sorensen --- v2v/test-v2v-i-vmx-5.expected | 22 ++++++++++++ v2v/test-v2v-i-vmx-5.vmx | 80 +++++++++++++++++++++++++++++++++++++++++++ v2v/test-v2v-i-vmx.sh | 2 +- 3 files changed, 103 insertions(+), 1 deletion(-) diff --git a/v2v/test-v2v-i-vmx-5.expected b/v2v/test-v2v-i-vmx-5.expected new file mode 100644 index 000000000..192bc441e --- /dev/null +++ b/v2v/test-v2v-i-vmx-5.expected @@ -0,0 +1,22 @@ + +Source guest information (--print-source option): + + source name: MSEdge - Win10_preview +hypervisor type: vmware + memory: 2147483648 (bytes) + nr vCPUs: 1 + CPU vendor: + CPU model: + CPU topology: sockets: 1 cores/socket: 1 threads/core: - + CPU features: + firmware: bios + display: + video: + sound: +disks: + /MSEdge - Win10_preview.vmdk (vmdk) [scsi] +removable media: + +NICs: + Bridge "ethernet0" mac: 00:0c:29:bf:e4:5d [e1000e] + diff --git a/v2v/test-v2v-i-vmx-5.vmx b/v2v/test-v2v-i-vmx-5.vmx new file mode 100644 index 000000000..eb54d85be --- /dev/null +++ b/v2v/test-v2v-i-vmx-5.vmx @@ -0,0 +1,80 @@ +.encoding = "UTF-8" +config.version = "8" +virtualHW.version = "11" +memsize = "2048" +MemAllowAutoScaleDown = "FALSE" +displayName = "MSEdge - Win10_preview" +guestOS = "windows9-64" +cpuid.coresPerSocket = "1" +vmci0.present = "TRUE" +ethernet0.present = "TRUE" +ethernet0.addressType = "generated" +ethernet0.connectionType = "bridged" +ethernet0.virtualDev = "e1000e" +ethernet0.startConnected = "TRUE" +scsi0.present = "TRUE" +scsi0.virtualDev = "lsisas1068" +scsi0:0.present = "TRUE" +scsi0:0.fileName = "MSEdge - Win10_preview.vmdk" +bios.bootorder = "hdd,CDROM" +cleanshutdown = "TRUE" +ethernet0.bsdname = "en0" +ethernet0.displayname = "Ethernet" +ethernet0.linkstatepropagation.enable = "FALSE" +gui.fullscreenatpoweron = "FALSE" +gui.viewmodeatpoweron = "windowed" +hgfs.linkrootshare = "TRUE" +hgfs.maprootshare = "TRUE" +isolation.tools.hgfs.disable = "FALSE" +monitor.phys_bits_used = "42" +msg.autoanswer = "true" +numa.autosize.cookie = "10001" +numa.autosize.vcpu.maxpervirtualnode = "1" +nvram = "MSEdge - Win10_preview.nvram" +proxyapps.publishtohost = "FALSE" +remotedisplay.vnc.enabled = "FALSE" +remotedisplay.vnc.port = "5900" +replay.filename = "" +replay.supported = "FALSE" +scsi0:0.redo = "" +softpoweroff = "TRUE" +tools.synctime = "true" +uuid.action = "create" +virtualhw.productcompatibility = "hosted" +vm.genid = "-570734802784577186" +vm.genidx = "-5042519231342505152" +vmotion.checkpointfbsize = "33554432" +pciBridge0.present = "TRUE" +tools.upgrade.policy = "useGlobal" +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" +extendedConfigFile = "MSEdge - Win10_preview.vmxf" +uuid.bios = "56 4d 54 59 5d 0c 51 8d-d3 40 38 4f fe bf e4 5d" +uuid.location = "56 4d 54 59 5d 0c 51 8d-d3 40 38 4f fe bf e4 5d" +migrate.hostlog = ".\MSEdge - Win10_preview-aee69569.hlog" +pciBridge0.pciSlotNumber = "17" +pciBridge4.pciSlotNumber = "21" +pciBridge5.pciSlotNumber = "22" +pciBridge6.pciSlotNumber = "23" +pciBridge7.pciSlotNumber = "24" +scsi0.pciSlotNumber = "160" +ethernet0.pciSlotNumber = "192" +vmci0.pciSlotNumber = "32" +scsi0.sasWWID = "50 05 05 69 5d 0c 51 80" +ethernet0.generatedAddress = "00:0c:29:bf:e4:5d" +ethernet0.generatedAddressOffset = "0" +vmci0.id = "-20978595" +vmotion.checkpointSVGAPrimarySize = "33554432" +toolsInstallManager.updateCounter = "1" +toolsInstallManager.lastInstallError = "21004" diff --git a/v2v/test-v2v-i-vmx.sh b/v2v/test-v2v-i-vmx.sh index 997103d41..3822e7426 100755 --- a/v2v/test-v2v-i-vmx.sh +++ b/v2v/test-v2v-i-vmx.sh @@ -29,7 +29,7 @@ export VIRTIO_WIN="$top_srcdir/test-data/fake-virtio-win" rm -f test-v2v-i-vmx-*.actual -for i in 1 2 3 4; do +for i in 1 2 3 4 5; do $VG virt-v2v --debug-gc \ -i vmx test-v2v-i-vmx-$i.vmx \ --print-source > test-v2v-i-vmx-$i.actual -- 2.13.2
Pino Toscano
2017-Oct-11 15:05 UTC
Re: [Libguestfs] [PATCH 0/2] v2v: -i vmx: Allow deviceType field to be completely omitted.
On Wednesday, 11 October 2017 14:50:00 CEST Richard W.M. Jones wrote:> A colleague found some VMX files which omit the deviceType field. > This allows -i vmx mode to parse them.LGTM. Thanks, -- Pino Toscano