[libvirt] [glib PATCH] Add bindings for virDomainSnapshotCreateXML()

Daniel P. Berrange berrange at redhat.com
Wed Jul 11 15:54:08 UTC 2012


On Wed, Jul 11, 2012 at 05:40:43PM +0200, Jovanka Gulicoska wrote:
> ---
>  libvirt-gobject/libvirt-gobject-domain.c |   39 ++++++++++++++++++++++++++++++
>  libvirt-gobject/libvirt-gobject-domain.h |    4 +++
>  2 files changed, 43 insertions(+)
> 
> diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
> index eda2427..ea621ff 100644
> --- a/libvirt-gobject/libvirt-gobject-domain.c
> +++ b/libvirt-gobject/libvirt-gobject-domain.c
> @@ -1270,3 +1270,42 @@ GList *gvir_domain_get_devices(GVirDomain *domain,
>  
>      return g_list_reverse (ret);
>  }
> +
> +/**
> + * gvir_domain_snapshot_create_xml:
> + * @dom: the domain
> + * @conf: configuration of domain
> + * @flags: the flags
> + * @err: (allow-none):Place-holder for error or NULL
> + *
> + * Returns: snapshot of existing domain
> + */
> +GVirConfigDomainSnapshot *gvir_domain_snapshot_create_xml(GVirDomain *dom,
> +                                                          GVirConfigDomain *conf,

This parameter actually needs to be GVirConfigDomainSnapshot, since the
method below needs the domain-snapshot XML format, not the domain XML
format

> +                                                          guint flags,
> +                                                          GError **err)
> +{
> +    GVirDomainPrivate *priv;
> +    virDomainSnapshot *snapshot;
> +    gchar *xml_desc;
> +
> +    g_return_val_if_fail(GVIR_IS_DOMAIN(dom), FALSE);
> +    g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN (conf), FALSE);
> +    g_return_val_if_fail(err == NULL || *err == NULL, NULL);
> +
> +    priv = dom->priv;
> +    xml_desc = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(conf));
> +
> +    if(!(snapshot = virDomainSnapshotCreateXML(priv->handle, xml_desc, flags))) {
> +       gvir_set_error_literal(err, GVIR_DOMAIN_ERROR,
> +                              0,
> +                             "Unable to create snapshot of domain");
> +        return NULL;
> +
> +    }
> +    
> +    GVirConfigDomainSnapshot *conf_snapshot = gvir_config_domain_snapshot_new_from_xml(xml_desc, err);
> +
> +    g_free(xml_desc);
> +    return conf_snapshot;
> +}

There seems to be some trailing whitespace on some of these lines - you
can use 'make syntax-check' to validate code style

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list