[libvirt] [PATCH libvirt-glib 1/2] gconfig: add spiceport chardev

Marc-André Lureau marcandre.lureau at gmail.com
Fri May 9 20:28:27 UTC 2014


From: Marc-André Lureau <marcandre.lureau at gmail.com>

---
 libvirt-gconfig/Makefile.am                        |   2 +
 libvirt-gconfig/libvirt-gconfig-domain-channel.h   |   1 +
 ...bvirt-gconfig-domain-chardev-source-spiceport.c | 101 +++++++++++++++++++++
 ...bvirt-gconfig-domain-chardev-source-spiceport.h |  71 +++++++++++++++
 libvirt-gconfig/libvirt-gconfig.h                  |   1 +
 libvirt-gconfig/libvirt-gconfig.sym                |   9 ++
 6 files changed, 185 insertions(+)
 create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spiceport.c
 create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spiceport.h

diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index d328ca7..83d521f 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -28,6 +28,7 @@ GCONFIG_HEADER_FILES = \
 			libvirt-gconfig-domain-chardev.h \
 			libvirt-gconfig-domain-chardev-source.h \
 			libvirt-gconfig-domain-chardev-source-pty.h \
+			libvirt-gconfig-domain-chardev-source-spiceport.h \
 			libvirt-gconfig-domain-chardev-source-spicevmc.h \
 			libvirt-gconfig-domain-clock.h \
 			libvirt-gconfig-domain-console.h \
@@ -114,6 +115,7 @@ GCONFIG_SOURCE_FILES = \
 			libvirt-gconfig-domain-chardev.c \
 			libvirt-gconfig-domain-chardev-source.c \
 			libvirt-gconfig-domain-chardev-source-pty.c \
