Blame SOURCES/0070-v2v-OVF-Better-mapping-for-inspection-data-to-vmtype.patch

e76f14
From 165d9fbc3bb53daff1c1e1336610fba672a9412a Mon Sep 17 00:00:00 2001
e76f14
From: "Richard W.M. Jones" <rjones@redhat.com>
e76f14
Date: Tue, 26 Apr 2016 12:27:14 +0100
e76f14
Subject: [PATCH] v2v: OVF: Better mapping for inspection data to vmtype.
e76f14
e76f14
The old mapping code was directly copied from old virt-v2v, translated
e76f14
from Perl to OCaml.
e76f14
e76f14
The new mapping code does a few things more accurately:
e76f14
e76f14
 - Use the i_product_variant field (Windows InstallationType) if available.
e76f14
e76f14
 - Simplify rules, so there is only one special case needed for RHEL 3/4.
e76f14
e76f14
 - Don't assume Fedora == Desktop.
e76f14
e76f14
 - Don't assume all later Windows variants are server.
e76f14
e76f14
 - Works for Windows > 7.
e76f14
e76f14
(cherry picked from commit 5ec42a62384f87a4de841d202e31d0337c64f5af)
e76f14
---
e76f14
 v2v/OVF.ml | 61 ++++++++++++++++++++-----------------------------------------
e76f14
 1 file changed, 20 insertions(+), 41 deletions(-)
e76f14
e76f14
diff --git a/v2v/OVF.ml b/v2v/OVF.ml
e76f14
index 8dc3fea..f1d8de5 100644
e76f14
--- a/v2v/OVF.ml
e76f14
+++ b/v2v/OVF.ml
e76f14
@@ -46,55 +46,34 @@ let iso_time =
e76f14
  * when the [--vmtype] parameter is NOT passed.
e76f14
  *)
e76f14
 let get_vmtype = function
e76f14
-  | { i_type = "linux"; i_distro = "rhel"; i_major_version = major;
e76f14
+  (* Special cases for RHEL 3 & RHEL 4. *)
e76f14
+  | { i_type = "linux"; i_distro = "rhel"; i_major_version = (3|4);
e76f14
       i_product_name = product }
e76f14
-      when major >= 5 && String.find product "Server" >= 0 ->
e76f14
-    Server
e76f14
+       when String.find product "ES" >= 0 ->
e76f14
+     Server
e76f14
 
e76f14
-  | { i_type = "linux"; i_distro = "rhel"; i_major_version = major }
e76f14
-      when major >= 5 ->
e76f14
-    Desktop
e76f14
-
e76f14
-  | { i_type = "linux"; i_distro = "rhel"; i_major_version = major;
e76f14
-      i_product_name = product }
e76f14
-      when major >= 3 && String.find product "ES" >= 0 ->
e76f14
-    Server
e76f14
-
e76f14
-  | { i_type = "linux"; i_distro = "rhel"; i_major_version = major;
e76f14
+  | { i_type = "linux"; i_distro = "rhel"; i_major_version = (3|4);
e76f14
       i_product_name = product }
e76f14
-      when major >= 3 && String.find product "AS" >= 0 ->
e76f14
-    Server
e76f14
-
e76f14
-  | { i_type = "linux"; i_distro = "rhel"; i_major_version = major }
e76f14
-      when major >= 3 ->
e76f14
-    Desktop
e76f14
-
e76f14
-  | { i_type = "linux"; i_distro = "fedora" } -> Desktop
e76f14
-
e76f14
-  | { i_type = "windows"; i_major_version = 5; i_minor_version = 1 } ->
e76f14
-    Desktop                            (* Windows XP *)
e76f14
-
e76f14
-  | { i_type = "windows"; i_major_version = 5; i_minor_version = 2;
e76f14
-      i_product_name = product } when String.find product "XP" >= 0 ->
e76f14
-    Desktop                            (* Windows XP *)
e76f14
-
e76f14
-  | { i_type = "windows"; i_major_version = 5; i_minor_version = 2 } ->
e76f14
-    Server                             (* Windows 2003 *)
e76f14
+       when String.find product "AS" >= 0 ->
e76f14
+     Server
e76f14
 
e76f14
-  | { i_type = "windows"; i_major_version = 6; i_minor_version = 0;
e76f14
-      i_product_name = product } when String.find product "Server" >= 0 ->
e76f14
-    Server                             (* Windows 2008 *)
e76f14
+  | { i_type = "linux"; i_distro = "rhel"; i_major_version = (3|4) } ->
e76f14
+     Desktop
e76f14
 
e76f14
-  | { i_type = "windows"; i_major_version = 6; i_minor_version = 0 } ->
e76f14
-    Desktop                            (* Vista *)
e76f14
+  (* For Windows (and maybe Linux in future, but it is not set now),
e76f14
+   * use the i_product_variant field.
e76f14
+   *)
e76f14
+  | { i_product_variant = ("Server"|"Server Core"|"Embedded") } -> Server
e76f14
+  | { i_product_variant = "Client" } -> Desktop
e76f14
 
e76f14
-  | { i_type = "windows"; i_major_version = 6; i_minor_version = 1;
e76f14
-      i_product_name = product } when String.find product "Server" >= 0 ->
e76f14
-    Server                             (* Windows 2008R2 *)
e76f14
+  (* If the product name has "Server" or "Desktop" in it, use that. *)
e76f14
+  | { i_product_name = product } when String.find product "Server" >= 0 ->
e76f14
+     Server
e76f14
 
e76f14
-  | { i_type = "windows"; i_major_version = 6; i_minor_version = 1 } ->
e76f14
-    Server                             (* Windows 7 *)
e76f14
+  | { i_product_name = product } when String.find product "Desktop" >= 0 ->
e76f14
+     Desktop
e76f14
 
e76f14
+  (* Otherwise return server, a safe choice. *)
e76f14
   | _ -> Server
e76f14
 
e76f14
 (* Determine the ovf:OperatingSystemSection_Type from libguestfs
e76f14
-- 
7af31e
1.8.3.1
e76f14