From: Timm Bäder <mail(a)baedert.org>
---
configure.ac | 2 +-
libvirt-gobject/libvirt-gobject-domain.c | 61 ++++++++++++++++++++++++++++++++
libvirt-gobject/libvirt-gobject-domain.h | 10 ++++++
libvirt-gobject/libvirt-gobject.sym | 2 ++
4 files changed, 74 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 097f7f4..8e55509 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11,7 +11,7 @@ AM_SILENT_RULES([yes])
LIBVIRT_REQUIRED=0.10.2
AC_SUBST([LIBVIRT_REQUIRED]) dnl used in the .spec file
-GLIB2_REQUIRED=2.22.0
+GLIB2_REQUIRED=2.36.0
GLIB2_TEST_REQUIRED=2.38.0
GOBJECT2_REQUIRED=2.10.0
GIO_REQUIRED=2.10.0
diff --git a/libvirt-gobject/libvirt-gobject-domain.c
b/libvirt-gobject/libvirt-gobject-domain.c
index 8fcdaa4..5399892 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -1625,3 +1625,64 @@ GList *gvir_domain_get_snapshots(GVirDomain *dom)
return snapshots;
}
+
+
+
+static void _fetch_snapshots_async_thread(GTask *task,
+ gpointer source_object,
+ gpointer task_data,
+ GCancellable *cancellable) {
+ GError *error = NULL;
+ gboolean status;
+
+ status = gvir_domain_fetch_snapshots(source_object,
+ GPOINTER_TO_UINT(task_data),
+ cancellable,
+ &error);
+ if (status)
+ g_task_return_boolean(task, TRUE);
+ else
+ g_task_return_error(task, error);
+}
+
+
+/**
+ *
+ * @dom: The domain
+ * @list_flags: bitwise-OR of #GVirDomainSnapshotListFlags
+ * @cancellable: (allow-none)(transfer-none): cancellation object
+ * @callback: (scope async): completion callback
+ * @user_data: (closure): opaque data for callback
+ */
+void gvir_domain_fetch_snapshots_async(GVirDomain *dom,
+ guint list_flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data) {
+ GTask *task;
+
+ g_return_if_fail(GVIR_IS_DOMAIN(dom));
+ g_return_if_fail((cancellable == NULL) || G_IS_CANCELLABLE(cancellable));
+
+ task = g_task_new(dom, cancellable, callback, user_data);
+ g_task_set_task_data(task, GUINT_TO_POINTER(list_flags), NULL);
+ g_task_run_in_thread(task, _fetch_snapshots_async_thread);
+ g_object_unref(task);
+}
+
+
+/**
+ * gvir_domain_fetch_snapshots_finish:
+ * @dom: a #GVirDomain
+ * @res: (transfer none): async method result
+ *
+ * Returns: TRUE on success, FALSE otherwise.
+ */
+gboolean gvir_domain_fetch_snapshots_finish(GVirDomain *dom,
+ GAsyncResult *res,
+ GError **error) {
+ g_return_val_if_fail(GVIR_IS_DOMAIN(dom), FALSE);
+ g_return_val_if_fail(g_task_is_valid(res, dom), FALSE);
+
+ return g_task_propagate_boolean(G_TASK(res), error);
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain.h
b/libvirt-gobject/libvirt-gobject-domain.h
index 22870c1..9846375 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -370,6 +370,16 @@ gboolean gvir_domain_fetch_snapshots(GVirDomain *dom,
GList *gvir_domain_get_snapshots(GVirDomain *dom);
+void gvir_domain_fetch_snapshots_async(GVirDomain *dom,
+ guint list_flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+gboolean gvir_domain_fetch_snapshots_finish(GVirDomain *dom,
+ GAsyncResult *res,
+ GError **error);
+
G_END_DECLS
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index 28e547a..6aa8b86 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -237,6 +237,8 @@ LIBVIRT_GOBJECT_0.1.5 {
LIBVIRT_GOBJECT_0.1.9 {
global:
gvir_domain_fetch_snapshots;
+ gvir_domain_fetch_snapshots_async;
+ gvir_domain_fetch_snapshots_finish;
gvir_domain_get_snapshots;
gvir_domain_snapshot_delete;
gvir_domain_snapshot_list_flags_get_type;
--
2.0.3