[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [libosinfo v3] Add 'installer-reboots' parameter to OsinfoMedia



From: "Zeeshan Ali (Khattak)" <zeeshanak gnome org>

If media is an installer, this specifies the number of reboots the
installer takes before installation is complete. Default value is '1'.

This is mainly needed for applications like GNOME Boxes and virt-install
to be able to tell when OS installation from a given media is complete so
that they can take whatever post installation steps they may need to.
---
 osinfo/libosinfo.syms  |  1 +
 osinfo/osinfo_loader.c |  9 +++++++
 osinfo/osinfo_media.c  | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++
 osinfo/osinfo_media.h  | 20 +++++++++-------
 4 files changed, 86 insertions(+), 9 deletions(-)

diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 0efc162..8cbb94e 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -312,6 +312,7 @@ LIBOSINFO_0.2.1 {
 	osinfo_install_config_param_is_required;
 	osinfo_install_script_get_expected_filename;
 	osinfo_install_script_get_config_param;
+	osinfo_media_get_installer_reboots;
 } LIBOSINFO_0.2.0;
 
 /* Symbols in next release...
diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
index 13cbe5f..934c758 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -652,6 +652,8 @@ static OsinfoMedia *osinfo_loader_media (OsinfoLoader *loader,
     gchar *arch = (gchar *)xmlGetProp(root, BAD_CAST "arch");
     xmlChar *live = xmlGetProp(root, BAD_CAST OSINFO_MEDIA_PROP_LIVE);
     xmlChar *installer = xmlGetProp(root, BAD_CAST OSINFO_MEDIA_PROP_INSTALLER);
+    xmlChar *installer_reboots =
+            xmlGetProp(root, BAD_CAST OSINFO_MEDIA_PROP_INSTALLER_REBOOTS);
     const gchar *const keys[] = {
         OSINFO_MEDIA_PROP_URL,
         OSINFO_MEDIA_PROP_KERNEL,
@@ -676,6 +678,13 @@ static OsinfoMedia *osinfo_loader_media (OsinfoLoader *loader,
         xmlFree(installer);
     }
 
+    if (installer_reboots) {
+        osinfo_entity_set_param(OSINFO_ENTITY(media),
+                                OSINFO_MEDIA_PROP_INSTALLER_REBOOTS,
+                                (gchar *)installer_reboots);
+        xmlFree(installer_reboots);
+    }
+
     gint nnodes = osinfo_loader_nodeset("./iso/*", ctxt, &nodes, err);
     if (error_is_set(err))
         return NULL;
diff --git a/osinfo/osinfo_media.c b/osinfo/osinfo_media.c
index 6e33634..e196e0f 100644
--- a/osinfo/osinfo_media.c
+++ b/osinfo/osinfo_media.c
@@ -151,6 +151,7 @@ enum {
     PROP_INITRD_PATH,
     PROP_INSTALLER,
     PROP_LIVE,
+    PROP_INSTALLER_REBOOTS,
 };
 
 static void
@@ -212,6 +213,11 @@ osinfo_media_get_property (GObject    *object,
                              osinfo_media_get_live (media));
         break;
 
+    case PROP_INSTALLER_REBOOTS:
+        g_value_set_int (value,
+                         osinfo_media_get_installer_reboots (media));
+        break;
+
     default:
         /* We don't have any other property... */
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -288,6 +294,12 @@ osinfo_media_set_property(GObject      *object,
                                          g_value_get_boolean (value));
         break;
 
+    case PROP_INSTALLER_REBOOTS:
+        osinfo_entity_set_param_int64 (OSINFO_ENTITY(media),
+                                       OSINFO_MEDIA_PROP_INSTALLER_REBOOTS,
+                                       g_value_get_int (value));
+        break;
+
     default:
         /* We don't have any other property... */
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -465,6 +477,33 @@ osinfo_media_class_init (OsinfoMediaClass *klass)
                                   G_PARAM_STATIC_NICK |
                                   G_PARAM_STATIC_BLURB);
     g_object_class_install_property (g_klass, PROP_LIVE, pspec);
