[libvirt] [glib PATCH V2] Add bindings for virDomainSave*()

Daniel P. Berrange berrange at redhat.com
Wed Jul 11 15:45:43 UTC 2012


On Wed, Jul 11, 2012 at 03:33:42PM +0200, Jovanka Gulicoska wrote:
> ---
>  libvirt-gobject/libvirt-gobject-domain.c |  149 +++++++++++++++++++++++++++++-
>  libvirt-gobject/libvirt-gobject-domain.h |   20 +++-
>  libvirt-gobject/libvirt-gobject.sym      |    3 +
>  3 files changed, 170 insertions(+), 2 deletions(-)
> 
> diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
> index 088cd33..eda2427 100644
> --- a/libvirt-gobject/libvirt-gobject-domain.c
> +++ b/libvirt-gobject/libvirt-gobject-domain.c
> @@ -557,6 +557,153 @@ gboolean gvir_domain_reboot(GVirDomain *dom,
>  }
>  
>  /**
> + * gvir_domain_save_to_file:
> + * @dom: the domain
> + * @filename: path to the output file
> + * @conf: configuration for domain

In most use cases, people won't care about passing a 'conf'
instance, so we need to accept NULL for this.

> + * @flags: the flags
> + *
> + * Returns: TRUE on success, FALSE otherwise 
> + */
> +gboolean gvir_domain_save_to_file(GVirDomain *dom,
> +                                  gchar *filename,
> +                                  GVirConfigDomain *conf,
> +                                  guint flags,
> +                                  GError **err)
> +{
> +    GVirDomainPrivate *priv;    
> +    gchar *custom_xml;
> +    int ret;
> +    
> +    g_return_val_if_fail(GVIR_IS_DOMAIN(dom), FALSE);
> +    g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN (conf), FALSE);

Need to allow for NULL conf here.

> +    g_return_val_if_fail(err == NULL || *err == NULL, FALSE);
> +
> +    priv = dom->priv;
> +    custom_xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(conf));

So this should be pushed inside the if()

> +   
> +    if (flags || (custom_xml != NULL)) {

changing this second clause to  '(conf != NULL)'

> +        ret = virDomainSaveFlags(priv->handle, filename, custom_xml, flags);
> +        g_free (custom_xml);
> +    }
> +    else {
> +        ret = virDomainSave(priv->handle, filename);
> +        g_free (custom_xml);
> +    }
> +    if (ret < 0) {
> +        gvir_set_error_literal(err, GVIR_DOMAIN_ERROR,
> +                                 0,
> +                                 "Unable to save domain to file");
> +        return FALSE;
> +    }
> +    
> +    return TRUE;
> +}
> +


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