[libvirt] [libvirt-glib 0/4] Add API to build <timer name="hpet" present="no"/>

This series allows to generate <timer name="hpet" present="no"/> using libvirt-gconfig. This is a prerequisite for fixing this Boxes bug https://bugzilla.gnome.org/show_bug.cgi?id=722293 Patch 2/4 doesn't anything to do in this series, but this was easy to implement after 1/4 so I slipped it there. Christophe

gvir_config_object_set_attribute() converts (TRUE, FALSE) to ("yes", "no"), but we don't have the corresponding getter. This commit adds this. --- libvirt-gconfig/libvirt-gconfig-object-private.h | 4 ++++ libvirt-gconfig/libvirt-gconfig-object.c | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-object-private.h b/libvirt-gconfig/libvirt-gconfig-object-private.h index 2ec358b..e91c4ef 100644 --- a/libvirt-gconfig/libvirt-gconfig-object-private.h +++ b/libvirt-gconfig/libvirt-gconfig-object-private.h @@ -53,6 +53,10 @@ gint gvir_config_object_get_attribute_genum(GVirConfigObject *object, const char *attr_name, GType enum_type, gint default_value); +gboolean gvir_config_object_get_attribute_boolean(GVirConfigObject *object, + const char *node_name, + const char *attr_name, + gboolean default_value); void gvir_config_object_set_node_content(GVirConfigObject *object, const char *node_name, const char *value); diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c index a8025e6..5557165 100644 --- a/libvirt-gconfig/libvirt-gconfig-object.c +++ b/libvirt-gconfig/libvirt-gconfig-object.c @@ -684,6 +684,26 @@ gvir_config_object_get_attribute_uint64(GVirConfigObject *object, return g_ascii_strtoull(str, NULL, 0); } + +G_GNUC_INTERNAL gboolean +gvir_config_object_get_attribute_boolean(GVirConfigObject *object, + const char *node_name, + const char *attr_name, + gboolean default_value) +{ + const char *str; + + str = gvir_config_object_get_attribute(object, node_name, attr_name); + if (g_strcmp0(str, "yes") == 0) { + return TRUE; + } else if (g_strcmp0(str, "no") == 0) { + return FALSE; + } else { + return default_value; + } +} + + GVirConfigObject *gvir_config_object_new_from_xml(GType type, const char *root_name, const char *schema, -- 1.8.4.2

On Fri, Jan 17, 2014 at 2:11 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
gvir_config_object_set_attribute() converts (TRUE, FALSE) to ("yes", "no"), but we don't have the corresponding getter. This commit adds this. ---
ACK -- Regards, Zeeshan Ali (Khattak) FSF member#5124

