[libvirt-glib] [PATCH v2 2/4] GVirDomainSnapshot: Add async version of _revert_to

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

 



---
 libvirt-gobject/libvirt-gobject-domain-snapshot.c | 59 +++++++++++++++++++++++
 libvirt-gobject/libvirt-gobject-domain-snapshot.h | 11 +++++
 libvirt-gobject/libvirt-gobject.sym               |  2 +
 3 files changed, 72 insertions(+)

diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.c b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
index b071c5b..0dcbecc 100644
--- a/libvirt-gobject/libvirt-gobject-domain-snapshot.c
+++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
@@ -304,6 +304,65 @@ gboolean gvir_domain_snapshot_revert_to(GVirDomainSnapshot *snapshot,
     return TRUE;
 }
 
+static void _revert_to_async_thread(GTask *task,
+                                    gpointer source_object,
+                                    gpointer task_data,
+                                    GCancellable *cancellable) {
+    GError *error = NULL;
+    gboolean status;
+
+    status = gvir_domain_snapshot_revert_to(source_object,
+                                            GPOINTER_TO_UINT(task_data),
+                                            cancellable,
+                                            &error);
+
+    if (status)
+        g_task_return_boolean(task, TRUE);
+    else
+        g_task_return_error(task, error);
+}
+
+
+/**
+ * gvir_domain_snapshot_revert_to_async:
+ * @snapshot: A #GVirDomainSnapshot
+ * @cancellable: (allow-none) (transfer none): cancellation object
+ * @callback: (scope async): The callback
+ * @user_data: (closure): Opaque data for callback
+ */
+void gvir_domain_snapshot_revert_to_async(GVirDomainSnapshot *snapshot,
+                                          guint flags,
+                                          GCancellable *cancellable,
+                                          GAsyncReadyCallback callback,
+                                          gpointer user_data) {
+    GTask *task;
+
+    g_return_if_fail(GVIR_IS_DOMAIN_SNAPSHOT(snapshot));
+
+    task = g_task_new(snapshot, cancellable, callback, user_data);
+    g_task_set_task_data(task, GUINT_TO_POINTER(flags), NULL);
+    g_task_run_in_thread(task, _revert_to_async_thread);
+    g_object_unref(task);
+}
+
+
+
+/**
+ * gvir_domain_snapshot_revert_to_finished:
+ * @snapshot: The domain snapshot
+ * @result: (transfer none): The result
+ *
+ * Returns: %TRUE on success, %FALSE otherwise.
+ */
+gboolean gvir_domain_snapshot_revert_to_finish(GVirDomainSnapshot *snapshot,
+                                               GAsyncResult *result,
+                                               GError **error) {
+    g_return_val_if_fail(GVIR_IS_DOMAIN_SNAPSHOT(snapshot), FALSE);
+    g_return_val_if_fail(g_task_is_valid(result, snapshot), FALSE);
+
+    return g_task_propagate_boolean(G_TASK(result), error);
+}
+
 
 
 /**
diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.h b/libvirt-gobject/libvirt-gobject-domain-snapshot.h
index 401698a..0f4d31f 100644
--- a/libvirt-gobject/libvirt-gobject-domain-snapshot.h
+++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.h
@@ -108,6 +108,17 @@ gboolean gvir_domain_snapshot_revert_to(GVirDomainSnapshot *snapshot,
                                         GCancellable *cancellable,
                                         GError **error);
 
+void gvir_domain_snapshot_revert_to_async(GVirDomainSnapshot *snapshot,
+                                          guint flags,
+                                          GCancellable *cancellable,
+                                          GAsyncReadyCallback callback,
+                                          gpointer user_data);
+
+gboolean gvir_domain_snapshot_revert_to_finish(GVirDomainSnapshot *snapshot,
+                                               GAsyncResult *result,
+                                               GError **error);
+
+
 gboolean gvir_domain_snapshot_set_config(GVirDomainSnapshot *snapshot,
                                          GVirConfigDomainSnapshot *conf,
                                          GError **error);
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index 68e9b58..ebb9418 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -247,6 +247,8 @@ LIBVIRT_GOBJECT_0.1.9 {
 	gvir_domain_snapshot_list_flags_get_type;
 	gvir_domain_snapshot_revert_flags_get_type;
 	gvir_domain_snapshot_revert_to;
+	gvir_domain_snapshot_revert_to_async;
+	gvir_domain_snapshot_revert_to_finish;
 	gvir_domain_snapshot_set_config;
 	gvir_storage_pool_state_get_type;
 	gvir_storage_vol_resize_flags_get_type;
-- 
2.0.4

--
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]