---
libvirt-gconfig/Makefile.am | 2 +
libvirt-gconfig/libvirt-gconfig-device-video.c | 133 ++++++++++++++++++++++++
libvirt-gconfig/libvirt-gconfig-device-video.h | 82 +++++++++++++++
libvirt-gconfig/libvirt-gconfig.h | 1 +
libvirt-gconfig/libvirt-gconfig.sym | 8 ++
libvirt-gconfig/tests/test-domain-create.c | 9 ++
6 files changed, 235 insertions(+), 0 deletions(-)
create mode 100644 libvirt-gconfig/libvirt-gconfig-device-video.c
create mode 100644 libvirt-gconfig/libvirt-gconfig-device-video.h
diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index e14d90a..71fe027 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -15,6 +15,7 @@ GCONFIG_HEADER_FILES = \
libvirt-gconfig-device.h \
libvirt-gconfig-device-disk.h \
libvirt-gconfig-device-input.h \
+ libvirt-gconfig-device-video.h \
libvirt-gconfig-domain.h \
libvirt-gconfig-domain-snapshot.h \
libvirt-gconfig-graphics-spice.h \
@@ -38,6 +39,7 @@ GCONFIG_SOURCE_FILES = \
libvirt-gconfig-device.c \
libvirt-gconfig-device-disk.c \
libvirt-gconfig-device-input.c \
+ libvirt-gconfig-device-video.c \
libvirt-gconfig-domain.c \
libvirt-gconfig-domain-snapshot.c \
libvirt-gconfig-enum-types.c \
diff --git a/libvirt-gconfig/libvirt-gconfig-device-video.c
b/libvirt-gconfig/libvirt-gconfig-device-video.c
new file mode 100644
index 0000000..23736db
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-device-video.c
@@ -0,0 +1,133 @@
+/*
+ * libvirt-gobject-config-device-video.c: libvirt glib integration
+ *
+ * Copyright (C) 2011 Red Hat
+ *
+ * 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(a)gmail.com>
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <libxml/tree.h>
+
+#include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h"
+
+extern gboolean debugFlag;
+
+#define DEBUG(fmt, ...) do { if (G_UNLIKELY(debugFlag)) g_debug(fmt, ## __VA_ARGS__); }
while (0)
+
+#define GVIR_CONFIG_DEVICE_VIDEO_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DEVICE_VIDEO,
GVirConfigDeviceVideoPrivate))
+
+struct _GVirConfigDeviceVideoPrivate
+{
+ gboolean unused;
+};
+
+G_DEFINE_TYPE(GVirConfigDeviceVideo, gvir_config_device_video, GVIR_TYPE_CONFIG_DEVICE);
+
+
+static void gvir_config_device_video_class_init(GVirConfigDeviceVideoClass *klass)
+{
+
+ g_type_class_add_private(klass, sizeof(GVirConfigDeviceVideoPrivate));
+}
+
+
+static void gvir_config_device_video_init(GVirConfigDeviceVideo *device_video)
+{
+ GVirConfigDeviceVideoPrivate *priv;
+
+ DEBUG("Init GVirConfigDeviceVideo=%p", device_video);
+
+ priv = device_video->priv = GVIR_CONFIG_DEVICE_VIDEO_GET_PRIVATE(device_video);
+
+ memset(priv, 0, sizeof(*priv));
+}
+
+
+GVirConfigDeviceVideo *gvir_config_device_video_new(void)
+{
+ GVirConfigObject *object;
+
+ object = gvir_config_object_new(GVIR_TYPE_CONFIG_DEVICE_VIDEO,
+ "video", NULL);
+ return GVIR_CONFIG_DEVICE_VIDEO(object);
+}
+
+GVirConfigDeviceVideo *gvir_config_device_video_new_from_xml(const gchar *xml,
+ GError **error)
+{
+ GVirConfigObject *object;
+
+ object = gvir_config_object_new_from_xml(GVIR_TYPE_CONFIG_DEVICE_VIDEO,
+ "video", NULL, xml, error);
+ return GVIR_CONFIG_DEVICE_VIDEO(object);
+}
+
+void gvir_config_device_video_set_model(GVirConfigDeviceVideo *video,
+ GVirConfigDeviceVideoModel model)
+{
+ xmlNodePtr node;
+ const char *model_str;
+
+ node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(video),
+ "model", TRUE);
+ if (node == NULL)
+ return;
+ model_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_DEVICE_VIDEO_MODEL,
+ model);
+ if (model_str != NULL)
+ xmlNewProp(node, (xmlChar*)"type", (xmlChar*)model_str);
+}
+
+void gvir_config_device_video_set_vram(GVirConfigDeviceVideo *video,
+ guint kbytes)
+{
+ xmlNodePtr node;
+ char *vram_str;
+
+ node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(video));
+ if (node == NULL)
+ return;
+ node = gvir_config_xml_get_element(node, "model", NULL);
+ if (node == NULL)
+ return;
+ vram_str = g_strdup_printf("%u", kbytes);
+ xmlNewProp(node, (xmlChar*)"vram", (xmlChar*)vram_str);
+ g_free(vram_str);
+}
+
+void gvir_config_device_video_set_heads(GVirConfigDeviceVideo *video,
+ guint head_count)
+{
+ xmlNodePtr node;
+ char *heads_str;
+
+ node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(video));
+ if (node == NULL)
+ return;
+ node = gvir_config_xml_get_element(node, "model", NULL);
+ if (node == NULL)
+ return;
+ heads_str = g_strdup_printf("%u", head_count);
+ xmlNewProp(node, (xmlChar*)"heads", (xmlChar*)heads_str);
+ g_free(heads_str);
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-device-video.h
b/libvirt-gconfig/libvirt-gconfig-device-video.h
new file mode 100644
index 0000000..ec83d2e
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-device-video.h
@@ -0,0 +1,82 @@
+/*
+ * libvirt-gobject-device-video.c: libvirt gobject integration
+ *
+ * Copyright (C) 2011 Red Hat
+ *
+ * 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(a)gmail.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_DEVICE_VIDEO_H__
+#define __LIBVIRT_GCONFIG_DEVICE_VIDEO_H__
+
+G_BEGIN_DECLS
+
+#define GVIR_TYPE_CONFIG_DEVICE_VIDEO (gvir_config_device_video_get_type ())
+#define GVIR_CONFIG_DEVICE_VIDEO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GVIR_TYPE_CONFIG_DEVICE_VIDEO, GVirConfigDeviceVideo))
+#define GVIR_CONFIG_DEVICE_VIDEO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GVIR_TYPE_CONFIG_DEVICE_VIDEO, GVirConfigDeviceVideoClass))
+#define GVIR_IS_CONFIG_DEVICE_VIDEO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GVIR_TYPE_CONFIG_DEVICE_VIDEO))
+#define GVIR_IS_CONFIG_DEVICE_VIDEO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GVIR_TYPE_CONFIG_DEVICE_VIDEO))
+#define GVIR_CONFIG_DEVICE_VIDEO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GVIR_TYPE_CONFIG_DEVICE_VIDEO, GVirConfigDeviceVideoClass))
+
+typedef struct _GVirConfigDeviceVideo GVirConfigDeviceVideo;
+typedef struct _GVirConfigDeviceVideoPrivate GVirConfigDeviceVideoPrivate;
+typedef struct _GVirConfigDeviceVideoClass GVirConfigDeviceVideoClass;
+
+struct _GVirConfigDeviceVideo
+{
+ GVirConfigObject parent;
+
+ GVirConfigDeviceVideoPrivate *priv;
+
+ /* Do not add fields to this struct */
+};
+
+struct _GVirConfigDeviceVideoClass
+{
+ GVirConfigObjectClass parent_class;
+
+ gpointer padding[20];
+};
+
+typedef enum {
+ GVIR_CONFIG_DEVICE_VIDEO_MODEL_VGA,
+ GVIR_CONFIG_DEVICE_VIDEO_MODEL_CIRRUS,
+ GVIR_CONFIG_DEVICE_VIDEO_MODEL_VMVGA,
+ GVIR_CONFIG_DEVICE_VIDEO_MODEL_XEN,
+ GVIR_CONFIG_DEVICE_VIDEO_MODEL_VBOX,
+ GVIR_CONFIG_DEVICE_VIDEO_MODEL_QXL
+} GVirConfigDeviceVideoModel;
+
+GType gvir_config_device_video_get_type(void);
+
+GVirConfigDeviceVideo *gvir_config_device_video_new(void);
+GVirConfigDeviceVideo *gvir_config_device_video_new_from_xml(const gchar *xml,
+ GError **error);
+void gvir_config_device_video_set_model(GVirConfigDeviceVideo *video,
+ GVirConfigDeviceVideoModel model);
+void gvir_config_device_video_set_vram(GVirConfigDeviceVideo *video,
+ guint kbytes);
+void gvir_config_device_video_set_heads(GVirConfigDeviceVideo *video,
+ guint head_count);
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_DEVICE_VIDEO_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h
index 218aada..01c59d0 100644
--- a/libvirt-gconfig/libvirt-gconfig.h
+++ b/libvirt-gconfig/libvirt-gconfig.h
@@ -32,6 +32,7 @@
#include <libvirt-gconfig/libvirt-gconfig-device.h>
#include <libvirt-gconfig/libvirt-gconfig-device-disk.h>
#include <libvirt-gconfig/libvirt-gconfig-device-input.h>
+#include <libvirt-gconfig/libvirt-gconfig-device-video.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-snapshot.h>
#include <libvirt-gconfig/libvirt-gconfig-enum-types.h>
#include <libvirt-gconfig/libvirt-gconfig-graphics-spice.h>
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index ebe87d1..6d895fb 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -36,6 +36,14 @@ LIBVIRT_GOBJECT_0.0.1 {
gvir_config_device_input_set_device_type;
gvir_config_device_input_set_bus;
+ gvir_config_device_video_get_type;
+ gvir_config_device_video_model_get_type;
+ gvir_config_device_video_new;
+ gvir_config_device_video_new_from_xml;
+ gvir_config_device_video_set_model;
+ gvir_config_device_video_set_vram;
+ gvir_config_device_video_set_heads;
+
gvir_config_domain_get_type;
gvir_config_domain_new;
gvir_config_domain_new_from_xml;
diff --git a/libvirt-gconfig/tests/test-domain-create.c
b/libvirt-gconfig/tests/test-domain-create.c
index 539b475..ba08a9f 100644
--- a/libvirt-gconfig/tests/test-domain-create.c
+++ b/libvirt-gconfig/tests/test-domain-create.c
@@ -119,6 +119,15 @@ int main(void)
gvir_config_graphics_spice_set_port(graphics, 1234);
devices = g_list_append(devices, GVIR_CONFIG_DEVICE(graphics));
+ /* video node */
+ GVirConfigDeviceVideo *video;
+
+ video = gvir_config_device_video_new();
+ gvir_config_device_video_set_model(video,
+ GVIR_CONFIG_DEVICE_VIDEO_MODEL_QXL);
+ devices = g_list_append(devices, GVIR_CONFIG_DEVICE(video));
+
+
gvir_config_domain_set_devices(domain, devices);
g_list_free(devices);
--
1.7.7