Only the (non-TLS) port can be set on it --- libvirt-gconfig/Makefile.am | 2 + libvirt-gconfig/libvirt-gconfig-graphics-spice.c | 98 ++++++++++++++++++++++ libvirt-gconfig/libvirt-gconfig-graphics-spice.h | 69 +++++++++++++++ libvirt-gconfig/libvirt-gconfig.h | 1 + libvirt-gconfig/libvirt-gconfig.sym | 5 + libvirt-gconfig/tests/test-domain-create.c | 7 ++ 6 files changed, 182 insertions(+), 0 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-graphics-spice.c create mode 100644 libvirt-gconfig/libvirt-gconfig-graphics-spice.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index dcb5caa..e14d90a 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -17,6 +17,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-device-input.h \ libvirt-gconfig-domain.h \ libvirt-gconfig-domain-snapshot.h \ + libvirt-gconfig-graphics-spice.h \ libvirt-gconfig-helpers.h \ libvirt-gconfig-interface.h \ libvirt-gconfig-interface-network.h \ @@ -41,6 +42,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-snapshot.c \ libvirt-gconfig-enum-types.c \ libvirt-gconfig-enum-types.h \ + libvirt-gconfig-graphics-spice.c \ libvirt-gconfig-helpers.c \ libvirt-gconfig-interface.c \ libvirt-gconfig-interface-network.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-graphics-spice.c new file mode 100644 index 0000000..acb2304 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-graphics-spice.c @@ -0,0 +1,98 @@ +/* + * libvirt-gobject-config-graphics-spice.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@xxxxxxxxx> + */ + +#include <config.h> + +#include <string.h> + +#include <libxml/tree.h> + +#include "libvirt-gconfig/libvirt-gconfig.h" + +extern gboolean debugFlag; + +#define DEBUG(fmt, ...) do { if (G_UNLIKELY(debugFlag)) g_debug(fmt, ## __VA_ARGS__); } while (0) + +#define GVIR_CONFIG_GRAPHICS_SPICE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_GRAPHICS_SPICE, GVirConfigGraphicsSpicePrivate)) + +struct _GVirConfigGraphicsSpicePrivate +{ + gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigGraphicsSpice, gvir_config_graphics_spice, GVIR_TYPE_CONFIG_DEVICE); + + +static void gvir_config_graphics_spice_class_init(GVirConfigGraphicsSpiceClass *klass) +{ + + g_type_class_add_private(klass, sizeof(GVirConfigGraphicsSpicePrivate)); +} + + +static void gvir_config_graphics_spice_init(GVirConfigGraphicsSpice *graphics_spice) +{ + GVirConfigGraphicsSpicePrivate *priv; + + DEBUG("Init GVirConfigGraphicsSpice=%p", graphics_spice); + + priv = graphics_spice->priv = GVIR_CONFIG_GRAPHICS_SPICE_GET_PRIVATE(graphics_spice); + + memset(priv, 0, sizeof(*priv)); +} + + +GVirConfigGraphicsSpice *gvir_config_graphics_spice_new(void) +{ + GVirConfigObject *object; + + object = gvir_config_object_new(GVIR_TYPE_CONFIG_GRAPHICS_SPICE, + "graphics", NULL); + //xmlNewProp(doc->children, (xmlChar*)"type", (xmlChar*)"spice"); + return GVIR_CONFIG_GRAPHICS_SPICE(object); +} + +GVirConfigGraphicsSpice *gvir_config_graphics_spice_new_from_xml(const gchar *xml, + GError **error) +{ + GVirConfigObject *object; + + object = gvir_config_object_new_from_xml(GVIR_TYPE_CONFIG_GRAPHICS_SPICE, + "graphics", NULL, xml, error); +// xmlNewProp(doc->children, (xmlChar*)"type", (xmlChar*)"spice"); + return GVIR_CONFIG_GRAPHICS_SPICE(object); +} + +void gvir_config_graphics_spice_set_port(GVirConfigGraphicsSpice *graphics, + unsigned int port) +{ + xmlNodePtr node; + char *port_str; + + node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(graphics)); + if (node == NULL) + return; + port_str = g_strdup_printf("%u", port); + xmlNewProp(node, (xmlChar*)"port", (xmlChar*)port_str); + g_free(port_str); +} diff --git a/libvirt-gconfig/libvirt-gconfig-graphics-spice.h b/libvirt-gconfig/libvirt-gconfig-graphics-spice.h new file mode 100644 index 0000000..1266854 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-graphics-spice.h @@ -0,0 +1,69 @@ +/* + * libvirt-gobject-graphics-spice.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@xxxxxxxxx> + */ + +#if !defined(__LIBVIRT_GCONFIG_H__) && !defined(LIBVIRT_GCONFIG_BUILD) +#error "Only <libvirt-gconfig/libvirt-gconfig.h> can be included directly." +#endif + +#ifndef __LIBVIRT_GCONFIG_GRAPHICS_SPICE_H__ +#define __LIBVIRT_GCONFIG_GRAPHICS_SPICE_H__ + +G_BEGIN_DECLS + +#define GVIR_TYPE_CONFIG_GRAPHICS_SPICE (gvir_config_graphics_spice_get_type ()) +#define GVIR_CONFIG_GRAPHICS_SPICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_TYPE_CONFIG_GRAPHICS_SPICE, GVirConfigGraphicsSpice)) +#define GVIR_CONFIG_GRAPHICS_SPICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_TYPE_CONFIG_GRAPHICS_SPICE, GVirConfigGraphicsSpiceClass)) +#define GVIR_IS_CONFIG_GRAPHICS_SPICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_TYPE_CONFIG_GRAPHICS_SPICE)) +#define GVIR_IS_CONFIG_GRAPHICS_SPICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_TYPE_CONFIG_GRAPHICS_SPICE)) +#define GVIR_CONFIG_GRAPHICS_SPICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_TYPE_CONFIG_GRAPHICS_SPICE, GVirConfigGraphicsSpiceClass)) + +typedef struct _GVirConfigGraphicsSpice GVirConfigGraphicsSpice; +typedef struct _GVirConfigGraphicsSpicePrivate GVirConfigGraphicsSpicePrivate; +typedef struct _GVirConfigGraphicsSpiceClass GVirConfigGraphicsSpiceClass; + +struct _GVirConfigGraphicsSpice +{ + GVirConfigObject parent; + + GVirConfigGraphicsSpicePrivate *priv; + + /* Do not add fields to this struct */ +}; + +struct _GVirConfigGraphicsSpiceClass +{ + GVirConfigObjectClass parent_class; + + gpointer padding[20]; +}; + +GType gvir_config_graphics_spice_get_type(void); + +GVirConfigGraphicsSpice *gvir_config_graphics_spice_new(void); +GVirConfigGraphicsSpice *gvir_config_graphics_spice_new_from_xml(const gchar *xml, + GError **error); +void gvir_config_graphics_spice_set_port(GVirConfigGraphicsSpice *graphics, + unsigned int port); + +G_END_DECLS + +#endif /* __LIBVIRT_GCONFIG_GRAPHICS_SPICE_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h index 0f0abb7..218aada 100644 --- a/libvirt-gconfig/libvirt-gconfig.h +++ b/libvirt-gconfig/libvirt-gconfig.h @@ -34,6 +34,7 @@ #include <libvirt-gconfig/libvirt-gconfig-device-input.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> #include <libvirt-gconfig/libvirt-gconfig-helpers.h> #include <libvirt-gconfig/libvirt-gconfig-interface.h> #include <libvirt-gconfig/libvirt-gconfig-interface-network.h> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 1904acc..ebe87d1 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -55,6 +55,11 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_config_domain_snapshot_new; gvir_config_domain_snapshot_new_from_xml; + gvir_config_graphics_spice_get_type; + gvir_config_graphics_spice_new; + gvir_config_graphics_spice_new_from_xml; + gvir_config_graphics_spice_set_port; + gvir_config_interface_get_type; gvir_config_interface_network_get_type; diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index a95da77..539b475 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -112,6 +112,13 @@ int main(void) gvir_config_device_input_set_bus(input, "usb"); devices = g_list_append(devices, GVIR_CONFIG_DEVICE(input)); + /* graphics node */ + GVirConfigGraphicsSpice *graphics; + + graphics = gvir_config_graphics_spice_new(); + gvir_config_graphics_spice_set_port(graphics, 1234); + devices = g_list_append(devices, GVIR_CONFIG_DEVICE(graphics)); + gvir_config_domain_set_devices(domain, devices); g_list_free(devices); -- 1.7.7 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list