Bug 1993842

Summary: RFE: virt-inspector fails to detect the distro on Pardus-19.5 image
Product: Red Hat Enterprise Linux 9 Reporter: YongkuiGuo <yoguo>
Component: libguestfsAssignee: Laszlo Ersek <lersek>
Status: CLOSED ERRATA QA Contact: YongkuiGuo <yoguo>
Severity: low Docs Contact:
Priority: low    
Version: 9.0CC: kkiwi, lersek, rjones, virt-maint
Target Milestone: betaKeywords: FutureFeature, RFE, Triaged
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libguestfs-1.46.0-1.el9 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: Feature Request
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2011711    
Bug Blocks:    

Description YongkuiGuo 2021-08-16 09:13:04 UTC
Description of problem:
virt-inspector fails to detect the distro, production_name, major_version and minor_version on Pardus-19.5 image.


Version-Release number of selected component (if applicable):
guestfs-tools-1.46.1-3.el9.1.x86_64


How reproducible:
100%


Steps:

1. Create Pardus-19.5.qcow2 image with Pardus-19.5-GNOME-amd64.iso
2.
$ virt-inspector -a  Pardus-19.5.qcow2 --no-applications --no-icon
<?xml version="1.0"?>
<operatingsystems>
  <operatingsystem>
    <root>/dev/pardus-vg/root</root>
    <name>linux</name>
    <arch>x86_64</arch>
    <distro>debian</distro>
    <product_name>10.8</product_name>
    <major_version>10</major_version>
    <minor_version>8</minor_version>
    <package_format>deb</package_format>
    <package_management>apt</package_management>
    <hostname>pardus</hostname>
    <osinfo>debian10</osinfo>
    <mountpoints>
      <mountpoint dev="/dev/pardus-vg/root">/</mountpoint>
      <mountpoint dev="/dev/sda1">/boot</mountpoint>
      <mountpoint dev="/dev/pardus-vg/home">/home</mountpoint>
    </mountpoints>
    <filesystems>
      <filesystem dev="/dev/pardus-vg/home">
        <type>ext4</type>
        <uuid>f66da380-0fbf-4b55-b516-cd83f8774d19</uuid>
      </filesystem>
      <filesystem dev="/dev/pardus-vg/root">
        <type>ext4</type>
        <uuid>a83f041c-e85c-4774-b2c1-f0247e029638</uuid>
      </filesystem>
      <filesystem dev="/dev/pardus-vg/swap_1">
        <type>swap</type>
        <uuid>6f127125-6321-4d20-83d7-f234a9d01ece</uuid>
      </filesystem>
      <filesystem dev="/dev/sda1">
        <type>ext2</type>
        <uuid>9a8def40-7ec5-44e1-917f-38551919b92c</uuid>
      </filesystem>
    </filesystems>
  </operatingsystem>
</operatingsystems>


Actual results:
As above

Expected results:
The distro should be 'pardus' not 'debian'.
The product_name may be 'Pardus 19.5'.
The major_version should be '19'.
The minor_version should be '5'.

Additional info:
The same issue on RHEL-8.5.0

Comment 1 Klaus Heinrich Kiwi 2021-08-16 20:44:50 UTC
I'm setting this as a low-priority RFE for now, but the changes should be minor (patches welcome).

Comment 4 Laszlo Ersek 2021-10-01 11:39:02 UTC
Pardus detection was introduced in commit 233530d3541d ("inspect: Add detection of Pardus.", 2010-10-29).

Comment 5 Laszlo Ersek 2021-10-01 11:43:25 UTC
A guest installed from the pardus 19.5 ISO does not have "/etc/pardus-release", only "/etc/os-release", with the following contents:

NAME="Pardus GNU/Linux"
VERSION="19.5 (Ondokuz)"
ID=pardus
ID_LIKE=debian
PRETTY_NAME="Pardus GNU/Linux Ondokuz"
VERSION_ID="19.5"
HOME_URL="https://www.pardus.org.tr/"
SUPPORT_URL="https://forum.pardus.org.tr/"
BUG_REPORT_URL="https://talep.pardus.org.tr/"
VERSION_CODENAME=ondokuz
PARDUS_CODENAME=ondokuz

Comment 6 Laszlo Ersek 2021-10-01 11:49:44 UTC
In libguestfs's "daemon/inspect_fs_unix.ml", the first record in the "linux_root_tests" list is

  (* systemd distros include /etc/os-release which is reasonably
   * standardized.  This entry should be first.
   *)
  "/etc/os-release",     parse_os_release;

and the "parse_os_release" function associates the "ID" key in the "/etc/os-release" file with the "distro_of_os_release_id" function.

The "distro_of_os_release_id" currently lacks a match for "pardus".

What must have happened is that new Pardus releases adopted the generic "/etc/os-release".ID notation, so this BZ should be solvable by:

diff --git a/daemon/inspect_fs_unix.ml b/daemon/inspect_fs_unix.ml
index 557f328333f0..d96e434e57ee 100644
--- a/daemon/inspect_fs_unix.ml
+++ b/daemon/inspect_fs_unix.ml
@@ -152,6 +152,7 @@ and distro_of_os_release_id = function
   | "opensuse" -> Some DISTRO_OPENSUSE
   | s when String.is_prefix s "opensuse-" -> Some DISTRO_OPENSUSE
   | "pld" -> Some DISTRO_PLD_LINUX
+  | "pardus" -> Some DISTRO_PARDUS
   | "rhel" -> Some DISTRO_RHEL
   | "sles" | "sled" -> Some DISTRO_SLES
   | "ubuntu" -> Some DISTRO_UBUNTU

