[Libguestfs] [PATCH v2v] rhv: Use osinfo to distinguish Windows >= 10 variants

Richard W.M. Jones rjones at redhat.com
Thu Dec 1 11:14:38 UTC 2022


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 concern it only needs the <Description> to be correct in order
to choose the correct devices etc.

Reported-by: Tingting Zheng
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2149863
---
 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 18e86d6cf1..8aff3d8f0b 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;
-- 
2.37.3



More information about the Libguestfs mailing list