[libvirt-glib 4/4] Add GVirConfigDomainTimerHpet

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

 



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@xxxxxxxxxx>
+ */
+
+#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@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_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

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