---
libvirt-gobject/libvirt-gobject-domain.c | 52 ++++++++++++++++++++++++++++++++
libvirt-gobject/libvirt-gobject-domain.h | 7 +++++
libvirt-gobject/libvirt-gobject.sym | 2 ++
3 files changed, 61 insertions(+)
diff --git a/libvirt-gobject/libvirt-gobject-domain.c
b/libvirt-gobject/libvirt-gobject-domain.c
index 861f713..31aa61a 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -1273,3 +1273,55 @@ GList *gvir_domain_get_devices(GVirDomain *domain,
return g_list_reverse (ret);
}
+
+/**
+ * gvir_domain_create_snapshot:
+ * @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
+ */
+GVirDomainSnapshot *
+gvir_domain_create_snapshot(GVirDomain *dom,
+ GVirConfigDomainSnapshot *custom_conf,
+ guint flags,
+ GError **err)
+{
+ GVirDomainPrivate *priv;
+ virDomainSnapshot *snapshot;
+ GVirDomainSnapshot *dom_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))) {
+ const gchar *domain_name = NULL;
+ domain_name = gvir_domain_get_name(dom);
+
+ gvir_set_error(err, GVIR_DOMAIN_ERROR,
+ 0,
+ "Unable to create snapshot of %s", domain_name);
+
+ g_free(custom_xml);
+ return NULL;
+ }
+
+ dom_snapshot = GVIR_DOMAIN_SNAPSHOT(g_object_new(GVIR_TYPE_DOMAIN_SNAPSHOT,
+ "handle",
+ snapshot,
+ NULL));
+
+ g_free(custom_xml);
+ return dom_snapshot;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain.h
b/libvirt-gobject/libvirt-gobject-domain.h
index c61a2f5..d10fa8d 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -31,6 +31,7 @@ G_BEGIN_DECLS
#include <libvirt-gobject/libvirt-gobject-stream.h>
#include <libvirt/libvirt.h>
+#include <libvirt-gobject/libvirt-gobject-domain-snapshot.h>
#define GVIR_TYPE_DOMAIN (gvir_domain_get_type ())
#define GVIR_DOMAIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_TYPE_DOMAIN,
GVirDomain))
@@ -247,6 +248,12 @@ gboolean gvir_domain_get_saved(GVirDomain *dom);
GList *gvir_domain_get_devices(GVirDomain *domain,
GError **err);
+GVirDomainSnapshot *
+gvir_domain_create_snapshot(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 8f7bcef..5d15e7a 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -183,6 +183,8 @@ LIBVIRT_GOBJECT_0.1.1 {
global:
gvir_domain_shutdown_flags_get_type;
gvir_domain_xml_flags_get_type;
+
+ gvir_domain_create_snapshot;
} LIBVIRT_GOBJECT_0.0.9;
# .... define new API here using predicted next version number ....
--
1.7.11.2