virt-v2v/0037-rhv-Use-osinfo-to-dist...

60 lines
2.1 KiB
Diff

From f708a4ba1bcd5cb3be8c2f91a347cd3eed81c8b7 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 1 Dec 2022 10:53:12 +0000
Subject: [PATCH] rhv: Use osinfo to distinguish Windows >= 10 variants
Windows versions >= 10 no longer use the NT major.minor numbering
scheme (it is fixed at 10.0). Libguestfs >= 1.49.8 can distinguish
these versions and it sets <osinfo> correctly, so use that instead.
After this change the OVF will contain:
<Info>Windows 10 Pro</Info>
<Description>windows_11</Description>
which is strange, but apparently what Microsoft intended. As far as
RHV is concerned it only needs <Description> to choose the correct
devices etc.
Reported-by: Tingting Zheng
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2149863
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 38b35f3b7e5c6e5aea5dece5f77561b8332d3360)
---
lib/create_ovf.ml | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/lib/create_ovf.ml b/lib/create_ovf.ml
index 18e86d6c..8aff3d8f 100644
--- a/lib/create_ovf.ml
+++ b/lib/create_ovf.ml
@@ -231,13 +231,22 @@ and get_ostype = function
i_arch = "i386" } ->
"windows_10"
+ (* For Windows NT 10.0 always use the <osinfo> field since the
+ * other fields will not accurately reflect the version.
+ *)
| { i_type = "windows"; i_major_version = 10; i_minor_version = 0;
- i_arch = "x86_64"; i_product_variant = "Client" } ->
- "windows_10x64"
-
- | { i_type = "windows"; i_major_version = 10; i_minor_version = 0;
- i_arch = "x86_64" } ->
- "windows_2016x64"
+ i_arch = "x86_64"; i_osinfo = osinfo; i_product_name = product } ->
+ (match osinfo with
+ | "win10" -> "windows_10x64"
+ | "win11" -> "windows_11"
+ | "win2k16" -> "windows_2016x64"
+ | "win2k19" -> "windows_2019x64"
+ | "win2k22" -> "windows_2022"
+ | _ ->
+ warning (f_"unknown Windows 10 variant: %s (%s)")
+ osinfo product;
+ "windows_2022"
+ )
| { i_type = typ; i_distro = distro;
i_major_version = major; i_minor_version = minor; i_arch = arch;