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

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



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

Attachment: pgpHOavCfdkWC.pgp
Description: PGP signature


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