Re: [glib PATCH V6] Add bindings for virDomainSnapshotCreateXML()

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

 



On Fri, Jul 13, 2012 at 9:45 AM, Jovanka Gulicoska
<jovanka.gulicoska@xxxxxxxxx> wrote:
> ---
>  libvirt-gobject/libvirt-gobject-domain.c |   42 ++++++++++++++++++++++++++++++
>  libvirt-gobject/libvirt-gobject-domain.h |    6 +++++
>  libvirt-gobject/libvirt-gobject.sym      |    1 +
>  3 files changed, 49 insertions(+)
>
> diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
> index 088cd33..ce81971 100644
> --- a/libvirt-gobject/libvirt-gobject-domain.c
> +++ b/libvirt-gobject/libvirt-gobject-domain.c
> @@ -1123,3 +1123,45 @@ GList *gvir_domain_get_devices(GVirDomain *domain,
>
>      return g_list_reverse (ret);
>  }
> +
> +/**
> + * gvir_domain_snapshot_create_xml:
> + * @dom: the domain
> + * @custom_conf: (allow-none): configuration of snapshot or NULL
> + * @flags: the flags
> + * @err: (allow-none):Place-holder for error or NULL
> + *
> + * Returns: (transfer full): snapshot of domain. The returned object should be
> + * unreffed when no longer needed
> + */
> +GVirConfigDomainSnapshot *gvir_domain_snapshot_create_xml
> +                                      (GVirDomain *dom,
> +                                       GVirConfigDomainSnapshot *custom_conf,
> +                                       guint flags,
> +                                       GError **err)
> +{
> +    GVirDomainPrivate *priv;
> +    virDomainSnapshot *snapshot;
> +    GVirConfigDomainSnapshot *conf_snapshot;
> +    gchar *custom_xml = NULL;
> +
> +    g_return_val_if_fail(GVIR_IS_DOMAIN(dom), FALSE);
> +    g_return_val_if_fail(err == NULL || *err == NULL, NULL);
> +
> +    priv = dom->priv;
> +
> +    if (custom_conf != NULL)
> +        custom_xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(custom_conf));
> +
> +    if (!(snapshot = virDomainSnapshotCreateXML(priv->handle, custom_xml, flags))) {
> +        gvir_set_error_literal(err, GVIR_DOMAIN_ERROR,
> +                               0,
> +                              "Unable to create snapshot of domain");
> +        return NULL;
> +    }
> +
> +    conf_snapshot = gvir_config_domain_snapshot_new_from_xml(custom_xml, err);

You seem to be completely ignoring the snapshot returned by
virDomainSnapshotCreateXML. The returned virDomainSnapshotPtr maps to
GVirDomainSnapshot, not GVirConfigDomainSnapshot. You need to:

1. Get the config xml used by virDomainSnapshotPtr using
virDomainSnapshotGetXMLDesc.
2. Create GVirConfigDomainSnapshot out of that xml string.
3. Create the GVirDomainSnapshot with this GVirConfigDomainSnapshot
using g_object_new().
4 Return this GVirDomainSnapshot.

> +
> +    g_free(custom_xml);
> +    return conf_snapshot;
> +}
> diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h
> index 87b94f4..8c4d28e 100644
> --- a/libvirt-gobject/libvirt-gobject-domain.h
> +++ b/libvirt-gobject/libvirt-gobject-domain.h
> @@ -202,6 +202,12 @@ gboolean gvir_domain_get_saved(GVirDomain *dom);
>  GList *gvir_domain_get_devices(GVirDomain *domain,
>                                 GError **err);
>
> +GVirConfigDomainSnapshot *gvir_domain_snapshot_create_xml
> +                                      (GVirDomain *dom,
> +                                       GVirConfigDomainSnapshot *custom_conf,
> +                                       guint flags,
> +                                       GError **err);
> +
>  G_END_DECLS
>
>  #endif /* __LIBVIRT_GOBJECT_DOMAIN_H__ */
> diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
> index 94e441a..045e1b5 100644
> --- a/libvirt-gobject/libvirt-gobject.sym
> +++ b/libvirt-gobject/libvirt-gobject.sym
> @@ -75,6 +75,7 @@ LIBVIRT_GOBJECT_0.0.8 {
>         gvir_domain_get_persistent;
>         gvir_domain_get_saved;
>         gvir_domain_screenshot;
> +       gvir_domain_snapshot_create_xml;
>
>         gvir_domain_snapshot_get_type;
>         gvir_domain_snapshot_handle_get_type;
> --
> 1.7.10.4
>
> --
> libvir-list mailing list
> libvir-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/libvir-list



-- 
Regards,

Zeeshan Ali (Khattak)
FSF member#5124

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