mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0051-inspector-show-the-per-OS-osinfo-guess-RHBZ-1544842.patch

e9bfca
From 6357a82435d328b1da23ab4995f26836427747a4 Mon Sep 17 00:00:00 2001
e9bfca
From: Pino Toscano <ptoscano@redhat.com>
e9bfca
Date: Wed, 21 Feb 2018 17:37:30 +0100
e9bfca
Subject: [PATCH] inspector: show the per-OS osinfo guess (RHBZ#1544842)
e9bfca
e9bfca
Output also the osinfo guess for each OS in the generated XML output;
e9bfca
adapt the RNG schema, and the test data to it.
e9bfca
e9bfca
(cherry picked from commit 2f8ec91fc1f3e81c8fb81d45849bc7462ee13642)
e9bfca
---
e9bfca
 inspector/expected-coreos.img.xml | 1 +
e9bfca
 inspector/expected-debian.img.xml | 1 +
e9bfca
 inspector/expected-fedora.img.xml | 1 +
e9bfca
 inspector/expected-ubuntu.img.xml | 1 +
e9bfca
 inspector/inspector.c             | 7 +++++++
e9bfca
 inspector/virt-inspector.rng      | 1 +
e9bfca
 6 files changed, 12 insertions(+)
e9bfca
e9bfca
diff --git a/inspector/expected-coreos.img.xml b/inspector/expected-coreos.img.xml
e9bfca
index e4a5d1134..0cdfba6e6 100644
e9bfca
--- a/inspector/expected-coreos.img.xml
e9bfca
+++ b/inspector/expected-coreos.img.xml
e9bfca
@@ -8,6 +8,7 @@
e9bfca
     <major_version>899</major_version>
e9bfca
     <minor_version>13</minor_version>
e9bfca
     <hostname>coreos.invalid</hostname>
e9bfca
+    <osinfo>coreos899.13</osinfo>
e9bfca
     <mountpoints>
e9bfca
       <mountpoint dev="/dev/sda5">/</mountpoint>
e9bfca
       <mountpoint dev="/dev/sda3">/usr</mountpoint>
e9bfca
diff --git a/inspector/expected-debian.img.xml b/inspector/expected-debian.img.xml
e9bfca
index 37ecfa049..6583dc262 100644
e9bfca
--- a/inspector/expected-debian.img.xml
e9bfca
+++ b/inspector/expected-debian.img.xml
e9bfca
@@ -11,6 +11,7 @@
e9bfca
     <package_format>deb</package_format>
e9bfca
     <package_management>apt</package_management>
e9bfca
     <hostname>debian.invalid</hostname>
e9bfca
+    <osinfo>debian5</osinfo>
e9bfca
     <mountpoints>
e9bfca
       <mountpoint dev="/dev/debian/root">/</mountpoint>
e9bfca
       <mountpoint dev="/dev/debian/usr">/usr</mountpoint>
e9bfca
diff --git a/inspector/expected-fedora.img.xml b/inspector/expected-fedora.img.xml
e9bfca
index 8d40e8cb7..df6060a73 100644
e9bfca
--- a/inspector/expected-fedora.img.xml
e9bfca
+++ b/inspector/expected-fedora.img.xml
e9bfca
@@ -11,6 +11,7 @@
e9bfca
     <package_format>rpm</package_format>
e9bfca
     <package_management>yum</package_management>
e9bfca
     <hostname>fedora.invalid</hostname>
e9bfca
+    <osinfo>fedora14</osinfo>
e9bfca
     <mountpoints>
e9bfca
       <mountpoint dev="/dev/VG/Root">/</mountpoint>
e9bfca
       <mountpoint dev="/dev/sda1">/boot</mountpoint>
e9bfca
diff --git a/inspector/expected-ubuntu.img.xml b/inspector/expected-ubuntu.img.xml
e9bfca
index c19c14cd5..4ebcd76d6 100644
e9bfca
--- a/inspector/expected-ubuntu.img.xml
e9bfca
+++ b/inspector/expected-ubuntu.img.xml
e9bfca
@@ -11,6 +11,7 @@
e9bfca
     <package_format>deb</package_format>
e9bfca
     <package_management>apt</package_management>
e9bfca
     <hostname>ubuntu.invalid</hostname>
e9bfca
+    <osinfo>ubuntu10.10</osinfo>
e9bfca
     <mountpoints>
e9bfca
       <mountpoint dev="/dev/sda2">/</mountpoint>
e9bfca
       <mountpoint dev="/dev/sda1">/boot</mountpoint>
e9bfca
diff --git a/inspector/inspector.c b/inspector/inspector.c
e9bfca
index d608b1b63..5075a8f04 100644
e9bfca
--- a/inspector/inspector.c
e9bfca
+++ b/inspector/inspector.c
e9bfca
@@ -443,6 +443,13 @@ output_root (xmlTextWriterPtr xo, char *root)
e9bfca
 					 BAD_CAST str));
e9bfca
   free (str);
e9bfca
 
e9bfca
+  str = guestfs_inspect_get_osinfo (g, root);
e9bfca
+  if (!str) exit (EXIT_FAILURE);
e9bfca
+  if (STRNEQ (str, "unknown"))
e9bfca
+    XMLERROR (-1,
e9bfca
+              xmlTextWriterWriteElement (xo, BAD_CAST "osinfo", BAD_CAST str));
e9bfca
+  free (str);
e9bfca
+
e9bfca
   output_mountpoints (xo, root);
e9bfca
 
e9bfca
   output_filesystems (xo, root);
e9bfca
diff --git a/inspector/virt-inspector.rng b/inspector/virt-inspector.rng
e9bfca
index 314785202..1e3a58af8 100644
e9bfca
--- a/inspector/virt-inspector.rng
e9bfca
+++ b/inspector/virt-inspector.rng
e9bfca
@@ -38,6 +38,7 @@
e9bfca
             <optional><ref name="ospackageformat"/></optional>
e9bfca
             <optional><ref name="ospackagemanagement"/></optional>
e9bfca
             <optional><element name="hostname"><text/></element></optional>
e9bfca
+            <optional><element name="osinfo"><text/></element></optional>
e9bfca
 
e9bfca
             <ref name="mountpoints"/>
e9bfca
             <ref name="filesystems"/>
e9bfca
-- 
8ff76f
2.20.1
e9bfca