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

Himanshu Sharma himanshu.sharma at nectechnologies.in
Thu Aug 7 11:03:26 UTC 2014


You have any idea how I can clone VM of ESXi from libvirt?


-----Original Message-----
From: libvir-list-bounces at redhat.com [mailto:libvir-list-bounces at redhat.com] On Behalf Of Christophe Fergeau
Sent: 05 August 2014 18:26
To: mail at baedert.org
Cc: libvir-list at redhat.com
Subject: Re: [libvirt] [libvirt-glib] [PATCH 3/4] GVirDomainSnapshot: Add _set_config

On Sat, Aug 02, 2014 at 10:41:48AM +0200, mail at baedert.org wrote:
> From: Timm Bäder <mail at baedert.org>
> 
> ... 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



DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and
intended
for the named recipient(s) only. 
It shall not attach any liability on the originator or NEC or its
affiliates. Any views or opinions presented in 
this email are solely those of the author and may not necessarily reflect the
opinions of NEC or its affiliates. 
Any form of reproduction, dissemination, copying, disclosure, modification,
distribution and / or publication of 
this message without the prior written consent of the author of this e-mail is
strictly prohibited. If you have 
received this email in error please delete it and notify the sender
immediately. .
-----------------------------------------------------------------------------------------------------------------------




More information about the libvir-list mailing list