[libvirt] [libvirt-glib] [PATCH 0/4] Add some async versions of synchronous snapshot API

This adds async versions of a few snapshot related functions and a patch that cleans up some doc comments I crewed up in earlier commits. All the sync versions don't seem cancellable to me since we can't just throw the result away like we do when fetching snapshots in case the operation gets cancelled, so none of them take a GCancellable. Timm Bäder (4): GVirDomain: Fix some doc comments of the snapshot API GVirDomainSnapshot: Add async version of _revert_to GVirDomain: Add async version of _create_snapshot GVirDomainSnapshot: Add async version of _delete libvirt-gobject/libvirt-gobject-domain-snapshot.c | 112 ++++++++++++++++++++++ libvirt-gobject/libvirt-gobject-domain-snapshot.h | 19 ++++ libvirt-gobject/libvirt-gobject-domain.c | 77 ++++++++++++++- libvirt-gobject/libvirt-gobject-domain.h | 11 +++ libvirt-gobject/libvirt-gobject.sym | 6 ++ 5 files changed, 220 insertions(+), 5 deletions(-) -- 2.0.4

Fixes some warnings from g-ir-scanner. --- libvirt-gobject/libvirt-gobject-domain.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c index feac6f0..aa2a170 100644 --- a/libvirt-gobject/libvirt-gobject-domain.c +++ b/libvirt-gobject/libvirt-gobject-domain.c @@ -1529,10 +1529,10 @@ gvir_domain_create_snapshot(GVirDomain *dom, * gvir_domain_fetch_snapshots: * @dom: The domain * @list_flags: bitwise-OR of #GVirDomainSnapshotListFlags - * @cancellable: (allow-none)(transfer-none): cancellation object - * @error: (allow-none): Place-holder for error or NULL + * @cancellable: (allow-none) (transfer none): cancellation object + * @error: (allow-none): Place-holder for error or %NULL * - * Returns: TRUE on success, FALSE otherwise. + * Returns: %TRUE on success, %FALSE otherwise. */ gboolean gvir_domain_fetch_snapshots(GVirDomain *dom, guint list_flags, @@ -1647,10 +1647,10 @@ static void _fetch_snapshots_async_thread(GTask *task, /** - * + * gvir_domain_fetch_snapshots_async: * @dom: The domain * @list_flags: bitwise-OR of #GVirDomainSnapshotListFlags - * @cancellable: (allow-none)(transfer-none): cancellation object + * @cancellable: (allow-none) (transfer none): cancellation object * @callback: (scope async): completion callback * @user_data: (closure): opaque data for callback */ -- 2.0.4

Hey, On Fri, Aug 15, 2014 at 12:05:44PM +0200, Timm Bäder wrote:
Fixes some warnings from g-ir-scanner. --- libvirt-gobject/libvirt-gobject-domain.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c index feac6f0..aa2a170 100644 --- a/libvirt-gobject/libvirt-gobject-domain.c +++ b/libvirt-gobject/libvirt-gobject-domain.c @@ -1529,10 +1529,10 @@ gvir_domain_create_snapshot(GVirDomain *dom, * gvir_domain_fetch_snapshots: * @dom: The domain * @list_flags: bitwise-OR of #GVirDomainSnapshotListFlags - * @cancellable: (allow-none)(transfer-none): cancellation object - * @error: (allow-none): Place-holder for error or NULL + * @cancellable: (allow-none) (transfer none): cancellation object + * @error: (allow-none): Place-holder for error or %NULL * - * Returns: TRUE on success, FALSE otherwise. + * Returns: %TRUE on success, %FALSE otherwise. */ gboolean gvir_domain_fetch_snapshots(GVirDomain *dom, guint list_flags, @@ -1647,10 +1647,10 @@ static void _fetch_snapshots_async_thread(GTask *task,
/** - * + * gvir_domain_fetch_snapshots_async: * @dom: The domain * @list_flags: bitwise-OR of #GVirDomainSnapshotListFlags - * @cancellable: (allow-none)(transfer-none): cancellation object + * @cancellable: (allow-none) (transfer none): cancellation object
Is g-ir-scanner complaining about the lack of space? or just about 'transfer-none'? Just being curious, patch looks good to me, ACK. For future commits, c&p-ing the g-ir-scanner warnings that you are fixing in the commit log can be useful) Christophe

On 18.08, Christophe Fergeau wrote:
Hey,
On Fri, Aug 15, 2014 at 12:05:44PM +0200, Timm Bäder wrote:
/** - * + * gvir_domain_fetch_snapshots_async: * @dom: The domain * @list_flags: bitwise-OR of #GVirDomainSnapshotListFlags - * @cancellable: (allow-none)(transfer-none): cancellation object + * @cancellable: (allow-none) (transfer none): cancellation object
Is g-ir-scanner complaining about the lack of space? or just about 'transfer-none'? Just being curious, patch looks good to me, ACK. For future commits, c&p-ing the g-ir-scanner warnings that you are fixing in the commit log can be useful) I'll have to check but IIRC it was mostly about the missing function name on the first line and once I fixed that, it was the transfer-none, yes. The whitespace fixes are just cosmetic.

--- libvirt-gobject/libvirt-gobject-domain-snapshot.c | 56 +++++++++++++++++++++++ libvirt-gobject/libvirt-gobject-domain-snapshot.h | 10 ++++ libvirt-gobject/libvirt-gobject.sym | 2 + 3 files changed, 68 insertions(+) diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.c b/libvirt-gobject/libvirt-gobject-domain-snapshot.c index 62efce0..61ca53e 100644 --- a/libvirt-gobject/libvirt-gobject-domain-snapshot.c +++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.c @@ -302,6 +302,62 @@ 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), + &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 + * @callback: (scope async): The callback + * @user_data: (closure): Opaque data for callback + */ +void gvir_domain_snapshot_revert_to_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, _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 5ab3025..c6262e8 100644 --- a/libvirt-gobject/libvirt-gobject-domain-snapshot.h +++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.h @@ -107,6 +107,16 @@ gboolean gvir_domain_snapshot_revert_to(GVirDomainSnapshot *snapshot, guint flags, GError **error); +void gvir_domain_snapshot_revert_to_async(GVirDomainSnapshot *snapshot, + guint flags, + 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

On Fri, Aug 15, 2014 at 12:05:45PM +0200, Timm Bäder wrote:
--- libvirt-gobject/libvirt-gobject-domain-snapshot.c | 56 +++++++++++++++++++++++ libvirt-gobject/libvirt-gobject-domain-snapshot.h | 10 ++++ libvirt-gobject/libvirt-gobject.sym | 2 + 3 files changed, 68 insertions(+)
diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.c b/libvirt-gobject/libvirt-gobject-domain-snapshot.c index 62efce0..61ca53e 100644 --- a/libvirt-gobject/libvirt-gobject-domain-snapshot.c +++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.c @@ -302,6 +302,62 @@ 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), + &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 + * @callback: (scope async): The callback + * @user_data: (closure): Opaque data for callback + */ +void gvir_domain_snapshot_revert_to_async(GVirDomainSnapshot *snapshot, + guint flags, + GAsyncReadyCallback callback, + gpointer user_data) {
No GCancellable argument? Seems good otherwise. Christophe
+ 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, _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 5ab3025..c6262e8 100644 --- a/libvirt-gobject/libvirt-gobject-domain-snapshot.h +++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.h @@ -107,6 +107,16 @@ gboolean gvir_domain_snapshot_revert_to(GVirDomainSnapshot *snapshot, guint flags, GError **error);
+void gvir_domain_snapshot_revert_to_async(GVirDomainSnapshot *snapshot, + guint flags, + 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@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

--- libvirt-gobject/libvirt-gobject-domain.c | 67 ++++++++++++++++++++++++++++++++ libvirt-gobject/libvirt-gobject-domain.h | 11 ++++++ libvirt-gobject/libvirt-gobject.sym | 2 + 3 files changed, 80 insertions(+) diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c index aa2a170..29b82d0 100644 --- a/libvirt-gobject/libvirt-gobject-domain.c +++ b/libvirt-gobject/libvirt-gobject-domain.c @@ -61,6 +61,11 @@ enum { LAST_SIGNAL }; +typedef struct { + guint create_flags; + GVirConfigDomainSnapshot *snapshot_config; +} SnapshotCreateData; + static gint signals[LAST_SIGNAL]; #define GVIR_DOMAIN_ERROR gvir_domain_error_quark() @@ -1524,6 +1529,68 @@ gvir_domain_create_snapshot(GVirDomain *dom, } +static void _create_snapshot_async_thread(GTask *task, + gpointer source_object, + gpointer task_data, + GCancellable *cancellable) { + GError *error = NULL; + GVirDomainSnapshot *snapshot; + SnapshotCreateData *create_data = task_data; + + snapshot = gvir_domain_create_snapshot(source_object, + create_data->snapshot_config, + create_data->create_flags, + &error); + if (snapshot) + g_task_return_pointer(task, snapshot, g_object_unref); + else + g_task_return_error(task, error); +} + +/** + * gvir_domain_create_snapshot_async: + * @dom: The #GVirDomain + * @custom_conf: (allow-none): Configuration of snapshot or %NULL + * @flags: Bitwise-OR of #GVirDomainSnapshotCreateFlags + * @callback: (scope async): Complection callback + * @user_data: (closure): Opaque data for callback + */ +void gvir_domain_create_snapshot_async(GVirDomain *dom, + GVirConfigDomainSnapshot *custom_conf, + guint flags, + GAsyncReadyCallback callback, + gpointer user_data) { + SnapshotCreateData *create_data; + GTask *task; + + g_return_if_fail(GVIR_IS_DOMAIN(dom)); + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_SNAPSHOT(custom_conf)); + + create_data = g_slice_new(SnapshotCreateData); + create_data->create_flags = flags; + create_data->snapshot_config = custom_conf; + + task = g_task_new(dom, NULL, callback, user_data); + g_task_set_task_data(task, create_data, NULL); + g_task_run_in_thread(task, _create_snapshot_async_thread); + g_object_unref(task); +} + +/** + * gvir_domain_create_snapshot_finish: + * @domain: A #GVirDomain + * @result: (transfer none): Async method result + * @error: (allow-none): Error placeholder + * + * Returns: (transfer full): The created snapshot + */ +GVirDomainSnapshot * gvir_domain_create_snapshot_finish(GVirDomain *domain, + GAsyncResult *result, + GError **error) { + g_return_val_if_fail(g_task_is_valid(result, domain), NULL); + + return g_task_propagate_pointer(G_TASK(result), error); +} /** * gvir_domain_fetch_snapshots: diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h index 56c80b8..b5a0bd9 100644 --- a/libvirt-gobject/libvirt-gobject-domain.h +++ b/libvirt-gobject/libvirt-gobject-domain.h @@ -363,6 +363,17 @@ gvir_domain_create_snapshot(GVirDomain *dom, guint flags, GError **err); +void gvir_domain_create_snapshot_async(GVirDomain *dom, + GVirConfigDomainSnapshot *custom_conf, + guint flags, + GAsyncReadyCallback callback, + gpointer user_data); + +GVirDomainSnapshot * gvir_domain_create_snapshot_finish(GVirDomain *domain, + GAsyncResult *result, + GError **error); + + gboolean gvir_domain_fetch_snapshots(GVirDomain *dom, guint list_flags, GCancellable *cancellable, diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym index ebb9418..a610121 100644 --- a/libvirt-gobject/libvirt-gobject.sym +++ b/libvirt-gobject/libvirt-gobject.sym @@ -236,6 +236,8 @@ LIBVIRT_GOBJECT_0.1.5 { LIBVIRT_GOBJECT_0.1.9 { global: + gvir_domain_create_snapshot_async; + gvir_domain_create_snapshot_finish; gvir_domain_fetch_snapshots; gvir_domain_fetch_snapshots_async; gvir_domain_fetch_snapshots_finish; -- 2.0.4

On Fri, Aug 15, 2014 at 12:05:46PM +0200, Timm Bäder wrote:
--- libvirt-gobject/libvirt-gobject-domain.c | 67 ++++++++++++++++++++++++++++++++ libvirt-gobject/libvirt-gobject-domain.h | 11 ++++++ libvirt-gobject/libvirt-gobject.sym | 2 + 3 files changed, 80 insertions(+)
diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c index aa2a170..29b82d0 100644 --- a/libvirt-gobject/libvirt-gobject-domain.c +++ b/libvirt-gobject/libvirt-gobject-domain.c @@ -61,6 +61,11 @@ enum { LAST_SIGNAL };
+typedef struct { + guint create_flags; + GVirConfigDomainSnapshot *snapshot_config; +} SnapshotCreateData; + static gint signals[LAST_SIGNAL];
#define GVIR_DOMAIN_ERROR gvir_domain_error_quark() @@ -1524,6 +1529,68 @@ gvir_domain_create_snapshot(GVirDomain *dom, }
+static void _create_snapshot_async_thread(GTask *task, + gpointer source_object, + gpointer task_data, + GCancellable *cancellable) { + GError *error = NULL; + GVirDomainSnapshot *snapshot; + SnapshotCreateData *create_data = task_data; + + snapshot = gvir_domain_create_snapshot(source_object, + create_data->snapshot_config, + create_data->create_flags, + &error); + if (snapshot) + g_task_return_pointer(task, snapshot, g_object_unref); + else + g_task_return_error(task, error); +} + +/** + * gvir_domain_create_snapshot_async: + * @dom: The #GVirDomain + * @custom_conf: (allow-none): Configuration of snapshot or %NULL + * @flags: Bitwise-OR of #GVirDomainSnapshotCreateFlags + * @callback: (scope async): Complection callback + * @user_data: (closure): Opaque data for callback + */ +void gvir_domain_create_snapshot_async(GVirDomain *dom, + GVirConfigDomainSnapshot *custom_conf, + guint flags, + GAsyncReadyCallback callback, + gpointer user_data) {
No GCancellable either?
+ SnapshotCreateData *create_data; + GTask *task; + + g_return_if_fail(GVIR_IS_DOMAIN(dom)); + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_SNAPSHOT(custom_conf)); + + create_data = g_slice_new(SnapshotCreateData); + create_data->create_flags = flags; + create_data->snapshot_config = custom_conf;
I'd take a ref on snapshot_config as we don't really know what the caller will do with it once we return from this method.
+ + task = g_task_new(dom, NULL, callback, user_data); + g_task_set_task_data(task, create_data, NULL);
You need to have pass a GDestroyNotify argument as you allocated create_data in this function. Christophe

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

On Fri, Aug 15, 2014 at 12:05:47PM +0200, Timm Bäder wrote:
--- 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) {
Usual question about the lack of cancellable, ACK otherwise. Christophe
participants (2)
-
Christophe Fergeau
-
Timm Bäder