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

[libvirt] [glib PATCH V6] Add bindings for virDomainSnapshotCreateXML()



---
 libvirt-gobject/libvirt-gobject-domain.c |   42 ++++++++++++++++++++++++++++++
 libvirt-gobject/libvirt-gobject-domain.h |    6 +++++
 libvirt-gobject/libvirt-gobject.sym      |    1 +
 3 files changed, 49 insertions(+)

diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index 088cd33..ce81971 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -1123,3 +1123,45 @@ GList *gvir_domain_get_devices(GVirDomain *domain,
 
     return g_list_reverse (ret);
 }
+
+/**
+ * gvir_domain_snapshot_create_xml:
+ * @dom: the domain
+ * @custom_conf: (allow-none): configuration of snapshot or NULL
+ * @flags: the flags
+ * @err: (allow-none):Place-holder for error or NULL
+ *
+ * Returns: (transfer full): snapshot of domain. The returned object should be
+ * unreffed when no longer needed
+ */
+GVirConfigDomainSnapshot *gvir_domain_snapshot_create_xml
+                                      (GVirDomain *dom,
+                                       GVirConfigDomainSnapshot *custom_conf,
+                                       guint flags,
+                                       GError **err)
+{
+    GVirDomainPrivate *priv;
+    virDomainSnapshot *snapshot;
+    GVirConfigDomainSnapshot *conf_snapshot;
+    gchar *custom_xml = NULL;
+
+    g_return_val_if_fail(GVIR_IS_DOMAIN(dom), FALSE);
+    g_return_val_if_fail(err == NULL || *err == NULL, NULL);
+
+    priv = dom->priv;
+
+    if (custom_conf != NULL)
+        custom_xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(custom_conf));
+
+    if (!(snapshot = virDomainSnapshotCreateXML(priv->handle, custom_xml, flags))) {
+        gvir_set_error_literal(err, GVIR_DOMAIN_ERROR,
+                               0,
+                              "Unable to create snapshot of domain");
+        return NULL;
+    }
+
+    conf_snapshot = gvir_config_domain_snapshot_new_from_xml(custom_xml, err);
+
+    g_free(custom_xml);
+    return conf_snapshot;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h
index 87b94f4..8c4d28e 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -202,6 +202,12 @@ gboolean gvir_domain_get_saved(GVirDomain *dom);
 GList *gvir_domain_get_devices(GVirDomain *domain,
                                GError **err);
 
+GVirConfigDomainSnapshot *gvir_domain_snapshot_create_xml
+                                      (GVirDomain *dom,
+                                       GVirConfigDomainSnapshot *custom_conf,
+                                       guint flags,
+                                       GError **err);
+
 G_END_DECLS
 
 #endif /* __LIBVIRT_GOBJECT_DOMAIN_H__ */
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index 94e441a..045e1b5 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -75,6 +75,7 @@ LIBVIRT_GOBJECT_0.0.8 {
 	gvir_domain_get_persistent;
 	gvir_domain_get_saved;
 	gvir_domain_screenshot;
+	gvir_domain_snapshot_create_xml;
 
 	gvir_domain_snapshot_get_type;
 	gvir_domain_snapshot_handle_get_type;
-- 
1.7.10.4


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