The old way should be preserved for recognizing earlier Pardus releases.

I'll try this out later and if it works, I'll submit an upstream patch.

Comment 7 Laszlo Ersek 2021-10-01 12:03:01 UTC
(In reply to Laszlo Ersek from comment #6)

> diff --git a/daemon/inspect_fs_unix.ml b/daemon/inspect_fs_unix.ml
> index 557f328333f0..d96e434e57ee 100644
> --- a/daemon/inspect_fs_unix.ml
> +++ b/daemon/inspect_fs_unix.ml
> @@ -152,6 +152,7 @@ and distro_of_os_release_id = function
>    | "opensuse" -> Some DISTRO_OPENSUSE
>    | s when String.is_prefix s "opensuse-" -> Some DISTRO_OPENSUSE
>    | "pld" -> Some DISTRO_PLD_LINUX
> +  | "pardus" -> Some DISTRO_PARDUS
>    | "rhel" -> Some DISTRO_RHEL
>    | "sles" | "sled" -> Some DISTRO_SLES
>    | "ubuntu" -> Some DISTRO_UBUNTU

pld<->pardus are in wrong alphabetical order of course; I'll correct that.

Comment 8 Laszlo Ersek 2021-10-01 12:46:43 UTC
With the patch applied on top of e2f8db27d0af:

--- before      2021-10-01 14:42:11.425011461 +0200
+++ after       2021-10-01 14:44:17.503078940 +0200
@@ -4,14 +4,14 @@
     <root>/dev/sda1</root>
     <name>linux</name>
     <arch>x86_64</arch>
-    <distro>debian</distro>
-    <product_name>10.8</product_name>
-    <major_version>10</major_version>
-    <minor_version>8</minor_version>
-    <package_format>deb</package_format>
-    <package_management>apt</package_management>
+    <distro>pardus</distro>
+    <product_name>Pardus GNU/Linux Ondokuz</product_name>
+    <major_version>19</major_version>
+    <minor_version>5</minor_version>
+    <package_format>pisi</package_format>
+    <package_management>pisi</package_management>
     <hostname>pardus</hostname>
-    <osinfo>debian10</osinfo>
+    <osinfo>pardus19.5</osinfo>
     <mountpoints>
       <mountpoint dev="/dev/sda1">/</mountpoint>
     </mountpoints>

Comment 9 Laszlo Ersek 2021-10-01 12:53:58 UTC
No regressions found in the upstream libguestfs and guestfs-tools "make check" suites; posted the patch.

Subject: [PATCH] daemon/inspect_fs_unix: recognize modern Pardus GNU/Linux releases
Message-Id: <20211001125338.8956-1-lersek>
https://listman.redhat.com/archives/libguestfs/2021-October/msg00005.html

Comment 11 Laszlo Ersek 2021-10-01 13:37:32 UTC
(In reply to Laszlo Ersek from comment #9)
> No regressions found in the upstream libguestfs and guestfs-tools "make
> check" suites; posted the patch.
> 
> Subject: [PATCH] daemon/inspect_fs_unix: recognize modern Pardus GNU/Linux releases
> Message-Id: <20211001125338.8956-1-lersek>
> https://listman.redhat.com/archives/libguestfs/2021-October/msg00005.html

Merged up-stream as commit 3f6f2fb8f699.

Comment 13 Richard W.M. Jones 2021-10-08 13:48:51 UTC
I (accidentally) pulled in the fix for this to RHEL 9 GA.

Comment 14 YongkuiGuo 2021-10-09 06:36:39 UTC
Test with package:
libguestfs-1.46.0-1.el9.x86_64


Steps:

1. On rhel9 host

$ virt-inspector -a  Pardus-19.5.qcow2 --no-applications --no-icon
<?xml version="1.0"?>
<operatingsystems>
  <operatingsystem>
    <root>/dev/pardus-vg/root</root>
    <name>linux</name>
    <arch>x86_64</arch>
    <distro>pardus</distro>
    <product_name>Pardus GNU/Linux Ondokuz</product_name>
    <major_version>19</major_version>
    <minor_version>5</minor_version>
    <package_format>pisi</package_format>
    <package_management>pisi</package_management>
    <hostname>pardus</hostname>
    <osinfo>pardus19.5</osinfo>
    <mountpoints>
      <mountpoint dev="/dev/pardus-vg/root">/</mountpoint>
      <mountpoint dev="/dev/sda1">/boot</mountpoint>
      <mountpoint dev="/dev/pardus-vg/home">/home</mountpoint>
    </mountpoints>
    <filesystems>
      <filesystem dev="/dev/pardus-vg/home">
        <type>ext4</type>
        <uuid>f66da380-0fbf-4b55-b516-cd83f8774d19</uuid>
      </filesystem>
      <filesystem dev="/dev/pardus-vg/root">
        <type>ext4</type>
        <uuid>a83f041c-e85c-4774-b2c1-f0247e029638</uuid>
      </filesystem>
      <filesystem dev="/dev/pardus-vg/swap_1">
        <type>swap</type>
        <uuid>6f127125-6321-4d20-83d7-f234a9d01ece</uuid>
      </filesystem>
      <filesystem dev="/dev/sda1">
        <type>ext2</type>
        <uuid>9a8def40-7ec5-44e1-917f-38551919b92c</uuid>
      </filesystem>
    </filesystems>
  </operatingsystem>
</operatingsystems>

The info including distro, production_name, major_version ... and osinfo is correct.

Comment 18 YongkuiGuo 2021-10-21 08:04:54 UTC
The issue is fixed on the latest RHEL9 compose which contains the libguestfs-1.46.0-1.el9 package. So set the status to VERIFIED.

Comment 20 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