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

mail at baedert.org mail at baedert.org
Thu Jul 31 20:16:22 UTC 2014


From: Timm Bäder <mail at baedert.org>

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

diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index 708cb3b..8fcdaa4 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -1599,3 +1599,29 @@ cleanup:
         g_hash_table_unref(snap_table);
     return ret;
 }
+
+/**
+ * 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)
+{
+    GVirDomainPrivate *priv;
+    GList *snapshots = NULL;
+    g_return_val_if_fail(GVIR_IS_DOMAIN(dom), NULL);
+
+    priv = dom->priv;
+
+    g_mutex_lock (priv->lock);
+    if (dom->priv->snapshots != NULL) {
+        snapshots = g_hash_table_get_values(priv->snapshots);
+        g_list_foreach(snapshots, (GFunc)g_object_ref, NULL);
+    }
+    g_mutex_unlock (priv->lock);
+
+    return snapshots;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h
index 8c1a8e5..22870c1 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -367,6 +367,10 @@ gboolean gvir_domain_fetch_snapshots(GVirDomain *dom,
                                      guint list_flags,
                                      GCancellable *cancellable,
                                      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.3




More information about the libvir-list mailing list