Now that there is a gvir_config_object_get_attribute_boolean(), these are trivial to implement. --- .../libvirt-gconfig-domain-graphics-desktop.c | 24 +++++++++++++++++++++- .../libvirt-gconfig-domain-graphics-desktop.h | 4 +++- .../libvirt-gconfig-domain-graphics-rdp.c | 24 +++++++++++++++++++++- .../libvirt-gconfig-domain-graphics-rdp.h | 4 +++- libvirt-gconfig/libvirt-gconfig.sym | 5 +++++ 5 files changed, 57 insertions(+), 4 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.c index 41b1112..a7743f6 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.c @@ -1,7 +1,7 @@ /* * libvirt-gconfig-domain-graphics-desktop.c: libvirt domain desktop configuration * - * Copyright (C) 2011 Red Hat, Inc. + * Copyright (C) 2011, 2014 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 @@ -85,6 +85,17 @@ void gvir_config_domain_graphics_desktop_set_display(GVirConfigDomainGraphicsDes NULL); } + +const gchar *gvir_config_domain_graphics_desktop_get_display(GVirConfigDomainGraphicsDesktop *graphics) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_DESKTOP(graphics), NULL); + + return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(graphics), + NULL, + "display"); +} + + void gvir_config_domain_graphics_desktop_set_fullscreen(GVirConfigDomainGraphicsDesktop *graphics, gboolean fullscreen) { @@ -96,3 +107,14 @@ void gvir_config_domain_graphics_desktop_set_fullscreen(GVirConfigDomainGraphics fullscreen, NULL); } + + +gboolean gvir_config_domain_graphics_desktop_get_fullscreen(GVirConfigDomainGraphicsDesktop *graphics) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_DESKTOP(graphics), FALSE); + + return gvir_config_object_get_attribute_boolean(GVIR_CONFIG_OBJECT(graphics), + NULL, + "fullscreen", + FALSE); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.h index d16e3d8..7e7e635 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.h @@ -1,7 +1,7 @@ /* * libvirt-gconfig-domain-graphics-desktop.h: libvirt domain desktop configuration * - * Copyright (C) 2011 Red Hat, Inc. + * Copyright (C) 2011, 2014 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 @@ -61,8 +61,10 @@ GType gvir_config_domain_graphics_desktop_get_type(void); GVirConfigDomainGraphicsDesktop *gvir_config_domain_graphics_desktop_new(void); GVirConfigDomainGraphicsDesktop *gvir_config_domain_graphics_desktop_new_from_xml(const gchar *xml, GError **error); +const gchar *gvir_config_domain_graphics_desktop_get_display(GVirConfigDomainGraphicsDesktop *graphics); void gvir_config_domain_graphics_desktop_set_display(GVirConfigDomainGraphicsDesktop *graphics, const gchar *disp); +gboolean gvir_config_domain_graphics_desktop_get_fullscreen(GVirConfigDomainGraphicsDesktop *graphics); void gvir_config_domain_graphics_desktop_set_fullscreen(GVirConfigDomainGraphicsDesktop *graphics, gboolean fullscreen); diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.c index 8a4084e..3d8357d 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.c @@ -1,7 +1,7 @@ /* * libvirt-gconfig-domain-graphics-rdp.c: libvirt domain RDP configuration * - * Copyright (C) 2011 Red Hat, Inc. + * Copyright (C) 2011, 2014 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 @@ -117,6 +117,17 @@ void gvir_config_domain_graphics_rdp_set_replace_user(GVirConfigDomainGraphicsRd } +gboolean gvir_config_domain_graphics_rdp_get_replace_user(GVirConfigDomainGraphicsRdp *graphics) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_RDP(graphics), FALSE); + + return gvir_config_object_get_attribute_boolean(GVIR_CONFIG_OBJECT(graphics), + NULL, + "replaceUser", + FALSE); +} + + void gvir_config_domain_graphics_rdp_set_multi_user(GVirConfigDomainGraphicsRdp *graphics, gboolean multi_user) { @@ -128,3 +139,14 @@ void gvir_config_domain_graphics_rdp_set_multi_user(GVirConfigDomainGraphicsRdp multi_user, NULL); } + + +gboolean gvir_config_domain_graphics_rdp_get_multi_user(GVirConfigDomainGraphicsRdp *graphics) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_RDP(graphics), FALSE); + + return gvir_config_object_get_attribute_boolean(GVIR_CONFIG_OBJECT(graphics), + NULL, + "multiUser", + FALSE); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.h index fb47834..a048ff8 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.h @@ -1,7 +1,7 @@ /* * libvirt-gconfig-domain-graphics-rdp.h: libvirt domain RDP graphics configuration * - * Copyright (C) 2011 Red Hat, Inc. + * Copyright (C) 2011, 2014 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 @@ -69,8 +69,10 @@ int gvir_config_domain_graphics_rdp_get_port(GVirConfigDomainGraphicsRdp *graphi void gvir_config_domain_graphics_rdp_set_port(GVirConfigDomainGraphicsRdp *graphics, int port); +gboolean gvir_config_domain_graphics_rdp_get_multi_user(GVirConfigDomainGraphicsRdp *graphics); void gvir_config_domain_graphics_rdp_set_multi_user(GVirConfigDomainGraphicsRdp *graphics, gboolean multi_user); +gboolean gvir_config_domain_graphics_rdp_get_replace_user(GVirConfigDomainGraphicsRdp *graphics); void gvir_config_domain_graphics_rdp_set_replace_user(GVirConfigDomainGraphicsRdp *graphics, gboolean replace_user); diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 27e8e91..9c35f97 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -647,6 +647,11 @@ global: gvir_config_domain_get_uuid; + gvir_config_domain_graphics_desktop_get_display; + gvir_config_domain_graphics_desktop_get_fullscreen; + + gvir_config_domain_graphics_rdp_get_multi_user; + gvir_config_domain_graphics_rdp_get_replace_user; gvir_config_domain_graphics_rdp_set_multi_user; gvir_config_domain_graphics_rdp_set_replace_user; -- 1.8.4.2

On Fri, Jan 17, 2014 at 2:11 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
Now that there is a gvir_config_object_get_attribute_boolean(), these are trivial to implement. ---
ACK -- Regards, Zeeshan Ali (Khattak) FSF member#5124

--- libvirt-gconfig/libvirt-gconfig-domain-timer.c | 26 +++++++++++++++++++++++++- libvirt-gconfig/libvirt-gconfig-domain-timer.h | 4 +++- libvirt-gconfig/libvirt-gconfig.sym | 3 +++ libvirt-gconfig/tests/test-domain-create.c | 2 ++ 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-timer.c b/libvirt-gconfig/libvirt-gconfig-domain-timer.c index e4c68fe..2d778dd 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-timer.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-timer.c @@ -1,7 +1,7 @@ /* * libvirt-gconfig-domain-timer.c: libvirt domain timer configuration * - * Copyright (C) 2011 Red Hat, Inc. + * Copyright (C) 2011, 2014 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 @@ -73,3 +73,27 @@ gvir_config_domain_timer_get_tick_policy(GVirConfigDomainTimer *timer) GVIR_CONFIG_TYPE_DOMAIN_TIMER_TICK_POLICY, GVIR_CONFIG_DOMAIN_TIMER_TICK_POLICY_DELAY); } + + +void gvir_config_domain_timer_set_present(GVirConfigDomainTimer *timer, + gboolean present) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_TIMER(timer)); + + gvir_config_object_set_attribute_with_type(GVIR_CONFIG_OBJECT(timer), + "present", + G_TYPE_BOOLEAN, + present, + NULL); +} + + +gboolean gvir_config_domain_timer_get_present(GVirConfigDomainTimer *timer) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_TIMER(timer), TRUE); + + return gvir_config_object_get_attribute_boolean(GVIR_CONFIG_OBJECT(timer), + NULL, + "present", + TRUE); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-timer.h b/libvirt-gconfig/libvirt-gconfig-domain-timer.h index 677e85f..8c93562 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-timer.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-timer.h @@ -1,7 +1,7 @@ /* * libvirt-gconfig-domain-timer.h: libvirt domain timer configuration * - * Copyright (C) 2011 Red Hat, Inc. + * Copyright (C) 2011, 2014 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 @@ -67,6 +67,8 @@ GType gvir_config_domain_timer_get_type(void); GVirConfigDomainTimerTickPolicy gvir_config_domain_timer_get_tick_policy(GVirConfigDomainTimer *timer); void gvir_config_domain_timer_set_tick_policy(GVirConfigDomainTimer *timer, GVirConfigDomainTimerTickPolicy policy); +gboolean gvir_config_domain_timer_get_present(GVirConfigDomainTimer *timer); +void gvir_config_domain_timer_set_present(GVirConfigDomainTimer *timer, gboolean present); G_END_DECLS diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 9c35f97..a393db3 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -673,6 +673,9 @@ global: gvir_config_domain_interface_get_filterref; gvir_config_domain_interface_set_filterref; + gvir_config_domain_timer_get_present; + gvir_config_domain_timer_set_present; + gvir_config_domain_set_uuid; gvir_config_object_new_from_xml; diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index e0d6c00..c973bf5 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -147,6 +147,7 @@ int main(int argc, char **argv) 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_assert(gvir_config_domain_timer_get_present(GVIR_CONFIG_DOMAIN_TIMER(pit)) != FALSE); g_object_unref(G_OBJECT(pit)); rtc = gvir_config_domain_timer_rtc_new(); @@ -154,6 +155,7 @@ int main(int argc, char **argv) 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_assert(gvir_config_domain_timer_get_present(GVIR_CONFIG_DOMAIN_TIMER(rtc)) != FALSE); g_object_unref(G_OBJECT(rtc)); gvir_config_domain_set_clock(domain, klock); -- 1.8.4.2

This will be needed in order to solve https://bugzilla.gnome.org/show_bug.cgi?id=722293 --- libvirt-gconfig/Makefile.am | 2 + .../libvirt-gconfig-domain-timer-hpet.c | 75 ++++++++++++++++++++++ .../libvirt-gconfig-domain-timer-hpet.h | 67 +++++++++++++++++++ libvirt-gconfig/libvirt-gconfig.h | 3 +- libvirt-gconfig/libvirt-gconfig.sym | 5 ++ libvirt-gconfig/tests/test-domain-create.c | 7 ++ 6 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-timer-hpet.c create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-timer-hpet.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 70b4d81..8fb333e 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -68,6 +68,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-domain-snapshot-disk.h \ libvirt-gconfig-domain-sound.h \ libvirt-gconfig-domain-timer.h \ + libvirt-gconfig-domain-timer-hpet.h \ libvirt-gconfig-domain-timer-pit.h \ libvirt-gconfig-domain-timer-rtc.h \ libvirt-gconfig-domain-video.h \ @@ -154,6 +155,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-snapshot-disk.c \ libvirt-gconfig-domain-sound.c \ libvirt-gconfig-domain-timer.c \ + libvirt-gconfig-domain-timer-hpet.c \ libvirt-gconfig-domain-timer-pit.c \ libvirt-gconfig-domain-timer-rtc.c \ libvirt-gconfig-domain-video.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-domain-timer-hpet.c b/libvirt-gconfig/libvirt-gconfig-domain-timer-hpet.c new file mode 100644 index 0000000..1734428 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-timer-hpet.c @@ -0,0 +1,75 @@ +/* + * libvirt-gconfig-domain-timer-hpet.c: libvirt domain HPET timer configuration + * + * Copyright (C) 2012, 2014 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, see + * <http://www.gnu.org/licenses/>. + * + * Author: Christophe Fergeau <cfergeau@redhat.com> + */ + +#include <config.h> + +#include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-private.h" + +#define GVIR_CONFIG_DOMAIN_TIMER_HPET_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_TIMER_HPET, GVirConfigDomainTimerHpetPrivate)) + +struct _GVirConfigDomainTimerHpetPrivate +{ + gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigDomainTimerHpet, gvir_config_domain_timer_hpet, GVIR_CONFIG_TYPE_DOMAIN_TIMER); + + +static void gvir_config_domain_timer_hpet_class_init(GVirConfigDomainTimerHpetClass *klass) +{ + g_type_class_add_private(klass, sizeof(GVirConfigDomainTimerHpetPrivate)); +} + + +static void gvir_config_domain_timer_hpet_init(GVirConfigDomainTimerHpet *timer) +{ + g_debug("Init GVirConfigDomainTimerHpet=%p", timer); + + timer->priv = GVIR_CONFIG_DOMAIN_TIMER_HPET_GET_PRIVATE(timer); +} + + +GVirConfigDomainTimerHpet *gvir_config_domain_timer_hpet_new(void) +{ + GVirConfigObject *object; + + object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_TIMER_HPET, + "timer", NULL); + gvir_config_object_set_attribute(object, "name", "hpet", NULL); + return GVIR_CONFIG_DOMAIN_TIMER_HPET(object); +} + +GVirConfigDomainTimerHpet *gvir_config_domain_timer_hpet_new_from_xml(const gchar *xml, + GError **error) +{ + GVirConfigObject *object; + + object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_TIMER_HPET, + "timer", NULL, xml, error); + if (g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "hpet") != 0) { + g_object_unref(G_OBJECT(object)); + g_return_val_if_reached(NULL); + } + return GVIR_CONFIG_DOMAIN_TIMER_HPET(object); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-timer-hpet.h b/libvirt-gconfig/libvirt-gconfig-domain-timer-hpet.h new file mode 100644 index 0000000..8721f37 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-timer-hpet.h @@ -0,0 +1,67 @@ +/* + * libvirt-gconfig-domain-timer-hpet.h: libvirt domain HPET timer configuration + * + * Copyright (C) 2012, 2014 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, see + * <http://www.gnu.org/licenses/>. + * + * Author: Christophe Fergeau <cfergeau@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_HPET_H__ +#define __LIBVIRT_GCONFIG_DOMAIN_TIMER_HPET_H__ + +G_BEGIN_DECLS + +#define GVIR_CONFIG_TYPE_DOMAIN_TIMER_HPET (gvir_config_domain_timer_hpet_get_type ()) +#define GVIR_CONFIG_DOMAIN_TIMER_HPET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_TIMER_HPET, GVirConfigDomainTimerHpet)) +#define GVIR_CONFIG_DOMAIN_TIMER_HPET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_TIMER_HPET, GVirConfigDomainTimerHpetClass)) +#define GVIR_CONFIG_IS_DOMAIN_TIMER_HPET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_TIMER_HPET)) +#define GVIR_CONFIG_IS_DOMAIN_TIMER_HPET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_TIMER_HPET)) +#define GVIR_CONFIG_DOMAIN_TIMER_HPET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_TIMER_HPET, GVirConfigDomainTimerHpetClass)) + +typedef struct _GVirConfigDomainTimerHpet GVirConfigDomainTimerHpet; +typedef struct _GVirConfigDomainTimerHpetPrivate GVirConfigDomainTimerHpetPrivate; +typedef struct _GVirConfigDomainTimerHpetClass GVirConfigDomainTimerHpetClass; + +struct _GVirConfigDomainTimerHpet +{ + GVirConfigObject parent; + + GVirConfigDomainTimerHpetPrivate *priv; + + /* Do not add fields to this struct */ +}; + +struct _GVirConfigDomainTimerHpetClass +{ + GVirConfigObjectClass parent_class; + + gpointer padding[20]; +}; + +GType gvir_config_domain_timer_hpet_get_type(void); + +GVirConfigDomainTimerHpet *gvir_config_domain_timer_hpet_new(void); +GVirConfigDomainTimerHpet *gvir_config_domain_timer_hpet_new_from_xml(const gchar *xml, + GError **error); + +G_END_DECLS + +#endif /* __LIBVIRT_GCONFIG_DOMAIN_TIMER_HPET_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h index 2b615ab..36a0a90 100644 --- a/libvirt-gconfig/libvirt-gconfig.h +++ b/libvirt-gconfig/libvirt-gconfig.h @@ -1,7 +1,7 @@ /* * libvirt-gconfig.h: libvirt gconfig integration * - * Copyright (C) 2010-2012 Red Hat, Inc. + * Copyright (C) 2010-2014 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 @@ -85,6 +85,7 @@ #include <libvirt-gconfig/libvirt-gconfig-domain-snapshot-disk.h> #include <libvirt-gconfig/libvirt-gconfig-domain-sound.h> #include <libvirt-gconfig/libvirt-gconfig-domain-timer.h> +#include <libvirt-gconfig/libvirt-gconfig-domain-timer-hpet.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> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index a393db3..81926dc 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -674,6 +674,11 @@ global: gvir_config_domain_interface_set_filterref; gvir_config_domain_timer_get_present; + + gvir_config_domain_timer_hpet_get_type; + gvir_config_domain_timer_hpet_new; + gvir_config_domain_timer_hpet_new_from_xml; + gvir_config_domain_timer_set_present; gvir_config_domain_set_uuid; diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index c973bf5..7ff008e 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -138,6 +138,7 @@ int main(int argc, char **argv) GVirConfigDomainClock *klock; GVirConfigDomainTimerPit *pit; GVirConfigDomainTimerRtc *rtc; + GVirConfigDomainTimerHpet *hpet; klock = gvir_config_domain_clock_new(); gvir_config_domain_clock_set_offset(klock, GVIR_CONFIG_DOMAIN_CLOCK_UTC); @@ -158,6 +159,12 @@ int main(int argc, char **argv) g_assert(gvir_config_domain_timer_get_present(GVIR_CONFIG_DOMAIN_TIMER(rtc)) != FALSE); g_object_unref(G_OBJECT(rtc)); + hpet = gvir_config_domain_timer_hpet_new(); + gvir_config_domain_timer_set_present(GVIR_CONFIG_DOMAIN_TIMER(hpet), FALSE); + gvir_config_domain_clock_add_timer(klock, GVIR_CONFIG_DOMAIN_TIMER(hpet)); + g_assert(gvir_config_domain_timer_get_present(GVIR_CONFIG_DOMAIN_TIMER(hpet)) == FALSE); + g_object_unref(G_OBJECT(hpet)); + gvir_config_domain_set_clock(domain, klock); g_object_unref(G_OBJECT(klock)); -- 1.8.4.2

