[libvirt] [libvirt-glib] [PATCH 2/2] libvirt-gobject-domain: Add _get_snapshots

Timm Bäder mail at baedert.org
Mon Jun 23 15:29:11 UTC 2014


... which returns a GList of GVirDomainSnapshots, i.e. without any tree
structure or other relationship between the snapshots.
---
 libvirt-gobject/libvirt-gobject-domain.c | 21 +++++++++++++++++++++
 libvirt-gobject/libvirt-gobject-domain.h |  4 ++++
 libvirt-gobject/libvirt-gobject.sym      |  1 +
 3 files changed, 26 insertions(+)

diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index f6b5837..2da99df 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -1573,3 +1573,24 @@ gboolean gvir_domain_fetch_snapshots(GVirDomain *dom,
     g_free(snapshots);
     return TRUE;
 }
+
+/**
+ * gvir_domain_get_snapshots:
+ * @dom: The domain
+ * Returns: (element-type LibvirtGObject.DomainSnapshot) (transfer full): A list of
+ * all the snapshots available for the given domain. The returned list
+ * should be freed with g_list_free(), after its elements have been unreffed
+ * with g_object_unref().
+ */
+GList *gvir_domain_get_snapshots(GVirDomain *dom)
+{
+    GList *snapshots = NULL;
+    g_return_val_if_fail(GVIR_IS_DOMAIN(dom), NULL);
+
+    if (dom->priv->snapshots != NULL) {
+        snapshots = g_hash_table_get_values(dom->priv->snapshots);
+        g_list_foreach(snapshots, (GFunc)g_object_ref, NULL);
+    }
+
+    return snapshots;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h
index fb33e2b..acea7c2 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -366,6 +366,10 @@ gvir_domain_create_snapshot(GVirDomain *dom,
 gboolean gvir_domain_fetch_snapshots(GVirDomain *dom,
                                      guint flags,
                                      GError **error);
+
+GList *gvir_domain_get_snapshots(GVirDomain *dom);
+
+
 G_END_DECLS
 
 #endif /* __LIBVIRT_GOBJECT_DOMAIN_H__ */
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index 781310f..28e547a 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -237,6 +237,7 @@ LIBVIRT_GOBJECT_0.1.5 {
 LIBVIRT_GOBJECT_0.1.9 {
   global:
 	gvir_domain_fetch_snapshots;
+	gvir_domain_get_snapshots;
 	gvir_domain_snapshot_delete;
 	gvir_domain_snapshot_list_flags_get_type;
 } LIBVIRT_GOBJECT_0.1.5;
-- 
2.0.0




More information about the libvir-list mailing list