Re: [libvirt-glib] [PATCH 3/4] GVirDomainSnapshot: Add _set_config

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

 



On Sat, Aug 02, 2014 at 10:41:48AM +0200, mail@xxxxxxxxxxx wrote:
> From: Timm Bäder <mail@xxxxxxxxxxx>
> 
> ... which is basically analogous to gvir_domain_set_config
> ---
>  libvirt-gobject/libvirt-gobject-domain-snapshot.c | 58 +++++++++++++++++++++++
>  libvirt-gobject/libvirt-gobject-domain-snapshot.h |  5 ++
>  libvirt-gobject/libvirt-gobject.sym               |  1 +
>  3 files changed, 64 insertions(+)
> 
> diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.c b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
> index 497288f..2c81882 100644
> --- a/libvirt-gobject/libvirt-gobject-domain-snapshot.c
> +++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
> @@ -297,3 +297,61 @@ gboolean gvir_domain_snapshot_revert_to(GVirDomainSnapshot *snapshot,
>  
>      return TRUE;
>  }
> +
> +
> +
> +/**
> + * gvir_domain_snapshot_set_config:
> + * @snapshot: The domain snapshot
> + * @conf: The new config object
> + * @error: (allow-none): Place-holder for error or NULL
> + *
> + * Updates the given snapshot's configuration according to the
> + * given GVirConfigDomainSnapshot.
> + *
> + * Returns: TRUE if no error was reported, FALSE otherwise.
> + */
> +gboolean gvir_domain_snapshot_set_config(GVirDomainSnapshot *snapshot,
> +                                         GVirConfigDomainSnapshot *conf,
> +                                         GError **error)
> +{
> +    gchar *xml;
> +    virConnectPtr conn;
> +    virDomainSnapshotPtr handle;
> +    virDomainPtr domain;
> +    GVirDomainSnapshotPrivate *priv;
> +
> +    g_return_val_if_fail(GVIR_IS_DOMAIN_SNAPSHOT(snapshot), FALSE);
> +    g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_SNAPSHOT(conf), FALSE);
> +    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
> +
> +    priv = snapshot->priv;
> +    handle = priv->handle;
> +    domain = virDomainSnapshotGetDomain(handle);
> +
> +
> +    if ((conn = virDomainSnapshotGetConnect(priv->handle)) == NULL) {
> +        gvir_set_error_literal(error, GVIR_DOMAIN_SNAPSHOT_ERROR,
> +                               0,
> +                               "Failed to get domain connection");
> +        return FALSE;
> +    }
> +
> +
> +    xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(conf));
> +
> +    handle = virDomainSnapshotCreateXML(domain,
> +                                        xml,
> +                                        VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE);
> +    free(xml);

g_free here.

> +
> +    if (handle == NULL) {
> +        gvir_set_error(error, GVIR_DOMAIN_SNAPSHOT_ERROR,
> +                       0,
> +                       "Failed to create Snapshot `%s' from XML definition",

"snapshot" could have a lower case here.

I'm not exactly clear on what this method will be doing according to
your 0/4. If it creates a new snapshot rather than modifying an
existing one, maybe the name should be different/this should not be
wrapped?

Christophe

Attachment: pgple420gD6v5.pgp
Description: PGP signature

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