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

[libvirt] [libvirt-glib] Add gvir_domain_update_device() and enums needed for it



This is a wrapper for virDomainUpdateDeviceFlags.
---
 libvirt-gobject/libvirt-gobject-domain.c | 42 ++++++++++++++++++++++++++++++++
 libvirt-gobject/libvirt-gobject-domain.h | 17 +++++++++++++
 libvirt-gobject/libvirt-gobject.sym      |  7 ++++++
 3 files changed, 66 insertions(+)

diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index 8ade3ea..a00a042 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -1428,6 +1428,48 @@ GList *gvir_domain_get_devices(GVirDomain *domain,
     return g_list_reverse (ret);
 }
 
+
+/**
+ * gvir_domain_update_device:
+ * @dom: the domain
+ * @device: A modified device config
+ * @flags: bitwise-OR of #GVirDomainUpdateDeviceFlags
+ * @err: (allow-none):Place-holder for error or NULL
+ *
+ * Update the configuration of a device.
+ *
+ * Returns: TRUE if device was updated successfully, FALSE otherwise.
+ */
+gboolean
+gvir_domain_update_device(GVirDomain *dom,
+                          GVirConfigDomainDevice *device,
+                          guint flags,
+                          GError **err)
+{
+    gchar *xml;
+
+    g_return_val_if_fail(GVIR_IS_DOMAIN(dom), FALSE);
+    g_return_val_if_fail(err == NULL || *err == NULL, FALSE);
+    g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_DEVICE(device), FALSE);
+
+    xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(device));
+    g_return_val_if_fail(xml != NULL, FALSE);
+
+    if (virDomainUpdateDeviceFlags(dom->priv->handle,
+                                   xml, flags) < 0) {
+        gvir_set_error_literal(err, GVIR_DOMAIN_ERROR,
+                               0,
+                               "Failed to update device");
+        g_free (xml);
+
+        return FALSE;
+    }
+
+    g_free (xml);
+    return TRUE;
+}
+
+
 /**
  * gvir_domain_create_snapshot:
  * @dom: the domain
diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h
index 6e7b10d..a622a46 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -158,6 +158,18 @@ typedef enum {
     GVIR_DOMAIN_SNAPSHOT_ATOMIC       = VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC,
 } GVirDomainSnapshotCreateFlags;
 
+/**
+ * GVirDomainUpdateDeviceFlags:
+ * @GVIR_DOMAIN_UPDATE_DEVICE_CURRENT: Update current domain state
+ * @GVIR_DOMAIN_UPDATE_DEVICE_LIVE: Update state for only active domains
+ * @GVIR_DOMAIN_UPDATE_DEVICE_CONFIG: Update state for persistent state only
+ */
+typedef enum {
+    GVIR_DOMAIN_UPDATE_DEVICE_CURRENT   = VIR_DOMAIN_AFFECT_CURRENT,
+    GVIR_DOMAIN_UPDATE_DEVICE_LIVE      = VIR_DOMAIN_AFFECT_LIVE,
+    GVIR_DOMAIN_UPDATE_DEVICE_CONFIG    = VIR_DOMAIN_AFFECT_CONFIG,
+} GVirDomainUpdateDeviceFlags;
+
 typedef struct _GVirDomainInfo GVirDomainInfo;
 struct _GVirDomainInfo
 {
@@ -294,6 +306,11 @@ gboolean gvir_domain_get_saved(GVirDomain *dom);
 GList *gvir_domain_get_devices(GVirDomain *domain,
                                GError **err);
 
+gboolean gvir_domain_update_device(GVirDomain *dom,
+				   GVirConfigDomainDevice *device,
+				   guint flags,
+				   GError **err);
+
 GVirDomainSnapshot *
 gvir_domain_create_snapshot(GVirDomain *dom,
                             GVirConfigDomainSnapshot *custom_conf,
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index 3a40a8a..2034e89 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -204,4 +204,11 @@ LIBVIRT_GOBJECT_0.1.3 {
     gvir_domain_wakeup_finish;
 } LIBVIRT_GOBJECT_0.1.2;
 
+LIBVIRT_GOBJECT_0.1.4 {
+  global:
+    gvir_domain_update_device_flags_get_type;
+    gvir_domain_update_device;
+} LIBVIRT_GOBJECT_0.1.3;
+
+
 # .... define new API here using predicted next version number ....
-- 
1.7.12.1


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