[libvirt] [libvirt-glib 4/5] Add GVirConfigDomainTimerRtc class

Daniel P. Berrange berrange at redhat.com
Fri Apr 27 12:05:22 UTC 2012


On Fri, Apr 13, 2012 at 05:20:17PM +0200, Christophe Fergeau wrote:
> ---
>  libvirt-gconfig/Makefile.am                        |    2 +
>  libvirt-gconfig/libvirt-gconfig-domain-timer-rtc.c |   72 ++++++++++++++++++++
>  libvirt-gconfig/libvirt-gconfig-domain-timer-rtc.h |   67 ++++++++++++++++++
>  libvirt-gconfig/libvirt-gconfig.h                  |    1 +
>  libvirt-gconfig/libvirt-gconfig.sym                |    4 ++
>  libvirt-gconfig/tests/test-domain-create.c         |    9 +++
>  6 files changed, 155 insertions(+)
>  create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-timer-rtc.c
>  create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-timer-rtc.h
> 
> diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
> index 181ec57..0177a72 100644
> --- a/libvirt-gconfig/Makefile.am
> +++ b/libvirt-gconfig/Makefile.am
> @@ -41,6 +41,7 @@ GCONFIG_HEADER_FILES = \
>  			libvirt-gconfig-domain-snapshot.h \
>  			libvirt-gconfig-domain-sound.h \
>  			libvirt-gconfig-domain-timer.h \
> +			libvirt-gconfig-domain-timer-rtc.h \
>  			libvirt-gconfig-domain-video.h \
>  			libvirt-gconfig-helpers.h \
>  			libvirt-gconfig-interface.h \
> @@ -94,6 +95,7 @@ GCONFIG_SOURCE_FILES = \
>  			libvirt-gconfig-domain-snapshot.c \
>  			libvirt-gconfig-domain-sound.c \
>  			libvirt-gconfig-domain-timer.c \
> +			libvirt-gconfig-domain-timer-rtc.c \
>  			libvirt-gconfig-domain-video.c \
>  			libvirt-gconfig-helpers.c \
>  			libvirt-gconfig-interface.c \
> diff --git a/libvirt-gconfig/libvirt-gconfig-domain-timer-rtc.c b/libvirt-gconfig/libvirt-gconfig-domain-timer-rtc.c
> new file mode 100644
> index 0000000..b99c1e3
> --- /dev/null
> +++ b/libvirt-gconfig/libvirt-gconfig-domain-timer-rtc.c
> @@ -0,0 +1,72 @@
> +/*
> + * libvirt-gconfig-domain-timer-rtc.c: libvirt domain RTC timer configuration
> + *
> + * Copyright (C) 2012 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
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
> + *
> + * Author: Christophe Fergeau <cfergeau at redhat.com>
> + */
> +
> +#include <config.h>
> +
> +#include "libvirt-gconfig/libvirt-gconfig.h"
> +#include "libvirt-gconfig/libvirt-gconfig-private.h"
> +
> +#define GVIR_CONFIG_DOMAIN_TIMER_RTC_GET_PRIVATE(obj)                         \
> +        (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_TIMER_RTC, GVirConfigDomainTimerRtcPrivate))
> +
> +struct _GVirConfigDomainTimerRtcPrivate
> +{
> +    gboolean unused;
> +};
> +
> +G_DEFINE_TYPE(GVirConfigDomainTimerRtc, gvir_config_domain_timer_rtc, GVIR_CONFIG_TYPE_DOMAIN_TIMER);
> +
> +
> +static void gvir_config_domain_timer_rtc_class_init(GVirConfigDomainTimerRtcClass *klass)
> +{
> +    g_type_class_add_private(klass, sizeof(GVirConfigDomainTimerRtcPrivate));
> +}
> +
> +
> +static void gvir_config_domain_timer_rtc_init(GVirConfigDomainTimerRtc *timer)
> +{
> +    g_debug("Init GVirConfigDomainTimerRtc=%p", timer);
> +
> +    timer->priv = GVIR_CONFIG_DOMAIN_TIMER_RTC_GET_PRIVATE(timer);
> +}
> +
> +
> +GVirConfigDomainTimerRtc *gvir_config_domain_timer_rtc_new(void)
> +{
> +    GVirConfigObject *object;
> +
> +    object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_TIMER_RTC,
> +                                    "timer", NULL);
> +    gvir_config_object_set_attribute(object, "name", "rtc", NULL);
> +    return GVIR_CONFIG_DOMAIN_TIMER_RTC(object);
> +}
> +
> +GVirConfigDomainTimerRtc *gvir_config_domain_timer_rtc_new_from_xml(const gchar *xml,
> +                                                                    GError **error)
> +{
> +    GVirConfigObject *object;
> +
> +    object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_TIMER_RTC,
> +                                             "timer", NULL, xml, error);
> +    gvir_config_object_set_attribute(object, "name", "rtc", NULL);
> +    return GVIR_CONFIG_DOMAIN_TIMER_RTC(object);
> +}
> diff --git a/libvirt-gconfig/libvirt-gconfig-domain-timer-rtc.h b/libvirt-gconfig/libvirt-gconfig-domain-timer-rtc.h
> new file mode 100644
> index 0000000..6d76371
> --- /dev/null
> +++ b/libvirt-gconfig/libvirt-gconfig-domain-timer-rtc.h
> @@ -0,0 +1,67 @@
> +/*
> + * libvirt-gconfig-domain-timer-rtc.h: libvirt domain RTC timer configuration
> + *
> + * Copyright (C) 2012 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
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
> + *
> + * Author: Christophe Fergeau <cfergeau at redhat.com>
> + */
> +
> +#if !defined(__LIBVIRT_GCONFIG_H__) && !defined(LIBVIRT_GCONFIG_BUILD)
> +#error "Only <libvirt-gconfig/libvirt-gconfig.h> can be included directly."
> +#endif
> +
> +#ifndef __LIBVIRT_GCONFIG_DOMAIN_TIMER_RTC_H__
> +#define __LIBVIRT_GCONFIG_DOMAIN_TIMER_RTC_H__
> +
> +G_BEGIN_DECLS
> +
> +#define GVIR_CONFIG_TYPE_DOMAIN_TIMER_RTC            (gvir_config_domain_timer_rtc_get_type ())
> +#define GVIR_CONFIG_DOMAIN_TIMER_RTC(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_TIMER_RTC, GVirConfigDomainTimerRtc))
> +#define GVIR_CONFIG_DOMAIN_TIMER_RTC_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_TIMER_RTC, GVirConfigDomainTimerRtcClass))
> +#define GVIR_CONFIG_IS_DOMAIN_TIMER_RTC(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_TIMER_RTC))
> +#define GVIR_CONFIG_IS_DOMAIN_TIMER_RTC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_TIMER_RTC))
> +#define GVIR_CONFIG_DOMAIN_TIMER_RTC_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_TIMER_RTC, GVirConfigDomainTimerRtcClass))
> +
> +typedef struct _GVirConfigDomainTimerRtc GVirConfigDomainTimerRtc;
> +typedef struct _GVirConfigDomainTimerRtcPrivate GVirConfigDomainTimerRtcPrivate;
> +typedef struct _GVirConfigDomainTimerRtcClass GVirConfigDomainTimerRtcClass;
> +
> +struct _GVirConfigDomainTimerRtc
> +{
> +    GVirConfigDomainTimer parent;
> +
> +    GVirConfigDomainTimerRtcPrivate *priv;
> +
> +    /* Do not add fields to this struct */
> +};
> +
> +struct _GVirConfigDomainTimerRtcClass
> +{
> +    GVirConfigDomainTimerClass parent_class;
> +
> +    gpointer padding[20];
> +};
> +
> +GType gvir_config_domain_timer_rtc_get_type(void);
> +
> +GVirConfigDomainTimerRtc *gvir_config_domain_timer_rtc_new(void);
> +GVirConfigDomainTimerRtc *gvir_config_domain_timer_rtc_new_from_xml(const gchar *xml,
> +                                                GError **error);
> +
> +G_END_DECLS
> +
> +#endif /* __LIBVIRT_GCONFIG_DOMAIN_TIMER_RTC_H__ */
> diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h
> index 2fcc4ba..b8ef48f 100644
> --- a/libvirt-gconfig/libvirt-gconfig.h
> +++ b/libvirt-gconfig/libvirt-gconfig.h
> @@ -58,6 +58,7 @@
>  #include <libvirt-gconfig/libvirt-gconfig-domain-snapshot.h>
>  #include <libvirt-gconfig/libvirt-gconfig-domain-sound.h>
>  #include <libvirt-gconfig/libvirt-gconfig-domain-timer.h>
> +#include <libvirt-gconfig/libvirt-gconfig-domain-timer-rtc.h>
>  #include <libvirt-gconfig/libvirt-gconfig-domain-video.h>
>  #include <libvirt-gconfig/libvirt-gconfig-enum-types.h>
>  #include <libvirt-gconfig/libvirt-gconfig-helpers.h>
> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
> index 8eefb95..9bf9665 100644
> --- a/libvirt-gconfig/libvirt-gconfig.sym
> +++ b/libvirt-gconfig/libvirt-gconfig.sym
> @@ -232,6 +232,10 @@ LIBVIRT_GCONFIG_0.0.7 {
>  	gvir_config_domain_timer_get_tick_policy;
>  	gvir_config_domain_timer_set_tick_policy;
>  
> +	gvir_config_domain_timer_rtc_get_type;
> +	gvir_config_domain_timer_rtc_new;
> +	gvir_config_domain_timer_rtc_new_from_xml;
> +
>  	gvir_config_domain_video_get_type;
>  	gvir_config_domain_video_model_get_type;
>  	gvir_config_domain_video_new;
> diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c
> index 4ee33aa..6031829 100644
> --- a/libvirt-gconfig/tests/test-domain-create.c
> +++ b/libvirt-gconfig/tests/test-domain-create.c
> @@ -76,9 +76,18 @@ int main(int argc, char **argv)
>  
>      /* clock node */
>      GVirConfigDomainClock *klock;
> +    GVirConfigDomainTimerRtc *rtc;
>  
>      klock = gvir_config_domain_clock_new();
>      gvir_config_domain_clock_set_offset(klock, GVIR_CONFIG_DOMAIN_CLOCK_UTC);
> +
> +    rtc = gvir_config_domain_timer_rtc_new();
> +    gvir_config_domain_timer_set_tick_policy(GVIR_CONFIG_DOMAIN_TIMER(rtc),
> +                                             GVIR_CONFIG_DOMAIN_TIMER_TICK_POLICY_CATCHUP);
> +    gvir_config_domain_clock_add_timer(klock, GVIR_CONFIG_DOMAIN_TIMER(rtc));
> +    g_assert(gvir_config_domain_timer_get_tick_policy(GVIR_CONFIG_DOMAIN_TIMER(rtc)) == GVIR_CONFIG_DOMAIN_TIMER_TICK_POLICY_CATCHUP);
> +    g_object_unref(G_OBJECT(rtc));
> +
>      gvir_config_domain_set_clock(domain, klock);
>      g_object_unref(G_OBJECT(klock));
>  

ACK


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