+
+    /**
+     * OsinfoMedia::installer-reboots:
+     *
+     * If media is an installer, this property indicates the number of reboots
+     * the installer takes before installation is complete.
+     *
+     * This property is not applicable to media that has no installer. You can
+     * use #osinfo_media_get_installer (or OsinfoMedia::installer) to check
+     * that.
+     *
+     * Warning: Some media allow you to install from live sessions, in which
+     * case number of reboots *alone* is not a reliable method for tracking
+     * installation.
+     */
+    pspec = g_param_spec_int ("installer-reboots",
+                              "InstallerReboots",
+                              "Number of installer reboots",
+                              G_MININT,
+                              G_MAXINT,
+                              1 /* default value */,
+                              G_PARAM_READWRITE |
+                              G_PARAM_CONSTRUCT | /* to set default value */
+                              G_PARAM_STATIC_NAME |
+                              G_PARAM_STATIC_NICK |
+                              G_PARAM_STATIC_BLURB);
+    g_object_class_install_property (g_klass, PROP_INSTALLER_REBOOTS, pspec);
 }
 
 static void
@@ -1005,6 +1044,32 @@ gboolean osinfo_media_get_live(OsinfoMedia *media)
             (OSINFO_ENTITY(media), OSINFO_MEDIA_PROP_LIVE, FALSE);
 }
 
+/**
+ * osinfo_media_get_installer_reboots:
+ * @media: a #OsinfoMedia instance
+ *
+ * If media is an installer, this method retrieves the number of reboots the
+ * installer takes before installation is complete.
+ *
+ * This function is not supposed to be called on media that has no installer.
+ * You can use #osinfo_media_get_installer (or OsinfoMedia::installer) to check
+ * that.
+ *
+ * Warning: Some media allow you to install from live sessions, in which case
+ * number of reboots *alone* is not a reliable method for tracking installation.
+ *
+ * Returns: (transfer none): the number of installer reboots or -1 if media is
+ * not an installer
+ */
+gint osinfo_media_get_installer_reboots(OsinfoMedia *media)
+{
+    g_return_val_if_fail(OSINFO_IS_MEDIA(media), -1);
+    g_return_val_if_fail(osinfo_media_get_installer (media), -1);
+
+    return (gint) osinfo_entity_get_param_value_int64_with_default
+            (OSINFO_ENTITY(media), OSINFO_MEDIA_PROP_INSTALLER_REBOOTS, 1);
+}
+
 /*
  * Local variables:
  *  indent-tabs-mode: nil
diff --git a/osinfo/osinfo_media.h b/osinfo/osinfo_media.h
index e897a91..5982580 100644
--- a/osinfo/osinfo_media.h
+++ b/osinfo/osinfo_media.h
@@ -70,16 +70,17 @@ typedef struct _OsinfoMediaClass   OsinfoMediaClass;
 
 typedef struct _OsinfoMediaPrivate OsinfoMediaPrivate;
 
-#define OSINFO_MEDIA_PROP_ARCHITECTURE "architecture"
-#define OSINFO_MEDIA_PROP_URL          "url"
-#define OSINFO_MEDIA_PROP_VOLUME_ID    "volume-id"
-#define OSINFO_MEDIA_PROP_SYSTEM_ID    "system-id"
-#define OSINFO_MEDIA_PROP_PUBLISHER_ID "publisher-id"
+#define OSINFO_MEDIA_PROP_ARCHITECTURE   "architecture"
+#define OSINFO_MEDIA_PROP_URL            "url"
+#define OSINFO_MEDIA_PROP_VOLUME_ID      "volume-id"
+#define OSINFO_MEDIA_PROP_SYSTEM_ID      "system-id"
+#define OSINFO_MEDIA_PROP_PUBLISHER_ID   "publisher-id"
 #define OSINFO_MEDIA_PROP_APPLICATION_ID "application-id"
-#define OSINFO_MEDIA_PROP_KERNEL       "kernel"
-#define OSINFO_MEDIA_PROP_INITRD       "initrd"
-#define OSINFO_MEDIA_PROP_LIVE         "live"
-#define OSINFO_MEDIA_PROP_INSTALLER    "installer"
+#define OSINFO_MEDIA_PROP_KERNEL         "kernel"
+#define OSINFO_MEDIA_PROP_INITRD         "initrd"
+#define OSINFO_MEDIA_PROP_LIVE           "live"
+#define OSINFO_MEDIA_PROP_INSTALLER      "installer"
+#define OSINFO_MEDIA_PROP_INSTALLER_REBOOTS "installer-reboots"
 
 /* object */
 struct _OsinfoMedia
@@ -124,6 +125,7 @@ const gchar *osinfo_media_get_kernel_path(OsinfoMedia *media);
 const gchar *osinfo_media_get_initrd_path(OsinfoMedia *media);
 gboolean osinfo_media_get_installer(OsinfoMedia *media);
 gboolean osinfo_media_get_live(OsinfoMedia *media);
+gint osinfo_media_get_installer_reboots(OsinfoMedia *media);
 
 #endif /* __OSINFO_MEDIA_H__ */
 /*
-- 
1.7.12.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]