[Libguestfs] [PATCH] osinfo: do not assume every media is an installer

Pino Toscano ptoscano at redhat.com
Thu Jul 28 14:21:10 UTC 2016


The osinfo has an "installer" attribute in <media>, which defaults to
true, and there are few entries which are marked as not.
---
 src/guestfs-internal.h |  1 +
 src/inspect-fs-cd.c    |  3 ++-
 src/osinfo.c           | 11 ++++++++++-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h
index 03f1034..2b49011 100644
--- a/src/guestfs-internal.h
+++ b/src/guestfs-internal.h
@@ -861,6 +861,7 @@ struct osinfo {
   int minor_version;
   char *arch;
   int is_live_disk;
+  bool is_installer;
 
 #if 0
   /* Not yet available in libosinfo database. */
diff --git a/src/inspect-fs-cd.c b/src/inspect-fs-cd.c
index bb28c0f..10e9d54 100644
--- a/src/inspect-fs-cd.c
+++ b/src/inspect-fs-cd.c
@@ -526,7 +526,8 @@ guestfs_int_check_installer_iso (guestfs_h *g, struct inspect_fs *fs,
   /* Otherwise we matched an ISO, so fill in the fs fields. */
   fs->mountable = safe_strdup (g, device);
   fs->is_root = 1;
-  fs->format = OS_FORMAT_INSTALLER;
+  if (osinfo->is_installer)
+    fs->format = OS_FORMAT_INSTALLER;
   fs->type = osinfo->type;
   fs->distro = osinfo->distro;
   fs->product_name =
diff --git a/src/osinfo.c b/src/osinfo.c
index 22f1e92..fc18075 100644
--- a/src/osinfo.c
+++ b/src/osinfo.c
@@ -412,7 +412,7 @@ read_osinfo_db_xml (guestfs_h *g, const char *pathname)
       }
 
 #if 0
-      debug (g, "osinfo: %s: %s%s%s%s=> arch %s live %s product %s type %d distro %d version %d.%d",
+      debug (g, "osinfo: %s: %s%s%s%s=> arch %s live %s installer %s product %s type %d distro %d version %d.%d",
              pathname,
              osinfo->re_system_id ? "<system-id/> " : "",
              osinfo->re_volume_id ? "<volume-id/> " : "",
@@ -420,6 +420,7 @@ read_osinfo_db_xml (guestfs_h *g, const char *pathname)
              osinfo->re_application_id ? "<application-id/> " : "",
              osinfo->arch ? osinfo->arch : "(none)",
              osinfo->is_live_disk ? "true" : "false",
+             osinfo->is_installer ? "true" : "false",
              osinfo->product_name ? osinfo->product_name : "(none)",
              (int) osinfo->type, (int) osinfo->distro,
              osinfo->major_version, osinfo->minor_version);
@@ -495,6 +496,14 @@ read_media_node (guestfs_h *g, xmlXPathContextPtr xpathCtx,
       osinfo->is_live_disk = XMLSTREQ (content, BAD_CAST "true");
   }
 
+  osinfo->is_installer = true; /* If no 'installer' attr, defaults to true. */
+  {
+    CLEANUP_XMLFREE xmlChar *content = NULL;
+    content = xmlGetProp (media_node, BAD_CAST "installer");
+    if (content)
+      osinfo->is_installer = XMLSTREQ (content, BAD_CAST "true");
+  }
+
   return 0;
 }
 
-- 
2.7.4




More information about the Libguestfs mailing list