[libvirt-glib] [PATCH 4/4] GVirDomainSnapshot: Add async version of _delete

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

 



---
 libvirt-gobject/libvirt-gobject-domain-snapshot.c | 56 +++++++++++++++++++++++
 libvirt-gobject/libvirt-gobject-domain-snapshot.h |  9 ++++
 libvirt-gobject/libvirt-gobject.sym               |  2 +
 3 files changed, 67 insertions(+)

diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.c b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
index 61ca53e..46aa70f 100644
--- a/libvirt-gobject/libvirt-gobject-domain-snapshot.c
+++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
@@ -237,6 +237,62 @@ gboolean gvir_domain_snapshot_delete (GVirDomainSnapshot *snapshot,
 }
 
 
+
+static void _delete_async_thread(GTask *task,
+                                 gpointer source_object,
+                                 gpointer task_data,
+                                 GCancellable *cancellable) {
+    GError *error = NULL;
+    gboolean status;
+
+    status = gvir_domain_snapshot_delete(source_object,
+                                         GPOINTER_TO_UINT(task_data),
+                                         &error);
+
+    if (status)
+        g_task_return_boolean(task, TRUE);
+    else
+        g_task_return_error(task, error);
+}
+
+
+/**
+ * gvir_domain_snapshot_delete_async:
+ * @snapshot: A #GVirDomainSnapshot
+ * @flags: Bitwise-OR of #GVirDomainSnapshotDeleteFlags
+ * @callback: (scope async): completion callback
+ * @user_data: (closure): opaque data for callback
+ */
+void gvir_domain_snapshot_delete_async(GVirDomainSnapshot *snapshot,
+                                       guint flags,
+                                       GAsyncReadyCallback callback,
+                                       gpointer user_data) {
+    GTask *task;
+
+    g_return_if_fail(GVIR_IS_DOMAIN_SNAPSHOT(snapshot));
+
+    task = g_task_new(snapshot, NULL, callback, user_data);
+    g_task_set_task_data(task, GUINT_TO_POINTER(flags), NULL);
+    g_task_run_in_thread(task, _delete_async_thread);
+    g_object_unref(task);
+}
+
+/**
+ * gvir_domain_snapshot_delete_finish:
+ * @snapshot: A #GVirDomainSnapshot
+ * @res: (transfer none): async method result
+ *
+ * Returns: %TRUE on success, %FALSE otherwise.
+ */
+gboolean gvir_domain_snapshot_delete_finish(GVirDomainSnapshot *snapshot,
+                                            GAsyncResult *res,
+                                            GError **error) {
+    g_return_val_if_fail(GVIR_IS_DOMAIN_SNAPSHOT(snapshot), FALSE);
+    g_return_val_if_fail(g_task_is_valid(res, snapshot), FALSE);
+
+    return g_task_propagate_boolean(G_TASK(res), error);
+}
+
 /**
  * gvir_domain_snapshot_get_is_current:
  * @snapshot: The domain snapshot
diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.h b/libvirt-gobject/libvirt-gobject-domain-snapshot.h
index c6262e8..ba85dee 100644
--- a/libvirt-gobject/libvirt-gobject-domain-snapshot.h
+++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.h
@@ -98,6 +98,15 @@ gboolean gvir_domain_snapshot_delete (GVirDomainSnapshot *snapshot,
                                       guint flags,
                                       GError **error);
 
+void gvir_domain_snapshot_delete_async(GVirDomainSnapshot *snapshot,
+                                       guint flags,
+                                       GAsyncReadyCallback callback,
+                                       gpointer user_data);
+
+gboolean gvir_domain_snapshot_delete_finish(GVirDomainSnapshot *snapshot,
+                                            GAsyncResult *res,
+                                            GError **error);
+
 gboolean gvir_domain_snapshot_get_is_current(GVirDomainSnapshot *snapshot,
                                              guint flags,
                                              gboolean *is_current,
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index a610121..f335399 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -244,6 +244,8 @@ LIBVIRT_GOBJECT_0.1.9 {
 	gvir_domain_get_snapshots;
 	gvir_domain_get_has_current_snapshot;
 	gvir_domain_snapshot_delete;
+	gvir_domain_snapshot_delete_async;
+	gvir_domain_snapshot_delete_finish;
 	gvir_domain_snapshot_delete_flags_get_type;
 	gvir_domain_snapshot_get_is_current;
 	gvir_domain_snapshot_list_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]