Pino Toscano
2018-Apr-05 12:53 UTC
[Libguestfs] [PATCH v3 0/3] v2v: improve OVF in OVirt flavour
Hi, v3 of these patches: https://www.redhat.com/archives/libguestfs/2018-April/msg00002.html https://www.redhat.com/archives/libguestfs/2018-April/msg00006.html Thanks, Pino Toscano (3): v2v: OVF: improve get_ostype mappings v2v: OVF: write ovirt:id attribute for the OS in OVirt flavour v2v: OVF: fix ovf:id for VirtualSystem in OVirt flavour v2v/create_ovf.ml | 253 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 239 insertions(+), 14 deletions(-) -- 2.14.3
Pino Toscano
2018-Apr-05 12:53 UTC
[Libguestfs] [PATCH v3 1/3] v2v: OVF: improve get_ostype mappings
- 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
Pino Toscano
2018-Apr-05 12:53 UTC
[Libguestfs] [PATCH v3 2/3] v2v: OVF: write ovirt:id attribute for the OS in OVirt flavour
When writing the OVF in OVirt flavour, add a ovirt:id attribute to the OperatingSystemSection tag: this attribute represents the numeric value of the ostype ID, which is ignored by oVirt when parsing OVFs in API mode. --- v2v/create_ovf.ml | 203 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 201 insertions(+), 2 deletions(-) diff --git a/v2v/create_ovf.ml b/v2v/create_ovf.ml index 78f6b31a3..ce06ce613 100644 --- a/v2v/create_ovf.ml +++ b/v2v/create_ovf.ml @@ -242,6 +242,203 @@ and get_ostype = function typ distro major minor arch product; "Unassigned" +(* Determine the ovirt:id attribute from libguestfs inspection. + * See ovirt-engine sources, file: + * packaging/conf/osinfo-defaults.properties + * and also: + * https://bugzilla.redhat.com/show_bug.cgi?id=1219857#c9 + *) +and get_ovirt_osid = function + | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 3; + i_arch = "i386" } -> + 9 + + | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 3; + i_arch = "x86_64" } -> + 15 + + | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 4; + i_arch = "i386" } -> + 8 + + | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 4; + i_arch = "x86_64" } -> + 14 + + | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 5; + i_arch = "i386" } -> + 7 + + | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 5; + i_arch = "x86_64" } -> + 13 + + | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 6; + i_arch = "i386" } -> + 18 + + | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 6; + i_arch = "x86_64" } -> + 19 + + | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 6; + i_minor_version = min; i_arch = ("ppc64"|"ppc64le") } when min >= 9 -> + 1007 + + | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 6; + i_arch = ("ppc64"|"ppc64le") } -> + 1003 + + | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 7; + i_arch = "x86_64" } -> + 24 + + | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 7; + i_arch = ("ppc64"|"ppc64le") } -> + 1006 + + | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 7; + i_arch = "s390x" } -> + 2003 + + | { i_type = "linux"; i_distro = "sles"; i_major_version = maj; + i_arch = "x86_64" } when maj >= 11 -> + 1193 + + | { i_type = "linux"; i_distro = "sles"; i_major_version = maj; + i_arch = ("ppc64"|"ppc64le") } when maj >= 11 -> + 1004 + + | { i_type = "linux"; i_distro = "sles"; i_major_version = maj; + i_arch = "s390x" } when maj >= 12 -> + 2004 + + (* 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 -> + 1300 + + (* Only Ubuntu 12.04 to 14.04 are available, so use them starting + * from 12.04, and 14.04 for anything after it. + *) + | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = v; + i_arch = ("ppc64"|"ppc64le") } when v >= 14 -> + 1005 + + | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = v; + i_arch = "s390x" } when v >= 16 -> + 2005 + + | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = v } + when v >= 14 -> + 1256 + + | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = 12; + i_minor_version = 4 } -> + 1252 + + | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = 12; + i_minor_version = 10 } -> + 1253 + + | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = 13; + i_minor_version = 4 } -> + 1254 + + | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = 13; + i_minor_version = 10 } -> + 1255 + + | { i_type = "linux"; i_arch = ("ppc64"|"ppc64le") } -> + 1002 + + | { i_type = "linux"; i_arch = "s390x" } -> + 2002 + + | { i_type = "linux" } -> + 5 + + | { i_type = "windows"; i_major_version = 5; i_minor_version = 1 } -> + 1 (* no architecture differentiation of XP on RHV *) + + | { i_type = "windows"; i_major_version = 5; i_minor_version = 2; + i_product_name = product } when String.find product "XP" >= 0 -> + 1 (* no architecture differentiation of XP on RHV *) + + | { i_type = "windows"; i_major_version = 5; i_minor_version = 2; + i_arch = "i386" } -> + 3 + + | { i_type = "windows"; i_major_version = 5; i_minor_version = 2; + i_arch = "x86_64" } -> + 10 + + | { i_type = "windows"; i_major_version = 6; i_minor_version = 0; + i_arch = "i386" } -> + 4 + + | { i_type = "windows"; i_major_version = 6; i_minor_version = 0; + i_arch = "x86_64" } -> + 16 + + | { i_type = "windows"; i_major_version = 6; i_minor_version = 1; + i_arch = "i386" } -> + 11 + + | { i_type = "windows"; i_major_version = 6; i_minor_version = 1; + i_arch = "x86_64"; i_product_variant = "Client" } -> + 12 + + | { i_type = "windows"; i_major_version = 6; i_minor_version = 1; + i_arch = "x86_64" } -> + 17 + + | { i_type = "windows"; i_major_version = 6; i_minor_version = 2; + i_arch = "i386" } -> + 20 + + | { i_type = "windows"; i_major_version = 6; i_minor_version = 2; + i_arch = "x86_64"; i_product_variant = "Client" } -> + 21 + + | { i_type = "windows"; i_major_version = 6; i_minor_version = 2; + i_arch = "x86_64" } -> + 23 + + (* Treat Windows 8.1 client like Windows 8. See: + * https://bugzilla.redhat.com/show_bug.cgi?id=1309580#c4 + *) + | { i_type = "windows"; i_major_version = 6; i_minor_version = 3; + i_arch = "i386"; i_product_variant = "Client" } -> + 20 + + | { i_type = "windows"; i_major_version = 6; i_minor_version = 3; + i_arch = "x86_64"; i_product_variant = "Client" } -> + 21 + + | { i_type = "windows"; i_major_version = 6; i_minor_version = 3; + i_arch = "x86_64" } -> + 23 + + | { i_type = "windows"; i_major_version = 10; i_minor_version = 0; + i_arch = "i386" } -> + 26 + + | { i_type = "windows"; i_major_version = 10; i_minor_version = 0; + i_arch = "x86_64"; i_product_variant = "Client" } -> + 27 + + | { i_type = "windows"; i_major_version = 10; i_minor_version = 0; + i_arch = "x86_64" } -> + 29 + + | { i_type = typ; i_distro = distro; + i_major_version = major; i_minor_version = minor; i_arch = arch; + i_product_name = product } -> + warning (f_"unknown guest operating system: %s %s %d.%d %s (%s)") + typ distro major minor arch product; + 0 + (* Set the <Origin/> element based on the source hypervisor. * https://bugzilla.redhat.com/show_bug.cgi?id=1342398#c6 * https://gerrit.ovirt.org/#/c/59147/ @@ -321,6 +518,7 @@ let rec create_ovf source targets guestcaps inspect "xmlns:vssd", "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"; "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"; "xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1/"; + "xmlns:ovirt", "http://www.ovirt.org/ovf"; "ovf:version", "0.9" ] [ Comment generated_by; @@ -383,8 +581,9 @@ let rec create_ovf source targets guestcaps inspect ] in (match ovf_flavour with | OVirt -> - e "OperatingSystemSection" ["ovf:id", vm_uuid; - "ovf:required", "false"] + let ovirt_osid = get_ovirt_osid inspect in + e "OperatingSystemSection" ["ovf:required", "false"; + "ovirt:id", string_of_int ovirt_osid] osinfo_subnodes | RHVExportStorageDomain -> e "Section" ["ovf:id", vm_uuid; "ovf:required", "false"; -- 2.14.3
Pino Toscano
2018-Apr-05 12:53 UTC
[Libguestfs] [PATCH v3 3/3] v2v: OVF: fix ovf:id for VirtualSystem in OVirt flavour
When writing the OVF in OVirt flavour, write the actual UUID of the VM as ovf:id attribute for <VirtualSystem>, instead of a dummy value. Suggested by Arik Hadas in https://www.redhat.com/archives/libguestfs/2018-April/msg00005.html --- v2v/create_ovf.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v2v/create_ovf.ml b/v2v/create_ovf.ml index ce06ce613..2fc041168 100644 --- a/v2v/create_ovf.ml +++ b/v2v/create_ovf.ml @@ -699,7 +699,7 @@ let rec create_ovf source targets guestcaps inspect (match ovf_flavour with | OVirt -> - e "VirtualSystem" ["ovf:id", "out"] !content_subnodes + e "VirtualSystem" ["ovf:id", vm_uuid] !content_subnodes | RHVExportStorageDomain -> e "Content" ["ovf:id", "out"; "xsi:type", "ovf:VirtualSystem_Type"] !content_subnodes -- 2.14.3
Richard W.M. Jones
2018-Apr-05 13:45 UTC
Re: [Libguestfs] [PATCH v3 3/3] v2v: OVF: fix ovf:id for VirtualSystem in OVirt flavour
Looks good, ACK series. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
Tomáš Golembiovský
2018-Apr-06 15:45 UTC
Re: [Libguestfs] [PATCH v3 2/3] v2v: OVF: write ovirt:id attribute for the OS in OVirt flavour
On Thu, 5 Apr 2018 14:53:51 +0200 Pino Toscano <ptoscano@redhat.com> wrote:> @@ -383,8 +581,9 @@ let rec create_ovf source targets guestcaps inspect > ] in > (match ovf_flavour with > | OVirt -> > - e "OperatingSystemSection" ["ovf:id", vm_uuid; > - "ovf:required", "false"] > + let ovirt_osid = get_ovirt_osid inspect in > + e "OperatingSystemSection" ["ovf:required", "false"; > + "ovirt:id", string_of_int ovirt_osid]Sadly, OVF schema says ovf:id is reqiured. But since the generated OVF is not used by anything besides oVirt I think we can live without it. Tomas> osinfo_subnodes > | RHVExportStorageDomain -> > e "Section" ["ovf:id", vm_uuid; "ovf:required", "false"; > -- > 2.14.3 >-- Tomáš Golembiovský <tgolembi@redhat.com>
Reasonably Related Threads
- [PATCH v2 0/2] v2v: improve OVF in OVirt flavour
- [PATCH] v2v: OVF: write ovirt:id attribute for the OS in OVirt flavour
- Re: [PATCH v2 1/2] v2v: OVF: write ovirt:id attribute for the OS in OVirt flavour
- Re: [PATCH v2 1/2] v2v: OVF: write ovirt:id attribute for the OS in OVirt flavour
- [PATCH] v2v: Rename OVF module to Create_ovf.