+			libvirt-gconfig-domain-chardev-source-spiceport.c \
 			libvirt-gconfig-domain-chardev-source-spicevmc.c \
 			libvirt-gconfig-domain-clock.c \
 			libvirt-gconfig-domain-console.c \
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-channel.h b/libvirt-gconfig/libvirt-gconfig-domain-channel.h
index 889b09a..4f1130e 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-channel.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain-channel.h
@@ -59,6 +59,7 @@ struct _GVirConfigDomainChannelClass
 typedef enum {
     GVIR_CONFIG_DOMAIN_CHANNEL_TARGET_GUESTFWD,
     GVIR_CONFIG_DOMAIN_CHANNEL_TARGET_VIRTIO,
+    GVIR_CONFIG_DOMAIN_CHANNEL_TARGET_SPICEPORT,
 } GVirConfigDomainChannelTargetType;
 
 
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spiceport.c b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spiceport.c
new file mode 100644
index 0000000..570e7ea
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spiceport.c
@@ -0,0 +1,101 @@
+/*
+ * libvirt-gconfig-domain-chardev-source-spiceport.c: libvirt domain chardev spiceport configuration
+ *
+ * Copyright (C) 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/>.
+ */
+
+#include <config.h>
+
+#include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
+
+#define GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_PORT_GET_PRIVATE(obj)                         \
+        (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_PORT, GVirConfigDomainChardevSourceSpicePortPrivate))
+
+struct _GVirConfigDomainChardevSourceSpicePortPrivate
+{
+    gboolean unused;
+};
+
+G_DEFINE_TYPE(GVirConfigDomainChardevSourceSpicePort, gvir_config_domain_chardev_source_spiceport, GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE);
+
+
+static void gvir_config_domain_chardev_source_spiceport_class_init(GVirConfigDomainChardevSourceSpicePortClass *klass)
+{
+    g_type_class_add_private(klass, sizeof(GVirConfigDomainChardevSourceSpicePortPrivate));
+}
+
+
+static void gvir_config_domain_chardev_source_spiceport_init(GVirConfigDomainChardevSourceSpicePort *source)
+{
+    g_debug("Init GVirConfigDomainChardevSourceSpicePort=%p", source);
+
+    source->priv = GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_PORT_GET_PRIVATE(source);
+}
+
+
+GVirConfigDomainChardevSourceSpicePort *gvir_config_domain_chardev_source_spiceport_new(void)
+{
+    GVirConfigObject *object;
+
+    /* the name of the root node is just a placeholder, it will be
+     * overwritten when the GVirConfigDomainChardevSourceSpicePort is attached to a
+     * GVirConfigDomainChardevSourceSpicePort
+     */
+    object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_PORT, "dummy", NULL);
+    gvir_config_object_set_attribute(object, "type", "spiceport", NULL);
+    return GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_PORT(object);
+}
+
+
+GVirConfigDomainChardevSourceSpicePort *gvir_config_domain_chardev_source_spiceport_new_from_xml(const gchar *xml,
+                                                                              GError **error)
+{
+    GVirConfigObject *object;
+
+    /* the name of the root node is just a placeholder, it will be
+     * overwritten when the GVirConfigDomainChardevSourceSpicePort is attached to a
+     * GVirConfigDomainChardevSourceSpicePort
+     */
+    object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_PORT,
+                                             "dummy", NULL, xml, error);
+    if (g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "spiceport") != 0) {
+        g_object_unref(G_OBJECT(object));
+        g_return_val_if_reached(NULL);
+    }
+    return GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_PORT(object);
+}
+
+void gvir_config_domain_chardev_source_spiceport_set_channel(GVirConfigDomainChardevSourceSpicePort *port,
+                                                             const char *channel)
+{
+    g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_CHARDEV_SOURCE_SPICE_PORT(port));
+
+    gvir_config_object_replace_child_with_attribute(GVIR_CONFIG_OBJECT(port),
+                                                    "source",
+                                                    "channel",
+                                                    channel);
+
+}
+
+const gchar * gvir_config_domain_chardev_source_spiceport_get_channel(GVirConfigDomainChardevSourceSpicePort *port)
+{
+    g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_CHARDEV_SOURCE_SPICE_PORT(port), NULL);
+
+    return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(port),
+                                            "source", "channel");
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spiceport.h b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spiceport.h
new file mode 100644
index 0000000..5ff7794
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spiceport.h
@@ -0,0 +1,71 @@
+/*
+ * libvirt-gconfig-domain-chardev-source-spiceport.h: libvirt domain chardev spiceport configuration
+ *
+ * Copyright (C) 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/>.
+ */
+
+#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_CHARDEV_SOURCE_SPICE_PORT_H__
+#define __LIBVIRT_GCONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_PORT_H__
+
+G_BEGIN_DECLS
+
+#define GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_PORT            (gvir_config_domain_chardev_source_spiceport_get_type ())
+#define GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_PORT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_PORT, GVirConfigDomainChardevSourceSpicePort))
+#define GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_PORT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_PORT, GVirConfigDomainChardevSourceSpicePortClass))
+#define GVIR_CONFIG_IS_DOMAIN_CHARDEV_SOURCE_SPICE_PORT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_PORT))
+#define GVIR_CONFIG_IS_DOMAIN_CHARDEV_SOURCE_SPICE_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_PORT))
+#define GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_PORT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_PORT, GVirConfigDomainChardevSourceSpicePortClass))
+
+typedef struct _GVirConfigDomainChardevSourceSpicePort GVirConfigDomainChardevSourceSpicePort;
+typedef struct _GVirConfigDomainChardevSourceSpicePortPrivate GVirConfigDomainChardevSourceSpicePortPrivate;
+typedef struct _GVirConfigDomainChardevSourceSpicePortClass GVirConfigDomainChardevSourceSpicePortClass;
+
+struct _GVirConfigDomainChardevSourceSpicePort
+{
+    GVirConfigDomainChardevSource parent;
+
+    GVirConfigDomainChardevSourceSpicePortPrivate *priv;
+
+    /* Do not add fields to this struct */
+};
+
+struct _GVirConfigDomainChardevSourceSpicePortClass
+{
+    GVirConfigDomainChardevSourceClass parent_class;
+
+    gpointer padding[20];
+};
+
+
+GType gvir_config_domain_chardev_source_spiceport_get_type(void);
+
+GVirConfigDomainChardevSourceSpicePort *gvir_config_domain_chardev_source_spiceport_new(void);
+GVirConfigDomainChardevSourceSpicePort *gvir_config_domain_chardev_source_spiceport_new_from_xml(const gchar *xml,
+                                                                              GError **error);
+
+void gvir_config_domain_chardev_source_spiceport_set_channel(GVirConfigDomainChardevSourceSpicePort *port,
+                                                    const char *channel);
+
+const gchar * gvir_config_domain_chardev_source_spiceport_get_channel(GVirConfigDomainChardevSourceSpicePort *port);
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_PORT_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h
index 61b5a04..1582109 100644
--- a/libvirt-gconfig/libvirt-gconfig.h
+++ b/libvirt-gconfig/libvirt-gconfig.h
@@ -44,6 +44,7 @@
 #include <libvirt-gconfig/libvirt-gconfig-domain-chardev.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-chardev-source.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-chardev-source-pty.h>
+#include <libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spiceport.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-channel.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-clock.h>
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index ead313b..fc68050 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -687,4 +687,13 @@ global:
 	gvir_config_object_new_from_xml;
 } LIBVIRT_GCONFIG_0.1.7;
 
+LIBVIRT_GCONFIG_0.1.9 {
+global:
+	gvir_config_domain_chardev_source_spiceport_get_channel;
+	gvir_config_domain_chardev_source_spiceport_get_type;
+	gvir_config_domain_chardev_source_spiceport_new;
+	gvir_config_domain_chardev_source_spiceport_new_from_xml;
+	gvir_config_domain_chardev_source_spiceport_set_channel;
+} LIBVIRT_GCONFIG_0.1.8;
+
 # .... define new API here using predicted next version number ....
-- 
1.8.5.3




More information about the libvir-list mailing list