[libvirt-glib] Add API to redefine an existing domain

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

 



From: "Zeeshan Ali (Khattak)" <zeeshanak@xxxxxxxxx>

---
 libvirt-gobject/libvirt-gobject-connection.c |   37 ++++++++++++++++++++++++++
 libvirt-gobject/libvirt-gobject-connection.h |    4 +++
 libvirt-gobject/libvirt-gobject.sym          |    1 +
 3 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c
index 6c8de11..471c795 100644
--- a/libvirt-gobject/libvirt-gobject-connection.c
+++ b/libvirt-gobject/libvirt-gobject-connection.c
@@ -1201,6 +1201,43 @@ GVirDomain *gvir_connection_create_domain(GVirConnection *conn,
 }
 
 /**
+ * gvir_connection_redefine_domain:
+ * @conn: the connection on which the dmain exists
+ * @conf: the new configuration for the domain
+ *
+ * Redefines an existing domain.
+ */
+void gvir_connection_redefine_domain(GVirConnection *conn,
+                                     GVirDomain *domain,
+                                     GVirConfigDomain *conf,
+                                     GError **err)
+{
+    const gchar *xml;
+    virDomainPtr handle;
+    GVirDomain *dom;
+    virDomainPtr dom_handle;
+    GVirConnectionPrivate *priv = conn->priv;
+
+    xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(conf));
+
+    g_return_if_fail(xml != NULL);
+
+    g_mutex_lock(priv->lock);
+    dom = g_hash_table_lookup (priv->domains,
+                               (gpointer)gvir_domain_get_uuid(domain));
+    g_mutex_unlock(priv->lock);
+    g_return_if_fail(dom != NULL);
+    /* FIXME: Check if config's domain ID is the same as domain passed */
+
+    if (!(handle = virDomainDefineXML(priv->conn, xml))) {
+        *err = gvir_error_new_literal(GVIR_CONNECTION_ERROR,
+                                      0,
+                                      "Failed to redefine domain");
+        return NULL;
+    }
+}
+
+/**
  * gvir_connection_create_storage_pool:
  * @conn: the connection on which to create the pool
  * @conf: the configuration for the new storage pool
diff --git a/libvirt-gobject/libvirt-gobject-connection.h b/libvirt-gobject/libvirt-gobject-connection.h
index 9f4bdc3..c23d948 100644
--- a/libvirt-gobject/libvirt-gobject-connection.h
+++ b/libvirt-gobject/libvirt-gobject-connection.h
@@ -110,6 +110,10 @@ GVirDomain *gvir_connection_find_domain_by_name(GVirConnection *conn,
 GVirDomain *gvir_connection_create_domain(GVirConnection *conn,
                                           GVirConfigDomain *conf,
                                           GError **err);
+void gvir_connection_redefine_domain(GVirConnection *conn,
+                                     GVirDomain *domain,
+                                     GVirConfigDomain *conf,
+                                     GError **err);
 
 #if 0
 GList *gvir_connection_get_interfaces(GVirConnection *conn);
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index 164b6b8..b5cc347 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -27,6 +27,7 @@ LIBVIRT_GOBJECT_0.0.1 {
 	gvir_connection_find_domain_by_name;
 	gvir_connection_find_storage_pool_by_name;
 	gvir_connection_create_domain;
+	gvir_connection_redefine_domain;
 	gvir_connection_create_storage_pool;
 
 	gvir_domain_device_get_type;
-- 
1.7.7.1

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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]