Blame SOURCES/0043-v2v-i-vmx-Allow-deviceType-field-to-be-completely-om.patch

151578
From 46aaa657c76d473fcd6ac41a84101d7805306f58 Mon Sep 17 00:00:00 2001
151578
From: "Richard W.M. Jones" <rjones@redhat.com>
151578
Date: Wed, 11 Oct 2017 13:43:26 +0100
151578
Subject: [PATCH] v2v: -i vmx: Allow deviceType field to be completely omitted.
151578
MIME-Version: 1.0
151578
Content-Type: text/plain; charset=UTF-8
151578
Content-Transfer-Encoding: 8bit
151578
151578
Microsoft make some VMX files available here which we could not parse.
151578
These files lack the expected ‘scsi0:0.deviceType’ field:
151578
https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/
151578
151578
According to
151578
http://faq.sanbarrow.com/index.php?action=artikel&cat=7&id=54&artlang=en
151578
this is permitted.  Also several other deviceType values may be found.
151578
151578
Allow such VMX to be parsed.
151578
151578
Thanks: Tom Sorensen
151578
151578
Cherry picked from commit 418289029da9641b74984eb15eb1563649c38dd1.
151578
For RHEL 7.5: I inlined the Option.map function since that does not
151578
exist in this branch.
151578
---
151578
 v2v/input_vmx.ml | 19 +++++++++++--------
151578
 1 file changed, 11 insertions(+), 8 deletions(-)
151578
151578
diff --git a/v2v/input_vmx.ml b/v2v/input_vmx.ml
151578
index bb09f0bf8..a4f77c2ab 100644
151578
--- a/v2v/input_vmx.ml
151578
+++ b/v2v/input_vmx.ml
151578
@@ -35,7 +35,8 @@ let rec find_disks vmx vmx_filename =
151578
  *
151578
  * In the VMX file:
151578
  *   scsi0.virtualDev = "pvscsi"  # or may be "lsilogic" etc.
151578
- *   scsi0:0.deviceType = "scsi-hardDisk"
151578
+ *   scsi0:0.deviceType = "disk" | "plainDisk" | "rawDisk" | "scsi-hardDisk"
151578
+ *                        | omitted
151578
  *   scsi0:0.fileName = "guest.vmdk"
151578
  *)
151578
 and find_scsi_disks vmx vmx_filename =
151578
@@ -46,7 +47,8 @@ and find_scsi_disks vmx vmx_filename =
151578
     try ignore (get_scsi_controller_target ns); true
151578
     with Scanf.Scan_failure _ | End_of_file | Failure _ -> false
151578
   in
151578
-  let scsi_device_types = [ "scsi-harddisk" ] in
151578
+  let scsi_device_types = [ Some "disk"; Some "plaindisk"; Some "rawdisk";
151578
+                            Some "scsi-harddisk"; None ] in
151578
   let scsi_controller = Source_SCSI in
151578
 
151578
   find_hdds vmx vmx_filename
151578
@@ -67,7 +69,7 @@ and find_ide_disks vmx vmx_filename =
151578
     try ignore (get_ide_controller_target ns); true
151578
     with Scanf.Scan_failure _ | End_of_file | Failure _ -> false
151578
   in
151578
-  let ide_device_types = [ "ata-harddisk" ] in
151578
+  let ide_device_types = [ Some "ata-harddisk" ] in
151578
   let ide_controller = Source_IDE in
151578
 
151578
   find_hdds vmx vmx_filename
151578
@@ -86,11 +88,12 @@ and find_hdds vmx vmx_filename
151578
          if not (is_controller_target ns) then false
151578
          else (
151578
            (* Check the deviceType is one we are looking for. *)
151578
-           match Parse_vmx.get_string vmx [ns; "deviceType"] with
151578
-           | Some str ->
151578
-              let str = String.lowercase_ascii str in
151578
-              List.mem str device_types
151578
-           | None -> false
151578
+           let dt = Parse_vmx.get_string vmx [ns; "deviceType"] in
151578
+           let dt =
151578
+             match dt with
151578
+             | None -> None
151578
+             | Some dt -> Some (String.lowercase_ascii dt) in
151578
+           List.mem dt device_types
151578
          )
151578
       | _ -> false
151578
     ) vmx in
151578
-- 
151578
2.14.3
151578