On Fri, Jan 17, 2014 at 2:11 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
This will be needed in order to solve https://bugzilla.gnome.org/show_bug.cgi?id=722293 --- libvirt-gconfig/Makefile.am | 2 + .../libvirt-gconfig-domain-timer-hpet.c | 75 ++++++++++++++++++++++ .../libvirt-gconfig-domain-timer-hpet.h | 67 +++++++++++++++++++ libvirt-gconfig/libvirt-gconfig.h | 3 +- libvirt-gconfig/libvirt-gconfig.sym | 5 ++ libvirt-gconfig/tests/test-domain-create.c | 7 ++ 6 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-timer-hpet.c create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-timer-hpet.h
diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 70b4d81..8fb333e 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -68,6 +68,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-domain-snapshot-disk.h \ libvirt-gconfig-domain-sound.h \ libvirt-gconfig-domain-timer.h \ + libvirt-gconfig-domain-timer-hpet.h \ libvirt-gconfig-domain-timer-pit.h \ libvirt-gconfig-domain-timer-rtc.h \ libvirt-gconfig-domain-video.h \ @@ -154,6 +155,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-snapshot-disk.c \ libvirt-gconfig-domain-sound.c \ libvirt-gconfig-domain-timer.c \ + libvirt-gconfig-domain-timer-hpet.c \ libvirt-gconfig-domain-timer-pit.c \ libvirt-gconfig-domain-timer-rtc.c \ libvirt-gconfig-domain-video.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-domain-timer-hpet.c b/libvirt-gconfig/libvirt-gconfig-domain-timer-hpet.c new file mode 100644 index 0000000..1734428 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-timer-hpet.c @@ -0,0 +1,75 @@ +/* + * libvirt-gconfig-domain-timer-hpet.c: libvirt domain HPET timer configuration + * + * Copyright (C) 2012, 2014 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, see + * <http://www.gnu.org/licenses/>. + * + * Author: Christophe Fergeau <cfergeau@redhat.com> + */ + +#include <config.h> + +#include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-private.h" + +#define GVIR_CONFIG_DOMAIN_TIMER_HPET_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_TIMER_HPET, GVirConfigDomainTimerHpetPrivate)) + +struct _GVirConfigDomainTimerHpetPrivate +{ + gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigDomainTimerHpet, gvir_config_domain_timer_hpet, GVIR_CONFIG_TYPE_DOMAIN_TIMER); + + +static void gvir_config_domain_timer_hpet_class_init(GVirConfigDomainTimerHpetClass *klass) +{ + g_type_class_add_private(klass, sizeof(GVirConfigDomainTimerHpetPrivate)); +} + + +static void gvir_config_domain_timer_hpet_init(GVirConfigDomainTimerHpet *timer) +{ + g_debug("Init GVirConfigDomainTimerHpet=%p", timer); + + timer->priv = GVIR_CONFIG_DOMAIN_TIMER_HPET_GET_PRIVATE(timer); +} + + +GVirConfigDomainTimerHpet *gvir_config_domain_timer_hpet_new(void) +{ + GVirConfigObject *object; + + object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_TIMER_HPET, + "timer", NULL); + gvir_config_object_set_attribute(object, "name", "hpet", NULL); + return GVIR_CONFIG_DOMAIN_TIMER_HPET(object); +} + +GVirConfigDomainTimerHpet *gvir_config_domain_timer_hpet_new_from_xml(const gchar *xml, + GError **error) +{ + GVirConfigObject *object; + + object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_TIMER_HPET, + "timer", NULL, xml, error); + if (g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "hpet") != 0) { + g_object_unref(G_OBJECT(object)); + g_return_val_if_reached(NULL); + } + return GVIR_CONFIG_DOMAIN_TIMER_HPET(object); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-timer-hpet.h b/libvirt-gconfig/libvirt-gconfig-domain-timer-hpet.h new file mode 100644 index 0000000..8721f37 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-timer-hpet.h @@ -0,0 +1,67 @@ +/* + * libvirt-gconfig-domain-timer-hpet.h: libvirt domain HPET timer configuration + * + * Copyright (C) 2012, 2014 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, see + * <http://www.gnu.org/licenses/>. + * + * Author: Christophe Fergeau <cfergeau@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_HPET_H__ +#define __LIBVIRT_GCONFIG_DOMAIN_TIMER_HPET_H__ + +G_BEGIN_DECLS + +#define GVIR_CONFIG_TYPE_DOMAIN_TIMER_HPET (gvir_config_domain_timer_hpet_get_type ()) +#define GVIR_CONFIG_DOMAIN_TIMER_HPET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_TIMER_HPET, GVirConfigDomainTimerHpet)) +#define GVIR_CONFIG_DOMAIN_TIMER_HPET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_TIMER_HPET, GVirConfigDomainTimerHpetClass)) +#define GVIR_CONFIG_IS_DOMAIN_TIMER_HPET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_TIMER_HPET)) +#define GVIR_CONFIG_IS_DOMAIN_TIMER_HPET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_TIMER_HPET)) +#define GVIR_CONFIG_DOMAIN_TIMER_HPET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_TIMER_HPET, GVirConfigDomainTimerHpetClass)) + +typedef struct _GVirConfigDomainTimerHpet GVirConfigDomainTimerHpet; +typedef struct _GVirConfigDomainTimerHpetPrivate GVirConfigDomainTimerHpetPrivate; +typedef struct _GVirConfigDomainTimerHpetClass GVirConfigDomainTimerHpetClass; + +struct _GVirConfigDomainTimerHpet +{ + GVirConfigObject parent;
Shouldn't this be GVirConfigDomainTimer? -- Regards, Zeeshan Ali (Khattak) FSF member#5124

On Fri, Jan 17, 2014 at 02:33:55PM +0000, Zeeshan Ali (Khattak) wrote:
On Fri, Jan 17, 2014 at 2:11 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
+struct _GVirConfigDomainTimerHpet +{ + GVirConfigObject parent;
Shouldn't this be GVirConfigDomainTimer?
Yes, great catch! Fixed. This file is copied and pasted from GVirConfigDomainTimerPit which has already been in a release and has the same issue :( Christophe

On Fri, Jan 17, 2014 at 3:08 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
On Fri, Jan 17, 2014 at 02:33:55PM +0000, Zeeshan Ali (Khattak) wrote:
On Fri, Jan 17, 2014 at 2:11 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
+struct _GVirConfigDomainTimerHpet +{ + GVirConfigObject parent;
Shouldn't this be GVirConfigDomainTimer?
Yes, great catch! Fixed. This file is copied and pasted from GVirConfigDomainTimerPit which has already been in a release and has the same issue :(
Thats sad indeed but then again we haven't promised API/ABI stability yet and this only breaks ABI. -- Regards, Zeeshan Ali (Khattak) FSF member#5124
participants (2)
-
Christophe Fergeau
-
Zeeshan Ali (Khattak)