[Libguestfs] [PATCH v3 1/3] v2v: OVF: improve get_ostype mappings

Pino Toscano ptoscano at redhat.com
Thu Apr 5 12:53:50 UTC 2018


- consider CentOS as RHEL, since oVirt has no CentOS OS mappings, and
  CentOS is derived from RHEL
- use rhel_6_9_plus_ppc64 for RHEL 6 >= 6.9 on ppc64/ppc64le, while
  rhel_6_ppc64 for RHEL 6 < 6.9
- use rhel_7_s390x for RHEL 7 on s390x
- use sles_11, and sles_11_ppc64 for any SLES greater than 11, not only
  11
- use sles_12_s390x for SLES 11+ on s390x
- use ubuntu_16_04_s390x for Ubuntu 16.04+ on s390x
- use other_linux_ppc64 for any unmapped Linux distro on ppc64/ppc64le
- use other_linux_s390x for any unmapped Linux distro on s390x
---
 v2v/create_ovf.ml | 48 +++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 37 insertions(+), 11 deletions(-)

diff --git a/v2v/create_ovf.ml b/v2v/create_ovf.ml
index 87245fdc8..78f6b31a3 100644
--- a/v2v/create_ovf.ml
+++ b/v2v/create_ovf.ml
@@ -53,17 +53,17 @@ let iso_time =
 (* Guess vmtype based on the guest inspection data. *)
 let get_vmtype = function
   (* Special cases for RHEL 3 & RHEL 4. *)
-  | { i_type = "linux"; i_distro = "rhel"; i_major_version = (3|4);
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = (3|4);
       i_product_name = product }
        when String.find product "ES" >= 0 ->
      `Server
 
-  | { i_type = "linux"; i_distro = "rhel"; i_major_version = (3|4);
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = (3|4);
       i_product_name = product }
        when String.find product "AS" >= 0 ->
      `Server
 
-  | { i_type = "linux"; i_distro = "rhel"; i_major_version = (3|4) } ->
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = (3|4) } ->
      `Desktop
 
   (* For Windows (and maybe Linux in future, but it is not set now),
@@ -89,30 +89,46 @@ let get_vmtype = function
  *   https://bugzilla.redhat.com/show_bug.cgi?id=1219857#c9
  *)
 and get_ostype = function
-  | { i_type = "linux"; i_distro = "rhel"; i_major_version = v;
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = v;
       i_arch = "i386" } when v <= 6 ->
     sprintf "RHEL%d" v
 
-  | { i_type = "linux"; i_distro = "rhel"; i_major_version = v;
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = v;
       i_arch = "x86_64" } when v <= 6 ->
     sprintf "RHEL%dx64" v
 
-  | { i_type = "linux"; i_distro = "rhel"; i_major_version = v;
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = v;
       i_arch = "x86_64" } (* when v >= 7 *) ->
     sprintf "rhel_%dx64" v
 
-  | { i_type = "linux"; i_distro = "rhel"; i_major_version = 7;
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 6;
+      i_minor_version = min; i_arch = ("ppc64"|"ppc64le") } when min >= 9 ->
+    "rhel_6_9_plus_ppc64"
+
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 6;
+      i_arch = ("ppc64"|"ppc64le") } ->
+    "rhel_6_ppc64"
+
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 7;
       i_arch = "ppc64" | "ppc64le" } ->
     "rhel_7_ppc64"
 
-  | { i_type = "linux"; i_distro = "sles"; i_major_version = 11;
-      i_arch = "x86_64" } ->
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 7;
+      i_arch = "s390x" } ->
+    "rhel_7_s390x"
+
+  | { i_type = "linux"; i_distro = "sles"; i_major_version = maj;
+      i_arch = "x86_64" } when maj >= 11 ->
     "sles_11"
 
-  | { i_type = "linux"; i_distro = "sles"; i_major_version = 11;
-      i_arch = "ppc64" | "ppc64le" } ->
+  | { i_type = "linux"; i_distro = "sles"; i_major_version = maj;
+      i_arch = ("ppc64"|"ppc64le") } when maj >= 11 ->
     "sles_11_ppc64"
 
+  | { i_type = "linux"; i_distro = "sles"; i_major_version = maj;
+      i_arch = "s390x" } when maj >= 12 ->
+    "sles_12_s390x"
+
    (* Only Debian 7 is available, so use it for any 7+ version. *)
   | { i_type = "linux"; i_distro = "debian"; i_major_version = v }
       when v >= 7 ->
@@ -125,6 +141,10 @@ and get_ostype = function
       i_arch = "ppc64" | "ppc64le" } when v >= 14 ->
     "ubuntu_14_04_ppc64"
 
+  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = maj;
+      i_arch = "s390x" } when maj >= 16 ->
+    "ubuntu_16_04_s390x"
+
   | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = v }
       when v >= 14 ->
     "ubuntu_14_04"
@@ -133,6 +153,12 @@ and get_ostype = function
       i_minor_version = min } when maj >= 12 ->
     sprintf "ubuntu_%d_%02d" maj min
 
+  | { i_type = "linux"; i_arch = ("ppc64"|"ppc64le") } ->
+    "other_linux_ppc64"
+
+  | { i_type = "linux"; i_arch = "s390x" } ->
+    "other_linux_s390x"
+
   | { i_type = "linux" } -> "OtherLinux"
 
   | { i_type = "windows"; i_major_version = 5; i_minor_version = 1 } ->
-- 
2.14.3




More information about the Libguestfs mailing list