From: "Zeeshan Ali (Khattak)" <zeesha...@gnome.org>

---
 libvirt-gobject/libvirt-gobject-domain.c |   48 ++++++++++++++++++++++++++++++
 libvirt-gobject/libvirt-gobject-domain.h |    3 ++
 libvirt-gobject/libvirt-gobject.sym      |    1 +
 3 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/libvirt-gobject/libvirt-gobject-domain.c 
b/libvirt-gobject/libvirt-gobject-domain.c
index 1fa27bd..01ae1f4 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -449,6 +449,54 @@ GVirConfigDomain *gvir_domain_get_config(GVirDomain *dom,
     return conf;
 }
 
+/**
+ * gvir_domain_set_config:
+ * @domain: the domain
+ * @conf: the new configuration for the domain
+ * @error: (allow-none): Place-holder for error or NULL
+ *
+ * Resets configuration of an existing domain.
+ *
+ * Note: If domain is already running, the new configuration will not take
+ * affect until domain reboots.
+ *
+ * Returns: TRUE on success, FALSE if an error occurred.
+ */
+gboolean gvir_domain_set_config(GVirDomain *domain,
+                                GVirConfigDomain *conf,
+                                GError **error)
+{
+    const gchar *xml;
+    virConnectPtr conn;
+    GVirDomainPrivate *priv = domain->priv;
+
+    g_return_val_if_fail(GVIR_IS_DOMAIN (domain), FALSE);
+    g_return_val_if_fail(GVIR_IS_CONFIG_DOMAIN (conf), FALSE);
+    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
+
+    xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(conf));
+
+    g_return_val_if_fail(xml != NULL, FALSE);
+
+    if ((conn = virDomainGetConnect(priv->handle)) == NULL) {
+        if (error != NULL)
+            *error = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
+                                            0,
+                                            "Failed to get domain connection");
+        return FALSE;
+    }
+
+    if (virDomainDefineXML(conn, xml) == NULL) {
+        if (error != NULL)
+            *error = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
+                                            0,
+                                            "Failed to set "
+                                            "domain configuration");
+        return FALSE;
+   }
+
+   return TRUE;
+}
 
 /**
  * gvir_domain_get_info:
diff --git a/libvirt-gobject/libvirt-gobject-domain.h 
b/libvirt-gobject/libvirt-gobject-domain.h
index 94bd53e..0479de8 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -123,6 +123,9 @@ GVirDomainInfo *gvir_domain_get_info(GVirDomain *dom,
 GVirConfigDomain *gvir_domain_get_config(GVirDomain *dom,
                                          guint64 flags,
                                          GError **err);
+gboolean gvir_domain_set_config(GVirDomain *domain,
+                                GVirConfigDomain *conf,
+                                GError **err);
 
 gchar *gvir_domain_screenshot(GVirDomain *dom,
                               GVirStream *stream,
diff --git a/libvirt-gobject/libvirt-gobject.sym 
b/libvirt-gobject/libvirt-gobject.sym
index 164b6b8..46c53f9 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -53,6 +53,7 @@ LIBVIRT_GOBJECT_0.0.1 {
        gvir_domain_shutdown;
        gvir_domain_reboot;
        gvir_domain_get_config;
+       gvir_domain_set_config;
        gvir_domain_get_info;
        gvir_domain_screenshot;
 
-- 
1.7.7.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to