Bug 1997446

Summary: osinfo is not correct when handling windows server 2022 image
Product: Red Hat Enterprise Linux 9 Reporter: YongkuiGuo <yoguo>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: YongkuiGuo <yoguo>
Severity: low Docs Contact:
Priority: low    
Version: 9.0CC: kkiwi, rjones, virt-maint
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: libguestfs-1.46.0-4.el9.x86_64 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-17 12:28:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description YongkuiGuo 2021-08-25 09:23:33 UTC
Description of problem:
When handling windows server 2022 image with virt-inspector, the osinfo displays win2k16 not win2k22.


Version-Release number of selected component (if applicable):
libguestfs-1.45.6-12.el9.x86_64


How reproducible:
100%


Steps:

1. 
# virt-inspector -a win2022-preview-x86_64.raw
<?xml version="1.0"?>
<operatingsystems>
  <operatingsystem>
    <root>/dev/sda2</root>
    <name>windows</name>
    <arch>x86_64</arch>
    <distro>windows</distro>
    <product_name>Windows Server 2022 Datacenter</product_name>
    <product_variant>Server</product_variant>
    <major_version>10</major_version>
    <minor_version>0</minor_version>
    <windows_systemroot>/Windows</windows_systemroot>
    <windows_current_control_set>ControlSet001</windows_current_control_set>
    <hostname>WIN-12SKMK6PLJ3</hostname>
    <osinfo>win2k16</osinfo>
    <mountpoints>
      <mountpoint dev="/dev/sda2">/</mountpoint>
    </mountpoints>
    <filesystems>
      <filesystem dev="/dev/sda2">
        <type>ntfs</type>
        <uuid>F2B2A84FB2A819DD</uuid>
      </filesystem>
    </filesystems>
    <drive_mappings>
      <drive_mapping name="C">/dev/sda2</drive_mapping>
    </drive_mappings>
    <applications>
      <application>
        <name>Microsoft Edge</name>
        <display_name>Microsoft Edge</display_name>
        <version>92.0.902.55</version>
        <install_path>C:\Program Files (x86)\Microsoft\Edge\Application</install_path>
        <publisher>Microsoft Corporation</publisher>
      </application>
      <application>
        <name>Microsoft Edge Update</name>
        <display_name>Microsoft Edge Update</display_name>
        <version>1.3.145.49</version>
      </application>
    </applications>
  </operatingsystem>
</operatingsystems>


Actual results:
As above

Expected results:
The osinfo displays win2k22.

Additional info:

Comment 1 Richard W.M. Jones 2021-08-25 09:41:30 UTC
Hi Yongkui, do you have the output from
virt-inspector -a win2022-preview-x86_64.raw -vx ?

Comment 3 YongkuiGuo 2021-08-25 09:55:26 UTC
(In reply to Richard W.M. Jones from comment #1)
> Hi Yongkui, do you have the output from
> virt-inspector -a win2022-preview-x86_64.raw -vx ?

Sorry, attached the whole log. Seems this issue is related to the following source code:

$ vi lib/inspect-osinfo.c
case 10:
  switch (minor) {
    case 0:
      if (strstr (product_variant, "Server")) {
          if (strstr (product_name, "2019"))
            return safe_strdup (g, "win2k19");
          else
            return safe_strdup (g, "win2k16");
      } else
        return safe_strdup (g, "win10");
    }
    break;
  }

Comment 4 Richard W.M. Jones 2021-08-25 10:11:01 UTC
There's actually no entry in osinfo-db yet for this OS.  I created
an issue over there:
https://gitlab.com/libosinfo/osinfo-db/-/issues/82

The upstream fix in libguestfs is:
https://github.com/libguestfs/libguestfs/commit/73cd0a0c8df6d55fa445b93d97f4a17da483768d

Comment 5 Richard W.M. Jones 2021-11-23 13:16:15 UTC
The fix for this is included in libguestfs >= 1.45.7, so it
is already fixed in RHEL 9.

Comment 8 YongkuiGuo 2021-11-24 11:26:59 UTC
Verified with package:
libguestfs-1.46.0-5.el9.x86_64

Steps:

1. On rhel9 host
# virt-inspector -a win2022-preview-x86_64.raw
<?xml version="1.0"?>
<operatingsystems>
  <operatingsystem>
    <root>/dev/sda2</root>
    <name>windows</name>
    <arch>x86_64</arch>
    <distro>windows</distro>
    <product_name>Windows Server 2022 Datacenter</product_name>
    <product_variant>Server</product_variant>
    <major_version>10</major_version>
    <minor_version>0</minor_version>
    <windows_systemroot>/Windows</windows_systemroot>
    <windows_current_control_set>ControlSet001</windows_current_control_set>
    <hostname>WIN-12SKMK6PLJ3</hostname>
    <osinfo>win2k22</osinfo>
    <mountpoints>
      <mountpoint dev="/dev/sda2">/</mountpoint>
    </mountpoints>
    <filesystems>
      <filesystem dev="/dev/sda2">
        <type>ntfs</type>
        <uuid>F2B2A84FB2A819DD</uuid>
      </filesystem>
    </filesystems>
    <drive_mappings>
      <drive_mapping name="C">/dev/sda2</drive_mapping>
    </drive_mappings>
    <applications>
      <application>
        <name>Microsoft Edge</name>
        <display_name>Microsoft Edge</display_name>
        <version>92.0.902.55</version>
        <install_path>C:\Program Files (x86)\Microsoft\Edge\Application</install_path>
        <publisher>Microsoft Corporation</publisher>
      </application>
      <application>
        <name>Microsoft Edge Update</name>
        <display_name>Microsoft Edge Update</display_name>
        <version>1.3.145.49</version>
      </application>
    </applications>
  </operatingsystem>
</operatingsystems>

The value of osinfo is correct.

Comment 10 errata-xmlrpc 2022-05-17 12:28:37 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (new packages: libguestfs), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:2317