Richard W.M. Jones
2022-Dec-01  10:34 UTC
[Libguestfs] [PATCH guestfs-tools] inspector: Display the new build ID field
libguestfs 1.49.8 adds a new API to read the build ID from guests
(especially for Windows).  If the new API is available and if it
returns a string other than "unknown", then print it in virt-inspector
output.
---
 inspector/inspector.c        | 8 ++++++++
 inspector/virt-inspector.rng | 1 +
 2 files changed, 9 insertions(+)
diff --git a/inspector/inspector.c b/inspector/inspector.c
index 2702e3310c..e4b031149b 100644
--- a/inspector/inspector.c
+++ b/inspector/inspector.c
@@ -447,6 +447,14 @@ output_root (xmlTextWriterPtr xo, char *root)
       single_element ("hostname", str);
     free (str);
 
+#ifdef GUESTFS_HAVE_INSPECT_GET_BUILD_ID
+    str = guestfs_inspect_get_build_id (g, root);
+    if (!str) exit (EXIT_FAILURE);
+    if (STRNEQ (str, "unknown"))
+      single_element ("build_id", str);
+    free (str);
+#endif
+
     str = guestfs_inspect_get_osinfo (g, root);
     if (!str) exit (EXIT_FAILURE);
     if (STRNEQ (str, "unknown"))
diff --git a/inspector/virt-inspector.rng b/inspector/virt-inspector.rng
index 5b460b3645..29c5798e19 100644
--- a/inspector/virt-inspector.rng
+++ b/inspector/virt-inspector.rng
@@ -38,6 +38,7 @@
             <optional><ref
name="ospackageformat"/></optional>
             <optional><ref
name="ospackagemanagement"/></optional>
             <optional><element
name="hostname"><text/></element></optional>
+            <optional><element
name="build_id"><text/></element></optional>
             <optional><element
name="osinfo"><text/></element></optional>
 
             <ref name="mountpoints"/>
-- 
2.37.3
Laszlo Ersek
2022-Dec-02  09:18 UTC
[Libguestfs] [PATCH guestfs-tools] inspector: Display the new build ID field
On 12/01/22 11:34, Richard W.M. Jones wrote:> libguestfs 1.49.8 adds a new API to read the build ID from guests > (especially for Windows). If the new API is available and if it > returns a string other than "unknown", then print it in virt-inspector > output. > --- > inspector/inspector.c | 8 ++++++++ > inspector/virt-inspector.rng | 1 + > 2 files changed, 9 insertions(+) > > diff --git a/inspector/inspector.c b/inspector/inspector.c > index 2702e3310c..e4b031149b 100644 > --- a/inspector/inspector.c > +++ b/inspector/inspector.c > @@ -447,6 +447,14 @@ output_root (xmlTextWriterPtr xo, char *root) > single_element ("hostname", str); > free (str); > > +#ifdef GUESTFS_HAVE_INSPECT_GET_BUILD_ID > + str = guestfs_inspect_get_build_id (g, root); > + if (!str) exit (EXIT_FAILURE); > + if (STRNEQ (str, "unknown")) > + single_element ("build_id", str); > + free (str); > +#endif > + > str = guestfs_inspect_get_osinfo (g, root); > if (!str) exit (EXIT_FAILURE); > if (STRNEQ (str, "unknown")) > diff --git a/inspector/virt-inspector.rng b/inspector/virt-inspector.rng > index 5b460b3645..29c5798e19 100644 > --- a/inspector/virt-inspector.rng > +++ b/inspector/virt-inspector.rng > @@ -38,6 +38,7 @@ > <optional><ref name="ospackageformat"/></optional> > <optional><ref name="ospackagemanagement"/></optional> > <optional><element name="hostname"><text/></element></optional> > + <optional><element name="build_id"><text/></element></optional> > <optional><element name="osinfo"><text/></element></optional> > > <ref name="mountpoints"/> >Reviewed-by: Laszlo Ersek <lersek at redhat.com>