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

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

 



... 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 180a206..b12a4a0 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -1597,3 +1597,24 @@ cleanup:
     free(snapshots);
     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)
+{
+    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 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.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]