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

2014-06-27 Thread Timm Bäder
... 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 a527d4e..e4c99ed 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -1575,3 +1575,24 @@ gboolean gvir_domain_fetch_snapshots(GVirDomain *dom,
 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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


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

2014-06-27 Thread Christophe Fergeau
Looks good, ACK.


On Fri, Jun 27, 2014 at 04:35:07PM +0200, Timm Bäder wrote:
 ... 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 a527d4e..e4c99ed 100644
 --- a/libvirt-gobject/libvirt-gobject-domain.c
 +++ b/libvirt-gobject/libvirt-gobject-domain.c
 @@ -1575,3 +1575,24 @@ gboolean gvir_domain_fetch_snapshots(GVirDomain *dom,
  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
 
 --
 libvir-list mailing list
 libvir-list@redhat.com
 https://www.redhat.com/mailman/listinfo/libvir-list


pgpZ5tLU4_noS.pgp
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list