Re: [libvirt-glib 3/3] gconfig: Add GVirConfigDomainSnapshot getters/setters

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

 



On Wed, May 1, 2013 at 10:59 PM, Christophe Fergeau <cfergeau@xxxxxxxxxx> wrote:
> ---
>  libvirt-gconfig/libvirt-gconfig-domain-snapshot.c | 227 +++++++++++++++++++++-
>  libvirt-gconfig/libvirt-gconfig-domain-snapshot.h |  38 +++-
>  libvirt-gconfig/libvirt-gconfig.sym               |  15 ++
>  3 files changed, 278 insertions(+), 2 deletions(-)
>
> diff --git a/libvirt-gconfig/libvirt-gconfig-domain-snapshot.c b/libvirt-gconfig/libvirt-gconfig-domain-snapshot.c
> index 3d967f1..a3cec0c 100644
> --- a/libvirt-gconfig/libvirt-gconfig-domain-snapshot.c
> +++ b/libvirt-gconfig/libvirt-gconfig-domain-snapshot.c
> @@ -2,7 +2,7 @@
>   * libvirt-gconfig-domain-snapshot.c: libvirt domain snapshot configuration
>   *
>   * Copyright (C) 2008 Daniel P. Berrange
> - * Copyright (C) 2010-2011 Red Hat, Inc.
> + * Copyright (C) 2010-2013 Red Hat, Inc.
>   *
>   * This library is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU Lesser General Public
> @@ -19,11 +19,13 @@
>   * <http://www.gnu.org/licenses/>.
>   *
>   * Author: Daniel P. Berrange <berrange@xxxxxxxxxx>
> + *         Christophe Fergeau <cfergeau@xxxxxxxxxx>
>   */
>
>  #include <config.h>
>
>  #include "libvirt-gconfig/libvirt-gconfig.h"
> +#include "libvirt-gconfig/libvirt-gconfig-private.h"
>
>  #define GVIR_CONFIG_DOMAIN_SNAPSHOT_GET_PRIVATE(obj)                         \
>          (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_SNAPSHOT, GVirConfigDomainSnapshotPrivate))
> @@ -71,3 +73,226 @@ GVirConfigDomainSnapshot *gvir_config_domain_snapshot_new_from_xml(const gchar *
>                                      xml, error);
>      return GVIR_CONFIG_DOMAIN_SNAPSHOT(object);
>  }
> +
> +
> +const char *gvir_config_domain_snapshot_get_name(GVirConfigDomainSnapshot *snapshot)
> +{
> +    g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_SNAPSHOT(snapshot), NULL);
> +
> +    return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(snapshot),
> +                                               "name");
> +}
> +
> +
> +void gvir_config_domain_snapshot_set_name(GVirConfigDomainSnapshot *snapshot,
> +                                          const char *name)
> +{
> +    g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_SNAPSHOT(snapshot));
> +
> +    gvir_config_object_set_node_content(GVIR_CONFIG_OBJECT(snapshot),
> +                                        "name", name);
> +}
> +
> +
> +const char *gvir_config_domain_snapshot_get_description(GVirConfigDomainSnapshot *snapshot)
> +{
> +    g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_SNAPSHOT(snapshot), NULL);
> +
> +    return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(snapshot),
> +                                               "description");
> +}
> +
> +
> +void gvir_config_domain_snapshot_set_description(GVirConfigDomainSnapshot *snapshot,
> +                                                 const char *description)
> +{
> +    g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_SNAPSHOT(snapshot));
> +
> +    gvir_config_object_set_node_content(GVIR_CONFIG_OBJECT(snapshot),
> +                                        "description", description);
> +}
> +
> +/*
> +const char *gvir_config_domain_snapshot_get_memory(GVirConfigDomainSnapshot *snapshot)


Why commented-out? AFAICT from the docs, this deserves a separate object.

> +{
> +    g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_SNAPSHOT(snapshot), NULL);
> +
> +    return NULL;
> +}
> +
> +
> +void gvir_config_domain_snapshot_set_memory(GVirConfigDomainSnapshot *snapshot,
> +                                   const char *memory)
> +{
> +    g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_SNAPSHOT(snapshot));
> +}
> +*/
> +
> +
> +/* FIXME: GDateTime is only available since glib 2.26, libvirt-glib depends
> + * on glib 2.22, is the dep ok?
> + */

time_t seems pretty appropriate here.

> +GDateTime *gvir_config_domain_snapshot_get_creation_time(GVirConfigDomainSnapshot *snapshot)
> +{
> +    g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_SNAPSHOT(snapshot), NULL);
> +    guint64 creation_time;
> +
> +    creation_time = gvir_config_object_get_node_content_uint64(GVIR_CONFIG_OBJECT(snapshot),
> +                                                               "creationTime");
> +    return g_date_time_new_from_unix_utc(creation_time);
> +}
> +
> +
> +GVirConfigDomainSnapshotState gvir_config_domain_snapshot_get_state(GVirConfigDomainSnapshot *snapshot)
> +{
> +    g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_SNAPSHOT(snapshot),
> +                         GVIR_CONFIG_DOMAIN_SNAPSHOT_STATE_NOSTATE);
> +
> +    return gvir_config_object_get_node_content_genum(GVIR_CONFIG_OBJECT(snapshot),
> +                                                     "state",
> +                                                     GVIR_CONFIG_TYPE_DOMAIN_SNAPSHOT_STATE,
> +                                                     GVIR_CONFIG_DOMAIN_SNAPSHOT_STATE_NOSTATE);
> +}
> +
> +
> +const char *gvir_config_domain_snapshot_get_parent(GVirConfigDomainSnapshot *snapshot)
> +{

Shouldn't this be returning a GVirConfigDomainSnapshot instance?


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