Re: [libvirt-glib 5/5] Add GVirConfigDomainTimerPit class

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

 



On Fri, Apr 13, 2012 at 05:20:18PM +0200, Christophe Fergeau wrote:
> ---
>  libvirt-gconfig/Makefile.am                        |    2 +
>  libvirt-gconfig/libvirt-gconfig-domain-timer-pit.c |   72 ++++++++++++++++++++
>  libvirt-gconfig/libvirt-gconfig-domain-timer-pit.h |   67 ++++++++++++++++++
>  libvirt-gconfig/libvirt-gconfig.h                  |    1 +
>  libvirt-gconfig/libvirt-gconfig.sym                |    4 ++
>  libvirt-gconfig/tests/test-domain-create.c         |    8 +++
>  6 files changed, 154 insertions(+)
>  create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-timer-pit.c
>  create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-timer-pit.h
> 
> diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
> index 0177a72..5f15803 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-pit.h \
>  			libvirt-gconfig-domain-timer-rtc.h \
>  			libvirt-gconfig-domain-video.h \
>  			libvirt-gconfig-helpers.h \
> @@ -95,6 +96,7 @@ GCONFIG_SOURCE_FILES = \
>  			libvirt-gconfig-domain-snapshot.c \
>  			libvirt-gconfig-domain-sound.c \
>  			libvirt-gconfig-domain-timer.c \
> +			libvirt-gconfig-domain-timer-pit.c \
>  			libvirt-gconfig-domain-timer-rtc.c \
>  			libvirt-gconfig-domain-video.c \
>  			libvirt-gconfig-helpers.c \
> diff --git a/libvirt-gconfig/libvirt-gconfig-domain-timer-pit.c b/libvirt-gconfig/libvirt-gconfig-domain-timer-pit.c
> new file mode 100644
> index 0000000..d75cd30
> --- /dev/null
> +++ b/libvirt-gconfig/libvirt-gconfig-domain-timer-pit.c
> @@ -0,0 +1,72 @@
> +/*
> + * libvirt-gconfig-domain-timer-pit.c: libvirt domain PIT 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@xxxxxxxxxx>
> + */
> +
> +#include <config.h>
> +
> +#include "libvirt-gconfig/libvirt-gconfig.h"
> +#include "libvirt-gconfig/libvirt-gconfig-private.h"
> +
> +#define GVIR_CONFIG_DOMAIN_TIMER_PIT_GET_PRIVATE(obj)                         \
> +        (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_TIMER_PIT, GVirConfigDomainTimerPitPrivate))
> +
> +struct _GVirConfigDomainTimerPitPrivate
> +{
> +    gboolean unused;
> +};
> +
> +G_DEFINE_TYPE(GVirConfigDomainTimerPit, gvir_config_domain_timer_pit, GVIR_CONFIG_TYPE_DOMAIN_TIMER);
> +
> +
> +static void gvir_config_domain_timer_pit_class_init(GVirConfigDomainTimerPitClass *klass)
> +{
> +    g_type_class_add_private(klass, sizeof(GVirConfigDomainTimerPitPrivate));
> +}
> +
> +
> +static void gvir_config_domain_timer_pit_init(GVirConfigDomainTimerPit *timer)
> +{
> +    g_debug("Init GVirConfigDomainTimerPit=%p", timer);
> +
> +    timer->priv = GVIR_CONFIG_DOMAIN_TIMER_PIT_GET_PRIVATE(timer);
> +}
> +
> +
> +GVirConfigDomainTimerPit *gvir_config_domain_timer_pit_new(void)
> +{
> +    GVirConfigObject *object;
> +
> +    object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_TIMER_PIT,
> +                                    "timer", NULL);
> +    gvir_config_object_set_attribute(object, "name", "pit", NULL);
> +    return GVIR_CONFIG_DOMAIN_TIMER_PIT(object);
> +}
> +
> +GVirConfigDomainTimerPit *gvir_config_domain_timer_pit_new_from_xml(const gchar *xml,
> +                                                GError **error)
> +{
> +    GVirConfigObject *object;
> +
> +    object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_TIMER_PIT,
> +                                             "timer", NULL, xml, error);
> +    gvir_config_object_set_attribute(object, "name", "pit", NULL);
> +    return GVIR_CONFIG_DOMAIN_TIMER_PIT(object);
> +}
> diff --git a/libvirt-gconfig/libvirt-gconfig-domain-timer-pit.h b/libvirt-gconfig/libvirt-gconfig-domain-timer-pit.h
> new file mode 100644
> index 0000000..7709825
> --- /dev/null
> +++ b/libvirt-gconfig/libvirt-gconfig-domain-timer-pit.h
> @@ -0,0 +1,67 @@
> +/*
> + * libvirt-gconfig-domain-timer-pit.h: libvirt domain PIT 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@xxxxxxxxxx>
> + */
> +
> +#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_PIT_H__
> +#define __LIBVIRT_GCONFIG_DOMAIN_TIMER_PIT_H__
> +
> +G_BEGIN_DECLS
> +
> +#define GVIR_CONFIG_TYPE_DOMAIN_TIMER_PIT            (gvir_config_domain_timer_pit_get_type ())
> +#define GVIR_CONFIG_DOMAIN_TIMER_PIT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_TIMER_PIT, GVirConfigDomainTimerPit))
> +#define GVIR_CONFIG_DOMAIN_TIMER_PIT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_TIMER_PIT, GVirConfigDomainTimerPitClass))
> +#define GVIR_CONFIG_IS_DOMAIN_TIMER_PIT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_TIMER_PIT))
> +#define GVIR_CONFIG_IS_DOMAIN_TIMER_PIT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_TIMER_PIT))
> +#define GVIR_CONFIG_DOMAIN_TIMER_PIT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_TIMER_PIT, GVirConfigDomainTimerPitClass))
> +
> +typedef struct _GVirConfigDomainTimerPit GVirConfigDomainTimerPit;
> +typedef struct _GVirConfigDomainTimerPitPrivate GVirConfigDomainTimerPitPrivate;
> +typedef struct _GVirConfigDomainTimerPitClass GVirConfigDomainTimerPitClass;
> +
> +struct _GVirConfigDomainTimerPit
> +{
> +    GVirConfigObject parent;
> +
> +    GVirConfigDomainTimerPitPrivate *priv;
> +
> +    /* Do not add fields to this struct */
> +};
> +
> +struct _GVirConfigDomainTimerPitClass
> +{
> +    GVirConfigObjectClass parent_class;
> +
> +    gpointer padding[20];
> +};
> +
> +GType gvir_config_domain_timer_pit_get_type(void);
> +
> +GVirConfigDomainTimerPit *gvir_config_domain_timer_pit_new(void);
> +GVirConfigDomainTimerPit *gvir_config_domain_timer_pit_new_from_xml(const gchar *xml,
> +                                                                    GError **error);
> +
> +G_END_DECLS
> +
> +#endif /* __LIBVIRT_GCONFIG_DOMAIN_TIMER_PIT_H__ */
> diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h
> index b8ef48f..cd5c3ce 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-pit.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>
> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
> index 9bf9665..49a947e 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_pit_get_type;
> +	gvir_config_domain_timer_pit_new;
> +	gvir_config_domain_timer_pit_new_from_xml;
> +
>  	gvir_config_domain_timer_rtc_get_type;
>  	gvir_config_domain_timer_rtc_new;
>  	gvir_config_domain_timer_rtc_new_from_xml;
> diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c
> index 6031829..d40e5f3 100644
> --- a/libvirt-gconfig/tests/test-domain-create.c
> +++ b/libvirt-gconfig/tests/test-domain-create.c
> @@ -76,11 +76,19 @@ int main(int argc, char **argv)
>  
>      /* clock node */
>      GVirConfigDomainClock *klock;
> +    GVirConfigDomainTimerPit *pit;
>      GVirConfigDomainTimerRtc *rtc;
>  
>      klock = gvir_config_domain_clock_new();
>      gvir_config_domain_clock_set_offset(klock, GVIR_CONFIG_DOMAIN_CLOCK_UTC);
>  
> +    pit = gvir_config_domain_timer_pit_new();
> +    gvir_config_domain_timer_set_tick_policy(GVIR_CONFIG_DOMAIN_TIMER(pit),
> +                                             GVIR_CONFIG_DOMAIN_TIMER_TICK_POLICY_DELAY);
> +    gvir_config_domain_clock_add_timer(klock, GVIR_CONFIG_DOMAIN_TIMER(pit));
> +    g_assert(gvir_config_domain_timer_get_tick_policy(GVIR_CONFIG_DOMAIN_TIMER(pit)) == GVIR_CONFIG_DOMAIN_TIMER_TICK_POLICY_DELAY);
> +    g_object_unref(G_OBJECT(pit));
> +
>      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);

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

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