[libvirt] [libvirt-glib 00/20] gconfig: <graphics> configuration work

Hey, This series groups 2 series which were sent previously for review, one from Visarion https://www.redhat.com/archives/libvir-list/2016-August/msg00868.html and one from Fidencio https://www.redhat.com/archives/libvir-list/2016-March/msg00993.html I'm putting them together as they touch the same piece of code and thus conflict with each other. The separation would happen at 11/20 "gconfig: Implement gvir_config_domain_graphics_spice_get_tls_port()" if I were to send these separately. Visarion's changes add support for configuring the <listen> node for the graphics node, and Fidencio's changes add some base classes to make generic configuration of local/remote graphics nodes easier, regardless of their type (VNC/SPICE for example). This incorporate the various changes I suggested during review, in particular it renames _set_listen_nodes() in the original series to just _set_listen(), better naming suggestions welcome. I've also added a few patches of my own which made sense to have for completeness. Christophe

From: Visarion Alexandru <viorel.visarion@gmail.com> We will need a GInetAddress for setting a graphics device's listen address, so let's include GIO2 in libvirt-gconfig. --- libvirt-gconfig-1.0.pc.in | 2 +- libvirt-gconfig/Makefile.am | 6 ++++-- vapi/Makefile.am | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libvirt-gconfig-1.0.pc.in b/libvirt-gconfig-1.0.pc.in index a8cb5ac..c0212f8 100644 --- a/libvirt-gconfig-1.0.pc.in +++ b/libvirt-gconfig-1.0.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@ Name: libvirt-gconfig Version: @VERSION@ Description: libvirt GConfig library -Requires: gobject-2.0 libxml-2.0 +Requires: gobject-2.0 libxml-2.0 gio-2.0 Libs: -L${libdir} -lvirt-gconfig-1.0 Cflags: -I${includedir}/libvirt-gconfig-1.0 diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 0400343..1a9a97a 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -209,10 +209,12 @@ libvirt_gconfig_1_0_la_CFLAGS = \ -I$(top_builddir) \ $(GOBJECT2_CFLAGS) \ $(LIBXML2_CFLAGS) \ + $(GIO2_CFLAGS) \ $(WARN_CFLAGS) libvirt_gconfig_1_0_la_LIBADD = \ $(GOBJECT2_LIBS) \ $(LIBXML2_LIBS) \ + $(GIO2_LIBS) \ $(CYGWIN_EXTRA_LIBADD) libvirt_gconfig_1_0_la_DEPENDENCIES = \ libvirt-gconfig.sym @@ -253,8 +255,8 @@ INTROSPECTION_GIRS = if HAVE_INTROSPECTION LibvirtGConfig-1.0.gir: libvirt-gconfig-1.0.la -LibvirtGConfig_1_0_gir_INCLUDES = GObject-2.0 -LibvirtGConfig_1_0_gir_PACKAGES = gobject-2.0 +LibvirtGConfig_1_0_gir_INCLUDES = GObject-2.0 Gio-2.0 +LibvirtGConfig_1_0_gir_PACKAGES = gobject-2.0 gio-2.0 LibvirtGConfig_1_0_gir_EXPORT_PACKAGES = libvirt-gconfig-1.0 LibvirtGConfig_1_0_gir_LIBS = libvirt-gconfig-1.0.la LibvirtGConfig_1_0_gir_FILES = \ diff --git a/vapi/Makefile.am b/vapi/Makefile.am index 568de4f..dc98bd1 100644 --- a/vapi/Makefile.am +++ b/vapi/Makefile.am @@ -33,6 +33,7 @@ libvirt-gconfig-1.0.vapi: $(top_builddir)/libvirt-gconfig/LibvirtGConfig-1.0.gir $(AM_V_GEN)$(VAPIGEN) \ --vapidir=$(builddir) \ --pkg gobject-2.0 \ + --pkg gio-2.0 \ --library libvirt-gconfig-1.0 \ $< -- 2.7.4

From: Visarion Alexandru <viorel.visarion@gmail.com> Abstract class which represents a listen child node of the graphics device. --- libvirt-gconfig/Makefile.am | 2 + .../libvirt-gconfig-domain-graphics-listen.c | 49 ++++++++++++++++ .../libvirt-gconfig-domain-graphics-listen.h | 65 ++++++++++++++++++++++ libvirt-gconfig/libvirt-gconfig.h | 1 + libvirt-gconfig/libvirt-gconfig.sym | 1 + 5 files changed, 118 insertions(+) create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.c create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 1a9a97a..ec26ae7 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -46,6 +46,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-domain-filesys.h \ libvirt-gconfig-domain-graphics.h \ libvirt-gconfig-domain-graphics-desktop.h \ + libvirt-gconfig-domain-graphics-listen.h \ libvirt-gconfig-domain-graphics-rdp.h \ libvirt-gconfig-domain-graphics-sdl.h \ libvirt-gconfig-domain-graphics-spice.h \ @@ -139,6 +140,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-filesys.c \ libvirt-gconfig-domain-graphics.c \ libvirt-gconfig-domain-graphics-desktop.c \ + libvirt-gconfig-domain-graphics-listen.c \ libvirt-gconfig-domain-graphics-rdp.c \ libvirt-gconfig-domain-graphics-sdl.c \ libvirt-gconfig-domain-graphics-spice.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.c new file mode 100644 index 0000000..095abe7 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.c @@ -0,0 +1,49 @@ +/* + * libvirt-gconfig-domain-graphics-listen.c: libvirt domain graphics listen base class + * + * Copyright (C) 2016 Red Hat, Inc. + * Copyright (C) 2016 Visarion Alexandru <viorel.visarion@gmail.com> + * + * 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: Visarion Alexandru <viorel.visarion@gmail.com> + */ + +#include <config.h> + +#include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-private.h" + +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN, GVirConfigDomainGraphicsListenPrivate)) + +struct _GVirConfigDomainGraphicsListenPrivate +{ + gboolean unused; +}; + +G_DEFINE_ABSTRACT_TYPE(GVirConfigDomainGraphicsListen, gvir_config_domain_graphics_listen, GVIR_CONFIG_TYPE_OBJECT); + + +static void gvir_config_domain_graphics_listen_class_init(GVirConfigDomainGraphicsListenClass *klass) +{ + g_type_class_add_private(klass, sizeof(GVirConfigDomainGraphicsListenPrivate)); +} + + +static void gvir_config_domain_graphics_listen_init(GVirConfigDomainGraphicsListen *listen) +{ + listen->priv = GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_GET_PRIVATE(listen); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.h new file mode 100644 index 0000000..6f93d27 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.h @@ -0,0 +1,65 @@ +/* + * libvirt-gconfig-domain-graphics-listen.h: libvirt domain graphics listen base class + * + * Copyright (C) 2016 Red Hat, Inc. + * Copyright (C) 2016 Visarion Alexandru <viorel.visarion@gmail.com> + * + * 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: Visarion Alexandru <viorel.visarion@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_DOMAIN_GRAPHICS_LISTEN_H__ +#define __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_LISTEN_H__ + +G_BEGIN_DECLS + +#define GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN (gvir_config_domain_graphics_listen_get_type ()) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN, GVirConfigDomainGraphicsListen)) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN, GVirConfigDomainGraphicsListenClass)) +#define GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN)) +#define GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN)) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN, GVirConfigDomainGraphicsListenClass)) + +typedef struct _GVirConfigDomainGraphicsListen GVirConfigDomainGraphicsListen; +typedef struct _GVirConfigDomainGraphicsListenPrivate GVirConfigDomainGraphicsListenPrivate; +typedef struct _GVirConfigDomainGraphicsListenClass GVirConfigDomainGraphicsListenClass; + +struct _GVirConfigDomainGraphicsListen +{ + GVirConfigObject parent; + + GVirConfigDomainGraphicsListenPrivate *priv; + + /* Do not add fields to this struct */ +}; + +struct _GVirConfigDomainGraphicsListenClass +{ + GVirConfigObjectClass parent_class; + + gpointer padding[20]; +}; + + +GType gvir_config_domain_graphics_listen_get_type(void); + +G_END_DECLS + +#endif /* __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_LISTEN_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h index 6462154..496986e 100644 --- a/libvirt-gconfig/libvirt-gconfig.h +++ b/libvirt-gconfig/libvirt-gconfig.h @@ -63,6 +63,7 @@ #include <libvirt-gconfig/libvirt-gconfig-domain-filesys.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.h> +#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 4ef4bf7..32d2c7b 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -741,6 +741,7 @@ global: gvir_config_domain_address_pci_get_multifunction; gvir_config_domain_address_pci_get_slot; + gvir_config_domain_graphics_listen_get_type; gvir_config_domain_graphics_spice_set_gl; gvir_config_domain_hostdev_get_boot_order; -- 2.7.4

From: Visarion Alexandru <viorel.visarion@gmail.com> This is needed to be able to change the address a graphics device is listening for. --- libvirt-gconfig/Makefile.am | 2 + ...ibvirt-gconfig-domain-graphics-listen-address.c | 131 +++++++++++++++++++++ ...ibvirt-gconfig-domain-graphics-listen-address.h | 79 +++++++++++++ libvirt-gconfig/libvirt-gconfig.h | 1 + libvirt-gconfig/libvirt-gconfig.sym | 7 ++ 5 files changed, 220 insertions(+) create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.c create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index ec26ae7..045f570 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -47,6 +47,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-domain-graphics.h \ libvirt-gconfig-domain-graphics-desktop.h \ libvirt-gconfig-domain-graphics-listen.h \ + libvirt-gconfig-domain-graphics-listen-address.h \ libvirt-gconfig-domain-graphics-rdp.h \ libvirt-gconfig-domain-graphics-sdl.h \ libvirt-gconfig-domain-graphics-spice.h \ @@ -141,6 +142,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-graphics.c \ libvirt-gconfig-domain-graphics-desktop.c \ libvirt-gconfig-domain-graphics-listen.c \ + libvirt-gconfig-domain-graphics-listen-address.c \ libvirt-gconfig-domain-graphics-rdp.c \ libvirt-gconfig-domain-graphics-sdl.c \ libvirt-gconfig-domain-graphics-spice.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.c new file mode 100644 index 0000000..2489327 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.c @@ -0,0 +1,131 @@ +/* + * libvirt-gconfig-domain-graphics-listen-address.c: libvirt domain graphics listen address configuration + * + * Copyright (C) 2016 Red Hat, Inc. + * Copyright (C) 2016 Visarion Alexandru <viorel.visarion@gmail.com> + * + * 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: Visarion Alexandru <viorel.visarion@gmail.com> + */ + +#include <config.h> + +#include <gio/gio.h> + +#include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-private.h" + +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_ADDRESS_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_ADDRESS, GVirConfigDomainGraphicsListenAddressPrivate)) + +struct _GVirConfigDomainGraphicsListenAddressPrivate +{ + gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigDomainGraphicsListenAddress, gvir_config_domain_graphics_listen_address, GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN); + + +static void gvir_config_domain_graphics_listen_address_class_init(GVirConfigDomainGraphicsListenAddressClass *klass) +{ + g_type_class_add_private(klass, sizeof(GVirConfigDomainGraphicsListenAddressPrivate)); +} + + +static void gvir_config_domain_graphics_listen_address_init(GVirConfigDomainGraphicsListenAddress *address) +{ + address->priv = GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_ADDRESS_GET_PRIVATE(address); +} + + +GVirConfigDomainGraphicsListenAddress *gvir_config_domain_graphics_listen_address_new(void) +{ + GVirConfigObject *object; + + object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_ADDRESS, "listen", NULL); + gvir_config_object_set_attribute(object, + "type", "address", + NULL); + + return GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_ADDRESS(object); +} + + +GVirConfigDomainGraphicsListenAddress *gvir_config_domain_graphics_listen_address_new_from_xml(const gchar *xml, + GError **error) +{ + GVirConfigObject *object; + + object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_ADDRESS, + "listen", NULL, xml, error); + if (g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "address") != 0) { + g_object_unref(G_OBJECT(object)); + g_return_val_if_reached(NULL); + } + return GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_ADDRESS(object); +} + +void gvir_config_domain_graphics_listen_address_set_address(GVirConfigDomainGraphicsListenAddress *listen, + const gchar *address) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN_ADDRESS(listen)); + + gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(listen), + "address", address, + NULL); +} + +const gchar * +gvir_config_domain_graphics_listen_address_get_address(GVirConfigDomainGraphicsListenAddress *listen) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN_ADDRESS(listen), NULL); + + return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(listen), + NULL, + "address"); +} + +void gvir_config_domain_graphics_listen_address_set_inet_address(GVirConfigDomainGraphicsListenAddress *listen, + GInetAddress *address) +{ + char *address_str; + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN_ADDRESS(listen)); + + address_str = g_inet_address_to_string(address); + gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(listen), + "address", address_str, + NULL); + g_free(address_str); +} + +/** + * gvir_config_domain_graphics_listen_address_get_inet_address: + * + * Returns the #GInetAddress associated with the #GVirConfigDomainGraphicsListenAddress. + * + * Returns: (transfer full): a #GInetAddress. + * + */ +GInetAddress * +gvir_config_domain_graphics_listen_address_get_inet_address(GVirConfigDomainGraphicsListenAddress *listen) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN_ADDRESS(listen), NULL); + + const gchar *address = gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(listen), + NULL, + "address"); + return g_inet_address_new_from_string(address); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.h new file mode 100644 index 0000000..091aced --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.h @@ -0,0 +1,79 @@ +/* + * libvirt-gconfig-domain-graphics-listen-address.h: libvirt domain graphics listen address configuration + * + * Copyright (C) 2016 Red Hat, Inc. + * Copyright (C) 2016 Visarion Alexandru <viorel.visarion@gmail.com> + * + * 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: Visarion Alexandru <viorel.visarion@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_DOMAIN_GRAPHICS_LISTEN_ADDRESS_H__ +#define __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_LISTEN_ADDRESS_H__ + +#include <gio/gio.h> + +G_BEGIN_DECLS + +#define GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_ADDRESS (gvir_config_domain_graphics_listen_address_get_type ()) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_ADDRESS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_ADDRESS, GVirConfigDomainGraphicsListenAddress)) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_ADDRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_ADDRESS, GVirConfigDomainGraphicsListenAddressClass)) +#define GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN_ADDRESS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_ADDRESS)) +#define GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN_ADDRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_ADDRESS)) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_ADDRESS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_ADDRESS, GVirConfigDomainGraphicsListenAddressClass)) + +typedef struct _GVirConfigDomainGraphicsListenAddress GVirConfigDomainGraphicsListenAddress; +typedef struct _GVirConfigDomainGraphicsListenAddressPrivate GVirConfigDomainGraphicsListenAddressPrivate; +typedef struct _GVirConfigDomainGraphicsListenAddressClass GVirConfigDomainGraphicsListenAddressClass; + +struct _GVirConfigDomainGraphicsListenAddress +{ + GVirConfigDomainGraphicsListen parent; + + GVirConfigDomainGraphicsListenAddressPrivate *priv; + + /* Do not add fields to this struct */ +}; + +struct _GVirConfigDomainGraphicsListenAddressClass +{ + GVirConfigDomainGraphicsListenClass parent_class; + + gpointer padding[20]; +}; + + +GType gvir_config_domain_graphics_listen_address_get_type(void); + +GVirConfigDomainGraphicsListenAddress *gvir_config_domain_graphics_listen_address_new(void); +GVirConfigDomainGraphicsListenAddress *gvir_config_domain_graphics_listen_address_new_from_xml(const gchar *xml, + GError **error); + +void gvir_config_domain_graphics_listen_address_set_address(GVirConfigDomainGraphicsListenAddress *listen, + const gchar *address); +const gchar *gvir_config_domain_graphics_listen_address_get_address(GVirConfigDomainGraphicsListenAddress *listen); + +void gvir_config_domain_graphics_listen_address_set_inet_address(GVirConfigDomainGraphicsListenAddress *listen, + GInetAddress *address); +GInetAddress *gvir_config_domain_graphics_listen_address_get_inet_address(GVirConfigDomainGraphicsListenAddress *listen); + +G_END_DECLS + +#endif /* __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_LISTEN_ADDRESS_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h index 496986e..6132bc1 100644 --- a/libvirt-gconfig/libvirt-gconfig.h +++ b/libvirt-gconfig/libvirt-gconfig.h @@ -64,6 +64,7 @@ #include <libvirt-gconfig/libvirt-gconfig-domain-graphics.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.h> +#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 32d2c7b..364d8ff 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -741,6 +741,13 @@ global: gvir_config_domain_address_pci_get_multifunction; gvir_config_domain_address_pci_get_slot; + gvir_config_domain_graphics_listen_address_get_address; + gvir_config_domain_graphics_listen_address_get_inet_address; + gvir_config_domain_graphics_listen_address_get_type; + gvir_config_domain_graphics_listen_address_new; + gvir_config_domain_graphics_listen_address_new_from_xml; + gvir_config_domain_graphics_listen_address_set_address; + gvir_config_domain_graphics_listen_address_set_inet_address; gvir_config_domain_graphics_listen_get_type; gvir_config_domain_graphics_spice_set_gl; -- 2.7.4

On Tue, Oct 04, 2016 at 05:23:41PM +0200, Christophe Fergeau wrote:
From: Visarion Alexandru <viorel.visarion@gmail.com>
This is needed to be able to change the address a graphics device is listening for. --- libvirt-gconfig/Makefile.am | 2 + ...ibvirt-gconfig-domain-graphics-listen-address.c | 131 +++++++++++++++++++++ ...ibvirt-gconfig-domain-graphics-listen-address.h | 79 +++++++++++++ libvirt-gconfig/libvirt-gconfig.h | 1 + libvirt-gconfig/libvirt-gconfig.sym | 7 ++ 5 files changed, 220 insertions(+) create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.c create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.h
+void gvir_config_domain_graphics_listen_address_set_address(GVirConfigDomainGraphicsListenAddress *listen, + const gchar *address) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN_ADDRESS(listen)); + + gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(listen), + "address", address, + NULL); +} + +const gchar * +gvir_config_domain_graphics_listen_address_get_address(GVirConfigDomainGraphicsListenAddress *listen) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN_ADDRESS(listen), NULL); + + return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(listen), + NULL, + "address"); +} + +void gvir_config_domain_graphics_listen_address_set_inet_address(GVirConfigDomainGraphicsListenAddress *listen, + GInetAddress *address) +{ + char *address_str; + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN_ADDRESS(listen)); + + address_str = g_inet_address_to_string(address); + gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(listen), + "address", address_str, + NULL); + g_free(address_str); +} + +/** + * gvir_config_domain_graphics_listen_address_get_inet_address: + * + * Returns the #GInetAddress associated with the #GVirConfigDomainGraphicsListenAddress. + * + * Returns: (transfer full): a #GInetAddress. + * + */ +GInetAddress * +gvir_config_domain_graphics_listen_address_get_inet_address(GVirConfigDomainGraphicsListenAddress *listen) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN_ADDRESS(listen), NULL); + + const gchar *address = gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(listen), + NULL, + "address"); + return g_inet_address_new_from_string(address); +}
IIUC GInetAddress only supports numeric IP addresses, where as libvirt also allows hostnames anywhere that an IP address is used. So apps using get_inet_address are liable to get NULL returned if we use GInetAddress. So IMHO we should not use GInetAddress as it'd lead to apps which blindly use this API not realising they'll break if someone put a hostname in the XML until it is too late. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|

hey, On Tue, Oct 04, 2016 at 04:30:14PM +0100, Daniel P. Berrange wrote:
+ +/** + * gvir_config_domain_graphics_listen_address_get_inet_address: + * + * Returns the #GInetAddress associated with the #GVirConfigDomainGraphicsListenAddress. + * + * Returns: (transfer full): a #GInetAddress. + * + */ +GInetAddress * +gvir_config_domain_graphics_listen_address_get_inet_address(GVirConfigDomainGraphicsListenAddress *listen) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN_ADDRESS(listen), NULL); + + const gchar *address = gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(listen), + NULL, + "address"); + return g_inet_address_new_from_string(address); +}
IIUC GInetAddress only supports numeric IP addresses, where as libvirt also allows hostnames anywhere that an IP address is used. So apps using get_inet_address are liable to get NULL returned if we use GInetAddress.
So IMHO we should not use GInetAddress as it'd lead to apps which blindly use this API not realising they'll break if someone put a hostname in the XML until it is too late.
Good point. Should we keep _set_inet_address() which would limit what we can set, but would not lead to unexpected results depending on the XML content, or should we just drop the GInetAddress altogether, and only keep the string based API (which is what Visarion initially proposed). Christophe

On Wed, Oct 05, 2016 at 09:37:52AM +0200, Christophe Fergeau wrote:
hey,
On Tue, Oct 04, 2016 at 04:30:14PM +0100, Daniel P. Berrange wrote:
+ +/** + * gvir_config_domain_graphics_listen_address_get_inet_address: + * + * Returns the #GInetAddress associated with the #GVirConfigDomainGraphicsListenAddress. + * + * Returns: (transfer full): a #GInetAddress. + * + */ +GInetAddress * +gvir_config_domain_graphics_listen_address_get_inet_address(GVirConfigDomainGraphicsListenAddress *listen) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN_ADDRESS(listen), NULL); + + const gchar *address = gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(listen), + NULL, + "address"); + return g_inet_address_new_from_string(address); +}
IIUC GInetAddress only supports numeric IP addresses, where as libvirt also allows hostnames anywhere that an IP address is used. So apps using get_inet_address are liable to get NULL returned if we use GInetAddress.
So IMHO we should not use GInetAddress as it'd lead to apps which blindly use this API not realising they'll break if someone put a hostname in the XML until it is too late.
Good point. Should we keep _set_inet_address() which would limit what we can set, but would not lead to unexpected results depending on the XML content, or should we just drop the GInetAddress altogether, and only keep the string based API (which is what Visarion initially proposed).
I think I'd just drop GInetAddress completely to avoid confusion. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|

From: Visarion Alexandru <viorel.visarion@gmail.com> Learn to get/set the listen devices that vnc is using. When setting the listen devices, first remove the 'listen' attribute to avoid inconsistencies checks between the 'listen' attribute and the 'address' attribute of the 'listen' node. --- .../libvirt-gconfig-domain-graphics-vnc.c | 87 +++++++++++++++++++++- .../libvirt-gconfig-domain-graphics-vnc.h | 4 + libvirt-gconfig/libvirt-gconfig.sym | 2 + 3 files changed, 92 insertions(+), 1 deletion(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c index fc26bb9..bc229bd 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c @@ -1,7 +1,8 @@ /* * libvirt-gconfig-domain-graphics-vnc.c: libvirt domain VNC configuration * - * Copyright (C) 2011 Red Hat, Inc. + * Copyright (C) 2011-16 Red Hat, Inc. + * Copyright (C) 2016 Visarion Alexandru <viorel.visarion@gmail.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -120,6 +121,90 @@ void gvir_config_domain_graphics_vnc_set_port(GVirConfigDomainGraphicsVnc *graph NULL); } +/** + * gvir_config_domain_graphics_vnc_set_listen: + * @graphics: a #GVirConfigDomainGraphicsVnc + * @listens: (in) (element-type LibvirtGConfig.DomainGraphicsListen): + * + * This method is used to set the various listen nodes a #GVirConfigDomainGraphicsVnc + * device can handle. +*/ +void gvir_config_domain_graphics_vnc_set_listen(GVirConfigDomainGraphicsVnc *graphics, + GList *listens) +{ + GList *it; + + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics)); + + gvir_config_object_remove_attribute (GVIR_CONFIG_OBJECT(graphics), + "listen"); + gvir_config_object_delete_children (GVIR_CONFIG_OBJECT (graphics), + "listen", NULL); + + for (it = listens; it != NULL; it = it->next) { + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN(it->data)); + + gvir_config_object_attach_add(GVIR_CONFIG_OBJECT(graphics), + GVIR_CONFIG_OBJECT(it->data)); + } +} + +struct ListenData { + GVirConfigXmlDoc *doc; + const gchar *schema; + GList *listen_devices; +}; + +static gboolean add_listen(xmlNodePtr node, gpointer opaque) +{ + struct ListenData* data = (struct ListenData*)opaque; + GVirConfigObject *object; + + if (g_strcmp0((const gchar *)node->name, "listen") != 0) + return TRUE; + + object = gvir_config_object_new_from_tree + (GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_ADDRESS, + data->doc, + data->schema, + node); + if (object != NULL) + data->listen_devices = g_list_append(data->listen_devices, object); + else + g_debug("Failed to parse %s node", node->name); + + return TRUE; +} + +/** + * gvir_config_domain_graphics_vnc_get_listen: + * + * Gets all the listen not of #GVirConfigDomainGraphicsVnc + * + * Returns: (element-type LibvirtGConfig.DomainGraphicsListen) (transfer full): + * a newly allocated #GList of #GVirConfigDomainGraphicsListen. + */ +GList * +gvir_config_domain_graphics_vnc_get_listen(GVirConfigDomainGraphicsVnc *graphics) +{ + struct ListenData data; + + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics), NULL); + + g_object_get(G_OBJECT(graphics), "doc", &data.doc, NULL); + g_return_val_if_fail(data.doc != NULL, NULL); + data.schema = gvir_config_object_get_schema(GVIR_CONFIG_OBJECT(graphics)); + data.listen_devices = NULL; + + gvir_config_object_foreach_child(GVIR_CONFIG_OBJECT(graphics), + NULL, + add_listen, + &data); + g_clear_object(&data.doc); + + return data.listen_devices; +} + void gvir_config_domain_graphics_vnc_set_password(GVirConfigDomainGraphicsVnc *graphics, const char *password) { diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h index fe78621..df21bd6 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h @@ -73,6 +73,10 @@ int gvir_config_domain_graphics_vnc_get_port(GVirConfigDomainGraphicsVnc *graphi void gvir_config_domain_graphics_vnc_set_port(GVirConfigDomainGraphicsVnc *graphics, int port); +void gvir_config_domain_graphics_vnc_set_listen(GVirConfigDomainGraphicsVnc *graphics, + GList *listens); +GList *gvir_config_domain_graphics_vnc_get_listen(GVirConfigDomainGraphicsVnc *graphics); + void gvir_config_domain_graphics_vnc_set_password(GVirConfigDomainGraphicsVnc *graphics, const char *password); diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 364d8ff..6898597 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -750,6 +750,8 @@ global: gvir_config_domain_graphics_listen_address_set_inet_address; gvir_config_domain_graphics_listen_get_type; gvir_config_domain_graphics_spice_set_gl; + gvir_config_domain_graphics_vnc_get_listen; + gvir_config_domain_graphics_vnc_set_listen; gvir_config_domain_hostdev_get_boot_order; gvir_config_domain_hostdev_get_readonly; -- 2.7.4

From: Visarion Alexandru <viorel.visarion@gmail.com> Learn to get/set the listen devices that spice graphics is using. When setting the listen devices, first remove the 'listen' attribute to avoid the inconsistencies checks between the 'listen' attribute and the 'address' attribute of the 'listen' node. --- .../libvirt-gconfig-domain-graphics-spice.c | 87 +++++++++++++++++++++- .../libvirt-gconfig-domain-graphics-spice.h | 4 + libvirt-gconfig/libvirt-gconfig.sym | 2 + 3 files changed, 92 insertions(+), 1 deletion(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c index 079ea27..7e0bd9f 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c @@ -1,7 +1,8 @@ /* * libvirt-gconfig-domain-graphics-spice.c: libvirt domain SPICE configuration * - * Copyright (C) 2011 Red Hat, Inc. + * Copyright (C) 2011-2016 Red Hat, Inc. + * Copyright (C) 2016 Visarion Alexandru <viorel.visarion@gmail.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -157,6 +158,90 @@ void gvir_config_domain_graphics_spice_set_image_compression compression); } +/** + * gvir_config_domain_graphics_spice_set_listen: + * @graphics: a #GVirConfigDomainGraphicsSpice + * @listens: (in) (element-type LibvirtGConfig.DomainGraphicsListen): listens + * + * This method is used to set the various listen nodes a #GVirConfigDomainGraphicsSpice + * device can handle. +*/ +void gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice *graphics, + GList *listens) +{ + GList *it; + + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics)); + + gvir_config_object_remove_attribute (GVIR_CONFIG_OBJECT(graphics), + "listen"); + gvir_config_object_delete_children (GVIR_CONFIG_OBJECT (graphics), + "listen", NULL); + + for (it = listens; it != NULL; it = it->next) { + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN(it->data)); + + gvir_config_object_attach_add(GVIR_CONFIG_OBJECT(graphics), + GVIR_CONFIG_OBJECT(it->data)); + } +} + +struct ListenData { + GVirConfigXmlDoc *doc; + const gchar *schema; + GList *listen_devices; +}; + +static gboolean add_listen(xmlNodePtr node, gpointer opaque) +{ + struct ListenData* data = (struct ListenData*)opaque; + GVirConfigObject *object; + + if (g_strcmp0((const gchar *)node->name, "listen") != 0) + return TRUE; + + object = gvir_config_object_new_from_tree + (GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_ADDRESS, + data->doc, + data->schema, + node); + if (object != NULL) + data->listen_devices = g_list_append(data->listen_devices, object); + else + g_debug("Failed to parse %s node", node->name); + + return TRUE; +} + +/** + * gvir_config_domain_graphics_spice_get_listen: + * + * Gets all the listen not of #GVirConfigDomainGraphicsSpice + * + * Returns: (element-type LibvirtGConfig.DomainGraphicsListen) (transfer full): + * a newly allocated #GList of #GVirConfigDomainGraphicsListen. + */ +GList * +gvir_config_domain_graphics_spice_get_listen(GVirConfigDomainGraphicsSpice *graphics) +{ + struct ListenData data; + + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics), NULL); + + g_object_get(G_OBJECT(graphics), "doc", &data.doc, NULL); + g_return_val_if_fail(data.doc != NULL, NULL); + data.schema = gvir_config_object_get_schema(GVIR_CONFIG_OBJECT(graphics)); + data.listen_devices = NULL; + + gvir_config_object_foreach_child(GVIR_CONFIG_OBJECT(graphics), + NULL, + add_listen, + &data); + g_clear_object(&data.doc); + + return data.listen_devices; +} + void gvir_config_domain_graphics_spice_set_gl(GVirConfigDomainGraphicsSpice *graphics, gboolean gl) { diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h index 25c132e..1632cc9 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h @@ -95,6 +95,10 @@ gvir_config_domain_graphics_spice_get_image_compression void gvir_config_domain_graphics_spice_set_gl(GVirConfigDomainGraphicsSpice *graphics, gboolean gl); +void gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice *graphics, + GList *listens); +GList *gvir_config_domain_graphics_spice_get_listen(GVirConfigDomainGraphicsSpice *graphics); + G_END_DECLS #endif /* __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_SPICE_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 6898597..6d8be60 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -749,7 +749,9 @@ global: gvir_config_domain_graphics_listen_address_set_address; gvir_config_domain_graphics_listen_address_set_inet_address; gvir_config_domain_graphics_listen_get_type; + gvir_config_domain_graphics_spice_get_listen; gvir_config_domain_graphics_spice_set_gl; + gvir_config_domain_graphics_spice_set_listen; gvir_config_domain_graphics_vnc_get_listen; gvir_config_domain_graphics_vnc_set_listen; -- 2.7.4

From: Visarion Alexandru <viorel.visarion@gmail.com> --- tests/test-gconfig.c | 39 ++++++++++++++++++++++ .../xml/gconfig-domain-device-graphics-listen.xml | 7 ++++ 2 files changed, 46 insertions(+) create mode 100644 tests/xml/gconfig-domain-device-graphics-listen.xml diff --git a/tests/test-gconfig.c b/tests/test-gconfig.c index a26bb5f..97275a1 100644 --- a/tests/test-gconfig.c +++ b/tests/test-gconfig.c @@ -481,6 +481,43 @@ static void test_domain_device_graphics(void) g_object_unref(G_OBJECT(domain)); } +static void test_domain_device_graphics_listen(void) +{ + GVirConfigDomain *domain; + GVirConfigDomainGraphicsSpice *graphics = NULL; + + domain = gvir_config_domain_new(); + GList *listen_list = NULL; + + graphics = gvir_config_domain_graphics_spice_new(); + + /* listen address node */ + GVirConfigDomainGraphicsListenAddress *address_listen = gvir_config_domain_graphics_listen_address_new(); + GInetAddress *inet_address = g_inet_address_new_from_string("0.0.0.0"); + + gvir_config_domain_graphics_listen_address_set_inet_address(address_listen, inet_address); + GInetAddress *ret_inet_address = gvir_config_domain_graphics_listen_address_get_inet_address(address_listen); + g_assert(g_inet_address_equal(inet_address, ret_inet_address)); + g_object_unref(inet_address); + g_object_unref(ret_inet_address); + + gvir_config_domain_graphics_listen_address_set_address(address_listen, "127.0.0.1"); + const gchar *ret_address = gvir_config_domain_graphics_listen_address_get_address(address_listen); + g_assert_cmpstr("127.0.0.1", ==, ret_address); + + /* test listen setter */ + listen_list = g_list_append(listen_list, address_listen); + gvir_config_domain_graphics_spice_set_listen(graphics, listen_list); + g_object_unref(G_OBJECT(address_listen)); + g_list_free(listen_list); + + gvir_config_domain_add_device(domain, GVIR_CONFIG_DOMAIN_DEVICE(graphics)); + g_object_unref(G_OBJECT(graphics)); + + check_xml(domain, "gconfig-domain-device-graphics-listen.xml"); + + g_object_unref(G_OBJECT(domain)); +} static void test_domain_device_video(void) { @@ -782,6 +819,8 @@ int main(int argc, char **argv) test_domain_device_usb_redir); g_test_add_func("/libvirt-gconfig/domain-device-pci-hostdev", test_domain_device_pci_hostdev); + g_test_add_func("/libvirt-gconfig/domain-device-graphics-listen", + test_domain_device_graphics_listen); return g_test_run(); } diff --git a/tests/xml/gconfig-domain-device-graphics-listen.xml b/tests/xml/gconfig-domain-device-graphics-listen.xml new file mode 100644 index 0000000..27200c4 --- /dev/null +++ b/tests/xml/gconfig-domain-device-graphics-listen.xml @@ -0,0 +1,7 @@ +<domain> + <devices> + <graphics type="spice"> + <listen type="address" address="127.0.0.1"/> + </graphics> + </devices> +</domain> -- 2.7.4

--- libvirt-gconfig/Makefile.am | 2 + .../libvirt-gconfig-domain-graphics-listen-none.c | 78 ++++++++++++++++++++++ .../libvirt-gconfig-domain-graphics-listen-none.h | 70 +++++++++++++++++++ libvirt-gconfig/libvirt-gconfig.h | 1 + libvirt-gconfig/libvirt-gconfig.sym | 3 + 5 files changed, 154 insertions(+) create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-none.c create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-none.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 045f570..bdeac32 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -48,6 +48,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-domain-graphics-desktop.h \ libvirt-gconfig-domain-graphics-listen.h \ libvirt-gconfig-domain-graphics-listen-address.h \ + libvirt-gconfig-domain-graphics-listen-none.h \ libvirt-gconfig-domain-graphics-rdp.h \ libvirt-gconfig-domain-graphics-sdl.h \ libvirt-gconfig-domain-graphics-spice.h \ @@ -143,6 +144,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-graphics-desktop.c \ libvirt-gconfig-domain-graphics-listen.c \ libvirt-gconfig-domain-graphics-listen-address.c \ + libvirt-gconfig-domain-graphics-listen-none.c \ libvirt-gconfig-domain-graphics-rdp.c \ libvirt-gconfig-domain-graphics-sdl.c \ libvirt-gconfig-domain-graphics-spice.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-none.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-none.c new file mode 100644 index 0000000..a9d8a7a --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-none.c @@ -0,0 +1,78 @@ +/* + * libvirt-gconfig-domain-graphics-listen-none.c: libvirt domain graphics listen none configuration + * + * Copyright (C) 2016 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 <gio/gio.h> + +#include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-private.h" + +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_NONE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_NONE, GVirConfigDomainGraphicsListenNonePrivate)) + +struct _GVirConfigDomainGraphicsListenNonePrivate +{ + gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigDomainGraphicsListenNone, gvir_config_domain_graphics_listen_none, GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN); + + +static void gvir_config_domain_graphics_listen_none_class_init(GVirConfigDomainGraphicsListenNoneClass *klass) +{ + g_type_class_add_private(klass, sizeof(GVirConfigDomainGraphicsListenNonePrivate)); +} + + +static void gvir_config_domain_graphics_listen_none_init(GVirConfigDomainGraphicsListenNone *listen) +{ + listen->priv = GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_NONE_GET_PRIVATE(listen); +} + + +GVirConfigDomainGraphicsListenNone *gvir_config_domain_graphics_listen_none_new(void) +{ + GVirConfigObject *object; + + object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_NONE, "listen", NULL); + gvir_config_object_set_attribute(object, + "type", "none", + NULL); + + return GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_NONE(object); +} + + +GVirConfigDomainGraphicsListenNone *gvir_config_domain_graphics_listen_none_new_from_xml(const gchar *xml, + GError **error) +{ + GVirConfigObject *object; + + object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_NONE, + "listen", NULL, xml, error); + if (g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "none") != 0) { + g_object_unref(G_OBJECT(object)); + g_return_val_if_reached(NULL); + } + return GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_NONE(object); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-none.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-none.h new file mode 100644 index 0000000..d912c1e --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-none.h @@ -0,0 +1,70 @@ +/* + * libvirt-gconfig-domain-graphics-listen-none.h: libvirt domain graphics listen none configuration + * + * Copyright (C) 2016 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_GRAPHICS_LISTEN_NONE_H__ +#define __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_LISTEN_NONE_H__ + +#include <gio/gio.h> + +G_BEGIN_DECLS + +#define GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_NONE (gvir_config_domain_graphics_listen_none_get_type ()) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_NONE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_NONE, GVirConfigDomainGraphicsListenNone)) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_NONE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_NONE, GVirConfigDomainGraphicsListenNoneClass)) +#define GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN_NONE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_NONE)) +#define GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN_NONE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_NONE)) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_NONE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_NONE, GVirConfigDomainGraphicsListenNoneClass)) + +typedef struct _GVirConfigDomainGraphicsListenNone GVirConfigDomainGraphicsListenNone; +typedef struct _GVirConfigDomainGraphicsListenNonePrivate GVirConfigDomainGraphicsListenNonePrivate; +typedef struct _GVirConfigDomainGraphicsListenNoneClass GVirConfigDomainGraphicsListenNoneClass; + +struct _GVirConfigDomainGraphicsListenNone +{ + GVirConfigDomainGraphicsListen parent; + + GVirConfigDomainGraphicsListenNonePrivate *priv; + + /* Do not add fields to this struct */ +}; + +struct _GVirConfigDomainGraphicsListenNoneClass +{ + GVirConfigDomainGraphicsListenClass parent_class; + + gpointer padding[20]; +}; + + +GType gvir_config_domain_graphics_listen_none_get_type(void); + +GVirConfigDomainGraphicsListenNone *gvir_config_domain_graphics_listen_none_new(void); +GVirConfigDomainGraphicsListenNone *gvir_config_domain_graphics_listen_none_new_from_xml(const gchar *xml, + GError **error); + +G_END_DECLS + +#endif /* __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_LISTEN_NONE_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h index 6132bc1..cd9d54e 100644 --- a/libvirt-gconfig/libvirt-gconfig.h +++ b/libvirt-gconfig/libvirt-gconfig.h @@ -65,6 +65,7 @@ #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.h> +#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-none.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 6d8be60..a20c209 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -749,6 +749,9 @@ global: gvir_config_domain_graphics_listen_address_set_address; gvir_config_domain_graphics_listen_address_set_inet_address; gvir_config_domain_graphics_listen_get_type; + gvir_config_domain_graphics_listen_none_get_type; + gvir_config_domain_graphics_listen_none_new; + gvir_config_domain_graphics_listen_none_new_from_xml; gvir_config_domain_graphics_spice_get_listen; gvir_config_domain_graphics_spice_set_gl; gvir_config_domain_graphics_spice_set_listen; -- 2.7.4

--- libvirt-gconfig/Makefile.am | 2 + .../libvirt-gconfig-domain-graphics-listen-unix.c | 98 ++++++++++++++++++++++ .../libvirt-gconfig-domain-graphics-listen-unix.h | 72 ++++++++++++++++ libvirt-gconfig/libvirt-gconfig.h | 1 + libvirt-gconfig/libvirt-gconfig.sym | 5 ++ 5 files changed, 178 insertions(+) create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-unix.c create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-unix.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index bdeac32..ba08a11 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -49,6 +49,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-domain-graphics-listen.h \ libvirt-gconfig-domain-graphics-listen-address.h \ libvirt-gconfig-domain-graphics-listen-none.h \ + libvirt-gconfig-domain-graphics-listen-unix.h \ libvirt-gconfig-domain-graphics-rdp.h \ libvirt-gconfig-domain-graphics-sdl.h \ libvirt-gconfig-domain-graphics-spice.h \ @@ -145,6 +146,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-graphics-listen.c \ libvirt-gconfig-domain-graphics-listen-address.c \ libvirt-gconfig-domain-graphics-listen-none.c \ + libvirt-gconfig-domain-graphics-listen-unix.c \ libvirt-gconfig-domain-graphics-rdp.c \ libvirt-gconfig-domain-graphics-sdl.c \ libvirt-gconfig-domain-graphics-spice.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-unix.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-unix.c new file mode 100644 index 0000000..b16f52f --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-unix.c @@ -0,0 +1,98 @@ +/* + * libvirt-gconfig-domain-graphics-listen-unix.c: libvirt domain graphics listen unix socket configuration + * + * Copyright (C) 2016 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 <gio/gio.h> + +#include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-private.h" + +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_UNIX_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_UNIX, GVirConfigDomainGraphicsListenUnixPrivate)) + +struct _GVirConfigDomainGraphicsListenUnixPrivate +{ + gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigDomainGraphicsListenUnix, gvir_config_domain_graphics_listen_unix, GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN); + + +static void gvir_config_domain_graphics_listen_unix_class_init(GVirConfigDomainGraphicsListenUnixClass *klass) +{ + g_type_class_add_private(klass, sizeof(GVirConfigDomainGraphicsListenUnixPrivate)); +} + + +static void gvir_config_domain_graphics_listen_unix_init(GVirConfigDomainGraphicsListenUnix *listen) +{ + listen->priv = GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_UNIX_GET_PRIVATE(listen); +} + + +GVirConfigDomainGraphicsListenUnix *gvir_config_domain_graphics_listen_unix_new(void) +{ + GVirConfigObject *object; + + object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_UNIX, "listen", NULL); + gvir_config_object_set_attribute(object, + "type", "socket", + NULL); + + return GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_UNIX(object); +} + + +GVirConfigDomainGraphicsListenUnix *gvir_config_domain_graphics_listen_unix_new_from_xml(const gchar *xml, + GError **error) +{ + GVirConfigObject *object; + + object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_UNIX, + "listen", NULL, xml, error); + if (g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "socket") != 0) { + g_object_unref(G_OBJECT(object)); + g_return_val_if_reached(NULL); + } + return GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_UNIX(object); +} + +void gvir_config_domain_graphics_listen_unix_set_path(GVirConfigDomainGraphicsListenUnix *listen, + const gchar *path) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN_UNIX(listen)); + + gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(listen), + "socket", path, + NULL); +} + +const gchar * +gvir_config_domain_graphics_listen_unix_get_path(GVirConfigDomainGraphicsListenUnix *listen) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN_UNIX(listen), NULL); + + return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(listen), + NULL, + "socket"); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-unix.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-unix.h new file mode 100644 index 0000000..9c91679 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-unix.h @@ -0,0 +1,72 @@ +/* + * libvirt-gconfig-domain-graphics-listen-unix.h: libvirt domain graphics listen unix socket configuration + * + * Copyright (C) 2016 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_GRAPHICS_LISTEN_UNIX_H__ +#define __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_LISTEN_UNIX_H__ + +#include <gio/gio.h> + +G_BEGIN_DECLS + +#define GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_UNIX (gvir_config_domain_graphics_listen_unix_get_type ()) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_UNIX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_UNIX, GVirConfigDomainGraphicsListenUnix)) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_UNIX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_UNIX, GVirConfigDomainGraphicsListenUnixClass)) +#define GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN_UNIX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_UNIX)) +#define GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN_UNIX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_UNIX)) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_UNIX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_UNIX, GVirConfigDomainGraphicsListenUnixClass)) + +typedef struct _GVirConfigDomainGraphicsListenUnix GVirConfigDomainGraphicsListenUnix; +typedef struct _GVirConfigDomainGraphicsListenUnixPrivate GVirConfigDomainGraphicsListenUnixPrivate; +typedef struct _GVirConfigDomainGraphicsListenUnixClass GVirConfigDomainGraphicsListenUnixClass; + +struct _GVirConfigDomainGraphicsListenUnix +{ + GVirConfigDomainGraphicsListen parent; + + GVirConfigDomainGraphicsListenUnixPrivate *priv; + + /* Do not add fields to this struct */ +}; + +struct _GVirConfigDomainGraphicsListenUnixClass +{ + GVirConfigDomainGraphicsListenClass parent_class; + + gpointer padding[20]; +}; + + +GType gvir_config_domain_graphics_listen_unix_get_type(void); + +GVirConfigDomainGraphicsListenUnix *gvir_config_domain_graphics_listen_unix_new(void); +GVirConfigDomainGraphicsListenUnix *gvir_config_domain_graphics_listen_unix_new_from_xml(const gchar *xml, + GError **error); + +void gvir_config_domain_graphics_listen_unix_set_path(GVirConfigDomainGraphicsListenUnix *listen, + const gchar *path); +const gchar *gvir_config_domain_graphics_listen_unix_get_path(GVirConfigDomainGraphicsListenUnix *listen); + +#endif /* __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_LISTEN_UNIX_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h index cd9d54e..45d3839 100644 --- a/libvirt-gconfig/libvirt-gconfig.h +++ b/libvirt-gconfig/libvirt-gconfig.h @@ -66,6 +66,7 @@ #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-none.h> +#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-unix.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index a20c209..c07de56 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -752,6 +752,11 @@ global: gvir_config_domain_graphics_listen_none_get_type; gvir_config_domain_graphics_listen_none_new; gvir_config_domain_graphics_listen_none_new_from_xml; + gvir_config_domain_graphics_listen_unix_get_path; + gvir_config_domain_graphics_listen_unix_get_type; + gvir_config_domain_graphics_listen_unix_new; + gvir_config_domain_graphics_listen_unix_new_from_xml; + gvir_config_domain_graphics_listen_unix_set_path; gvir_config_domain_graphics_spice_get_listen; gvir_config_domain_graphics_spice_set_gl; gvir_config_domain_graphics_spice_set_listen; -- 2.7.4

--- libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c | 17 +++++++++++++++++ libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h | 2 ++ libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c | 17 +++++++++++++++++ libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h | 2 ++ libvirt-gconfig/libvirt-gconfig.sym | 2 ++ tests/test-gconfig.c | 10 ++++++++++ tests/xml/gconfig-domain-device-graphics-listen.xml | 2 ++ 7 files changed, 52 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c index 7e0bd9f..88dd757 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c @@ -186,6 +186,23 @@ void gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice } } +/** + * gvir_config_domain_graphics_spice_add_listen: + * @graphics: a #GVirConfigDomainGraphicsSpice + * @listens: a #GVirConfigDomainGraphicsListen + * + * This method is used to add a listen node to a #GVirConfigDomainGraphicsSpice + * device can handle. +*/ +void gvir_config_domain_graphics_spice_add_listen(GVirConfigDomainGraphicsSpice *graphics, + GVirConfigDomainGraphicsListen *listen) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics)); + + gvir_config_object_attach_add(GVIR_CONFIG_OBJECT(graphics), + GVIR_CONFIG_OBJECT(listen)); +} + struct ListenData { GVirConfigXmlDoc *doc; const gchar *schema; diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h index 1632cc9..468ead6 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h @@ -97,6 +97,8 @@ void gvir_config_domain_graphics_spice_set_gl(GVirConfigDomainGraphicsSpice *gra void gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice *graphics, GList *listens); +void gvir_config_domain_graphics_spice_add_listen(GVirConfigDomainGraphicsSpice *graphics, + GVirConfigDomainGraphicsListen *listen); GList *gvir_config_domain_graphics_spice_get_listen(GVirConfigDomainGraphicsSpice *graphics); G_END_DECLS diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c index bc229bd..17fce67 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c @@ -149,6 +149,23 @@ void gvir_config_domain_graphics_vnc_set_listen(GVirConfigDomainGraphicsVnc *gra } } +/** + * gvir_config_domain_graphics_vnc_add_listen: + * @graphics: a #GVirConfigDomainGraphicsVnc + * @listens: a #GVirConfigDomainGraphicsListen + * + * This method is used to add a listen node to a #GVirConfigDomainGraphicsVnc + * device can handle. +*/ +void gvir_config_domain_graphics_vnc_add_listen(GVirConfigDomainGraphicsVnc *graphics, + GVirConfigDomainGraphicsListen *listen) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics)); + + gvir_config_object_attach_add(GVIR_CONFIG_OBJECT(graphics), + GVIR_CONFIG_OBJECT(listen)); +} + struct ListenData { GVirConfigXmlDoc *doc; const gchar *schema; diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h index df21bd6..e4d4fc3 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h @@ -75,6 +75,8 @@ void gvir_config_domain_graphics_vnc_set_port(GVirConfigDomainGraphicsVnc *graph void gvir_config_domain_graphics_vnc_set_listen(GVirConfigDomainGraphicsVnc *graphics, GList *listens); +void gvir_config_domain_graphics_vnc_add_listen(GVirConfigDomainGraphicsVnc *graphics, + GVirConfigDomainGraphicsListen *listen); GList *gvir_config_domain_graphics_vnc_get_listen(GVirConfigDomainGraphicsVnc *graphics); void gvir_config_domain_graphics_vnc_set_password(GVirConfigDomainGraphicsVnc *graphics, diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index c07de56..aef53cd 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -757,9 +757,11 @@ global: gvir_config_domain_graphics_listen_unix_new; gvir_config_domain_graphics_listen_unix_new_from_xml; gvir_config_domain_graphics_listen_unix_set_path; + gvir_config_domain_graphics_spice_add_listen; gvir_config_domain_graphics_spice_get_listen; gvir_config_domain_graphics_spice_set_gl; gvir_config_domain_graphics_spice_set_listen; + gvir_config_domain_graphics_vnc_add_listen; gvir_config_domain_graphics_vnc_get_listen; gvir_config_domain_graphics_vnc_set_listen; diff --git a/tests/test-gconfig.c b/tests/test-gconfig.c index 97275a1..7fc0704 100644 --- a/tests/test-gconfig.c +++ b/tests/test-gconfig.c @@ -501,6 +501,11 @@ static void test_domain_device_graphics_listen(void) g_object_unref(inet_address); g_object_unref(ret_inet_address); + GVirConfigDomainGraphicsListenNone *none_listen = gvir_config_domain_graphics_listen_none_new(); + GVirConfigDomainGraphicsListenUnix *unix_listen = gvir_config_domain_graphics_listen_unix_new(); + gvir_config_domain_graphics_listen_unix_set_path(unix_listen, "/tmp/bar.sock"); + g_assert_cmpstr("/tmp/bar.sock", ==, gvir_config_domain_graphics_listen_unix_get_path(unix_listen)); + gvir_config_domain_graphics_listen_address_set_address(address_listen, "127.0.0.1"); const gchar *ret_address = gvir_config_domain_graphics_listen_address_get_address(address_listen); g_assert_cmpstr("127.0.0.1", ==, ret_address); @@ -511,6 +516,11 @@ static void test_domain_device_graphics_listen(void) g_object_unref(G_OBJECT(address_listen)); g_list_free(listen_list); + gvir_config_domain_graphics_spice_add_listen(graphics, GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN(none_listen)); + gvir_config_domain_graphics_spice_add_listen(graphics, GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN(unix_listen)); + g_object_unref(none_listen); + g_object_unref(unix_listen); + gvir_config_domain_add_device(domain, GVIR_CONFIG_DOMAIN_DEVICE(graphics)); g_object_unref(G_OBJECT(graphics)); diff --git a/tests/xml/gconfig-domain-device-graphics-listen.xml b/tests/xml/gconfig-domain-device-graphics-listen.xml index 27200c4..6e53876 100644 --- a/tests/xml/gconfig-domain-device-graphics-listen.xml +++ b/tests/xml/gconfig-domain-device-graphics-listen.xml @@ -2,6 +2,8 @@ <devices> <graphics type="spice"> <listen type="address" address="127.0.0.1"/> + <listen type="none"/> + <listen type="socket" socket="/tmp/bar.sock"/> </graphics> </devices> </domain> -- 2.7.4

This is a legacy attribute which is going to conflict with listen nodes when we set some. --- libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c | 2 ++ libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c index 88dd757..051ff87 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c @@ -175,6 +175,8 @@ void gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice gvir_config_object_remove_attribute (GVIR_CONFIG_OBJECT(graphics), "listen"); + gvir_config_object_remove_attribute (GVIR_CONFIG_OBJECT(graphics), + "socket"); gvir_config_object_delete_children (GVIR_CONFIG_OBJECT (graphics), "listen", NULL); diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c index 17fce67..3bc5b8c 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c @@ -138,6 +138,8 @@ void gvir_config_domain_graphics_vnc_set_listen(GVirConfigDomainGraphicsVnc *gra gvir_config_object_remove_attribute (GVIR_CONFIG_OBJECT(graphics), "listen"); + gvir_config_object_remove_attribute (GVIR_CONFIG_OBJECT(graphics), + "socket"); gvir_config_object_delete_children (GVIR_CONFIG_OBJECT (graphics), "listen", NULL); -- 2.7.4

From: Fabiano Fidêncio <fidencio@redhat.com> Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> --- libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c | 8 ++++++++ libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h | 1 + libvirt-gconfig/libvirt-gconfig.sym | 1 + 3 files changed, 10 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c index 051ff87..d66b362 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c @@ -113,6 +113,14 @@ void gvir_config_domain_graphics_spice_set_port(GVirConfigDomainGraphicsSpice *g NULL); } +int gvir_config_domain_graphics_spice_get_tls_port(GVirConfigDomainGraphicsSpice *graphics) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics), 0); + + return gvir_config_object_get_attribute_uint64(GVIR_CONFIG_OBJECT(graphics), + NULL, "tlsPort", 0); +} + void gvir_config_domain_graphics_spice_set_tls_port(GVirConfigDomainGraphicsSpice *graphics, int port) { diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h index 468ead6..54da02a 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h @@ -82,6 +82,7 @@ int gvir_config_domain_graphics_spice_get_port(GVirConfigDomainGraphicsSpice *gr void gvir_config_domain_graphics_spice_set_port(GVirConfigDomainGraphicsSpice *graphics, int port); +int gvir_config_domain_graphics_spice_get_tls_port(GVirConfigDomainGraphicsSpice *graphics); void gvir_config_domain_graphics_spice_set_tls_port(GVirConfigDomainGraphicsSpice *graphics, int port); diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index aef53cd..4cd5f4d 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -759,6 +759,7 @@ global: gvir_config_domain_graphics_listen_unix_set_path; gvir_config_domain_graphics_spice_add_listen; gvir_config_domain_graphics_spice_get_listen; + gvir_config_domain_graphics_spice_get_tls_port; gvir_config_domain_graphics_spice_set_gl; gvir_config_domain_graphics_spice_set_listen; gvir_config_domain_graphics_vnc_add_listen; -- 2.7.4

From: Fabiano Fidêncio <fidencio@redhat.com> Seems that GVirConfigDomainGraphics* were built with a strong focus on writing/setting configs, but not reading those. For instance, considering virt-viewer's case, where the app is just consuming an already built xml, for getting the port attribute of a GVirDomainConfigGraphis{Spice,Vnc} you have to know, beforehand, the type of the connection and then call gvir_config_domain_graphics_{sdl,spice}_get_port(). It means creating an abstraction on virt-viewer side, that will ended up in some code like: if (GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics)) _get_whatever_you_want_using_specific_spice_api() else _get_whatever_you want_using_specific_vnc_api() In order to avoid this, let's introduce GVirConfigDomainGraphicsRemote class that, at least for now, is intended to be a helper for the case explained above. It introduces a new hierarchy in the project, where, instead of having GVirConfigDomainGraphics{Spice,Vnc,Rdp} inheriting from GVirConfigDomainGraphics, these classes will inherit from GVirConfigDomainGraphicsRemote (see the next patches) which inherits from from GVirConfigGraphics (it will cause an ABI breakage, though). Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> --- libvirt-gconfig/Makefile.am | 2 + .../libvirt-gconfig-domain-graphics-remote.c | 95 ++++++++++++++++++++++ .../libvirt-gconfig-domain-graphics-remote.h | 69 ++++++++++++++++ libvirt-gconfig/libvirt-gconfig.h | 1 + libvirt-gconfig/libvirt-gconfig.sym | 2 + po/POTFILES.in | 1 + 6 files changed, 170 insertions(+) create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.c create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index ba08a11..64812bb 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -51,6 +51,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-domain-graphics-listen-none.h \ libvirt-gconfig-domain-graphics-listen-unix.h \ libvirt-gconfig-domain-graphics-rdp.h \ + libvirt-gconfig-domain-graphics-remote.h \ libvirt-gconfig-domain-graphics-sdl.h \ libvirt-gconfig-domain-graphics-spice.h \ libvirt-gconfig-domain-graphics-vnc.h \ @@ -148,6 +149,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-graphics-listen-none.c \ libvirt-gconfig-domain-graphics-listen-unix.c \ libvirt-gconfig-domain-graphics-rdp.c \ + libvirt-gconfig-domain-graphics-remote.c \ libvirt-gconfig-domain-graphics-sdl.c \ libvirt-gconfig-domain-graphics-spice.c \ libvirt-gconfig-domain-graphics-vnc.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.c new file mode 100644 index 0000000..46b97f2 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.c @@ -0,0 +1,95 @@ +/* + * libvirt-gconfig-domain-graphics-remote.c: libvirt domain graphics remote configuration + * + * Copyright (C) 2016 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: Fabiano Fidêncio <fidencio@redhat.com> + */ + +#include <config.h> + +#include <glib/gi18n-lib.h> + +#include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-private.h" + +#define GVIR_CONFIG_DOMAIN_GRAPHICS_REMOTE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_REMOTE, GVirConfigDomainGraphicsRemotePrivate)) + +struct _GVirConfigDomainGraphicsRemotePrivate +{ + gboolean unused; +}; + +typedef GVirConfigObject *(*GVirConfigDomainGraphicsRemoteNewFromXml)(const gchar *xml, GError **error); + +G_DEFINE_ABSTRACT_TYPE(GVirConfigDomainGraphicsRemote, gvir_config_domain_graphics_remote, GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS); + +static void gvir_config_domain_graphics_remote_class_init(GVirConfigDomainGraphicsRemoteClass *klass) +{ + g_type_class_add_private(klass, sizeof(GVirConfigDomainGraphicsRemotePrivate)); +} + +static void gvir_config_domain_graphics_remote_init(GVirConfigDomainGraphicsRemote *graphics) +{ + graphics->priv = GVIR_CONFIG_DOMAIN_GRAPHICS_REMOTE_GET_PRIVATE(graphics); +} + +GVirConfigDomainGraphicsRemote * +gvir_config_domain_graphics_remote_new_from_xml(const gchar *xml, + GError **error) +{ + GVirConfigDomainGraphicsRemoteNewFromXml functions[] = { + (GVirConfigDomainGraphicsRemoteNewFromXml)gvir_config_domain_graphics_vnc_new_from_xml, + (GVirConfigDomainGraphicsRemoteNewFromXml)gvir_config_domain_graphics_spice_new_from_xml, + (GVirConfigDomainGraphicsRemoteNewFromXml)gvir_config_domain_graphics_rdp_new_from_xml, + }; + GVirConfigObject *object; + + for (int i = 0; i < G_N_ELEMENTS(functions); i++) { + GVirConfigDomainGraphicsRemoteNewFromXml function = functions[i]; + + object = GVIR_CONFIG_OBJECT(function(xml, NULL)); + if (object != NULL) + break; + } + + if (object == NULL) { + g_set_error(error, + GVIR_CONFIG_OBJECT_ERROR, + 0, + _("Unable to create a new GraphicRemote object from the XML")); + } + + return GVIR_CONFIG_DOMAIN_GRAPHICS_REMOTE(object); +} + +gboolean gvir_config_domain_graphics_remote_get_autoport(GVirConfigDomainGraphicsRemote *graphics) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_REMOTE(graphics), FALSE); + + return gvir_config_object_get_attribute_boolean(GVIR_CONFIG_OBJECT(graphics), + NULL, "autoport", FALSE); +} + +int gvir_config_domain_graphics_remote_get_port(GVirConfigDomainGraphicsRemote *graphics) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_REMOTE(graphics), 0); + + return gvir_config_object_get_attribute_uint64(GVIR_CONFIG_OBJECT(graphics), + NULL, "port", 0); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.h new file mode 100644 index 0000000..cae8d21 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.h @@ -0,0 +1,69 @@ +/* + * libvirt-gconfig-domain-graphics-remote.h: libvirt domain graphics remote configuration + * + * Copyright (C) 2016 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: Fabiano Fidêncio <fidencio@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_GRAPHICS_REMOTE_H__ +#define __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_REMOTE_H__ + +G_BEGIN_DECLS + +#define GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_REMOTE (gvir_config_domain_graphics_remote_get_type ()) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_REMOTE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_REMOTE, GVirConfigDomainGraphicsRemote)) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_REMOTE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_REMOTE, GVirConfigDomainGraphicsRemoteClass)) +#define GVIR_CONFIG_IS_DOMAIN_GRAPHICS_REMOTE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_REMOTE)) +#define GVIR_CONFIG_IS_DOMAIN_GRAPHICS_REMOTE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_REMOTE)) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_REMOTE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_REMOTE, GVirConfigDomainGraphicsRemoteClass)) + +typedef struct _GVirConfigDomainGraphicsRemote GVirConfigDomainGraphicsRemote; +typedef struct _GVirConfigDomainGraphicsRemotePrivate GVirConfigDomainGraphicsRemotePrivate; +typedef struct _GVirConfigDomainGraphicsRemoteClass GVirConfigDomainGraphicsRemoteClass; + +struct _GVirConfigDomainGraphicsRemote +{ + GVirConfigDomainGraphics parent; + + GVirConfigDomainGraphicsRemotePrivate *priv; + + /* Do not add fields to this struct */ +}; + +struct _GVirConfigDomainGraphicsRemoteClass +{ + GVirConfigDomainGraphicsClass parent_class; + + gpointer padding[20]; +}; + +GType gvir_config_domain_graphics_remote_get_type(void); + +GVirConfigDomainGraphicsRemote *gvir_config_domain_graphics_remote_new_from_xml(const gchar *xml, + GError **error); + +gboolean gvir_config_domain_graphics_remote_get_autoport(GVirConfigDomainGraphicsRemote *interface); +int gvir_config_domain_graphics_remote_get_port(GVirConfigDomainGraphicsRemote *interface); + +G_END_DECLS + +#endif /* __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_REMOTE_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h index 45d3839..b6e8433 100644 --- a/libvirt-gconfig/libvirt-gconfig.h +++ b/libvirt-gconfig/libvirt-gconfig.h @@ -62,6 +62,7 @@ #include <libvirt-gconfig/libvirt-gconfig-domain-disk-driver.h> #include <libvirt-gconfig/libvirt-gconfig-domain-filesys.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics.h> +#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.h> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 4cd5f4d..7d17b01 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -757,6 +757,8 @@ global: gvir_config_domain_graphics_listen_unix_new; gvir_config_domain_graphics_listen_unix_new_from_xml; gvir_config_domain_graphics_listen_unix_set_path; + gvir_config_domain_graphics_remote_get_port; + gvir_config_domain_graphics_remote_get_type; gvir_config_domain_graphics_spice_add_listen; gvir_config_domain_graphics_spice_get_listen; gvir_config_domain_graphics_spice_get_tls_port; diff --git a/po/POTFILES.in b/po/POTFILES.in index 335ec67..da68459 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,4 +1,5 @@ libvirt-gconfig/libvirt-gconfig-helpers.c libvirt-gconfig/libvirt-gconfig-object.c +libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.c libvirt-gobject/libvirt-gobject-connection.c libvirt-gobject/libvirt-gobject-stream.c -- 2.7.4

From: Fabiano Fidêncio <fidencio@redhat.com> This patch adapts GVirConfigDomainGraphicsSpice to the new GVirConfigDomainGraphicsRemote, inheriting from it and using its helper functions for getting autoport and port properties. As GVirConfigDomainGraphicsSpice now inherits from GVirConfigDomainGraphicsRemote, this patch also introduces an ABI breakage. Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> --- libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c | 5 ++--- libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c index d66b362..4538820 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c @@ -35,7 +35,7 @@ struct _GVirConfigDomainGraphicsSpicePrivate gboolean unused; }; -G_DEFINE_TYPE(GVirConfigDomainGraphicsSpice, gvir_config_domain_graphics_spice, GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS); +G_DEFINE_TYPE(GVirConfigDomainGraphicsSpice, gvir_config_domain_graphics_spice, GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_REMOTE); static void gvir_config_domain_graphics_spice_class_init(GVirConfigDomainGraphicsSpiceClass *klass) @@ -99,8 +99,7 @@ int gvir_config_domain_graphics_spice_get_port(GVirConfigDomainGraphicsSpice *gr { g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics), 0); - return gvir_config_object_get_attribute_uint64(GVIR_CONFIG_OBJECT(graphics), - NULL, "port", 0); + return gvir_config_domain_graphics_remote_get_port(GVIR_CONFIG_DOMAIN_GRAPHICS_REMOTE(graphics)); } void gvir_config_domain_graphics_spice_set_port(GVirConfigDomainGraphicsSpice *graphics, diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h index 54da02a..b33c693 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h @@ -43,7 +43,7 @@ typedef struct _GVirConfigDomainGraphicsSpiceClass GVirConfigDomainGraphicsSpice struct _GVirConfigDomainGraphicsSpice { - GVirConfigDomainGraphics parent; + GVirConfigDomainGraphicsRemote parent; GVirConfigDomainGraphicsSpicePrivate *priv; @@ -52,7 +52,7 @@ struct _GVirConfigDomainGraphicsSpice struct _GVirConfigDomainGraphicsSpiceClass { - GVirConfigDomainGraphicsClass parent_class; + GVirConfigDomainGraphicsRemoteClass parent_class; gpointer padding[20]; }; -- 2.7.4

From: Fabiano Fidêncio <fidencio@redhat.com> This patch adapts GVirConfigDomainGraphicsRdp to the new GVirConfigDomainGraphicsRemote, inheriting from it and using its helper functions for getting autoport and port properties. As GVirConfigDomainGraphicsRdp now inherits from GVirConfigDomainGraphicsRemote, this patch also introduces an ABI breakage. Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> --- libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.c | 5 ++--- libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.h | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.c index 7a2cb4d..b3958c8 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.c @@ -33,7 +33,7 @@ struct _GVirConfigDomainGraphicsRdpPrivate gboolean unused; }; -G_DEFINE_TYPE(GVirConfigDomainGraphicsRdp, gvir_config_domain_graphics_rdp, GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS); +G_DEFINE_TYPE(GVirConfigDomainGraphicsRdp, gvir_config_domain_graphics_rdp, GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_REMOTE); static void gvir_config_domain_graphics_rdp_class_init(GVirConfigDomainGraphicsRdpClass *klass) @@ -87,8 +87,7 @@ int gvir_config_domain_graphics_rdp_get_port(GVirConfigDomainGraphicsRdp *graphi { g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_RDP(graphics), 0); - return gvir_config_object_get_attribute_uint64(GVIR_CONFIG_OBJECT(graphics), - NULL, "port", 0); + return gvir_config_domain_graphics_remote_get_port(GVIR_CONFIG_DOMAIN_GRAPHICS_REMOTE(graphics)); } void gvir_config_domain_graphics_rdp_set_port(GVirConfigDomainGraphicsRdp *graphics, diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.h index a048ff8..a549e46 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.h @@ -42,7 +42,7 @@ typedef struct _GVirConfigDomainGraphicsRdpClass GVirConfigDomainGraphicsRdpClas struct _GVirConfigDomainGraphicsRdp { - GVirConfigDomainGraphics parent; + GVirConfigDomainGraphicsRemote parent; GVirConfigDomainGraphicsRdpPrivate *priv; @@ -51,7 +51,7 @@ struct _GVirConfigDomainGraphicsRdp struct _GVirConfigDomainGraphicsRdpClass { - GVirConfigDomainGraphicsClass parent_class; + GVirConfigDomainGraphicsRemoteClass parent_class; gpointer padding[20]; }; -- 2.7.4

From: Fabiano Fidêncio <fidencio@redhat.com> This patch adapts GVirConfigDomainGraphicsVnc to the new GVirConfigDomainGraphicsRemote, inheriting from it and using its helper functions for getting auport and port properties. As GVirConfigDomainGraphicsVnc now inherits from GVirConfigDomainGraphicsRemote, this patch also introduces an ABI breakage. Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> --- libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c | 5 ++--- libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c index 3bc5b8c..0927cc9 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c @@ -34,7 +34,7 @@ struct _GVirConfigDomainGraphicsVncPrivate gboolean unused; }; -G_DEFINE_TYPE(GVirConfigDomainGraphicsVnc, gvir_config_domain_graphics_vnc, GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS); +G_DEFINE_TYPE(GVirConfigDomainGraphicsVnc, gvir_config_domain_graphics_vnc, GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_REMOTE); static void gvir_config_domain_graphics_vnc_class_init(GVirConfigDomainGraphicsVncClass *klass) @@ -107,8 +107,7 @@ int gvir_config_domain_graphics_vnc_get_port(GVirConfigDomainGraphicsVnc *graphi { g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics), 0); - return gvir_config_object_get_attribute_uint64(GVIR_CONFIG_OBJECT(graphics), - NULL, "port", 0); + return gvir_config_domain_graphics_remote_get_port(GVIR_CONFIG_DOMAIN_GRAPHICS_REMOTE(graphics)); } void gvir_config_domain_graphics_vnc_set_port(GVirConfigDomainGraphicsVnc *graphics, diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h index e4d4fc3..482070a 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h @@ -42,7 +42,7 @@ typedef struct _GVirConfigDomainGraphicsVncClass GVirConfigDomainGraphicsVncClas struct _GVirConfigDomainGraphicsVnc { - GVirConfigDomainGraphics parent; + GVirConfigDomainGraphicsRemote parent; GVirConfigDomainGraphicsVncPrivate *priv; @@ -51,7 +51,7 @@ struct _GVirConfigDomainGraphicsVnc struct _GVirConfigDomainGraphicsVncClass { - GVirConfigDomainGraphicsClass parent_class; + GVirConfigDomainGraphicsRemoteClass parent_class; gpointer padding[20]; }; -- 2.7.4

From: Fabiano Fidêncio <fidencio@redhat.com> Adding this class more fore completness to the GVirConfigDomainGraphicsRemote than for any other reason. This patch introduces a new hierarchy in the project, where, instead of having GVirConfigDomainGraphics{Desktop,Sdl} inheriting from GVirConfigDomainGraphics, these classes will inherit from GVirConfigDomainGraphicsLocal (see the next patches), which inherits from GVirConfigDomainGraphics (it will cause ABI breakages, though). Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> --- libvirt-gconfig/Makefile.am | 2 + .../libvirt-gconfig-domain-graphics-local.c | 97 ++++++++++++++++++++++ .../libvirt-gconfig-domain-graphics-local.h | 68 +++++++++++++++ libvirt-gconfig/libvirt-gconfig.h | 1 + libvirt-gconfig/libvirt-gconfig.sym | 4 + po/POTFILES.in | 1 + 6 files changed, 173 insertions(+) create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-graphics-local.c create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-graphics-local.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 64812bb..fe76615 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -50,6 +50,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-domain-graphics-listen-address.h \ libvirt-gconfig-domain-graphics-listen-none.h \ libvirt-gconfig-domain-graphics-listen-unix.h \ + libvirt-gconfig-domain-graphics-local.h \ libvirt-gconfig-domain-graphics-rdp.h \ libvirt-gconfig-domain-graphics-remote.h \ libvirt-gconfig-domain-graphics-sdl.h \ @@ -148,6 +149,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-graphics-listen-address.c \ libvirt-gconfig-domain-graphics-listen-none.c \ libvirt-gconfig-domain-graphics-listen-unix.c \ + libvirt-gconfig-domain-graphics-local.c \ libvirt-gconfig-domain-graphics-rdp.c \ libvirt-gconfig-domain-graphics-remote.c \ libvirt-gconfig-domain-graphics-sdl.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-local.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-local.c new file mode 100644 index 0000000..3a0fe51 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-local.c @@ -0,0 +1,97 @@ +/* + * libvirt-gconfig-domain-graphics-local.c: libvirt domain graphics local configuration + * + * Copyright (C) 2016 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: Fabiano Fidêncio <fidencio@redhat.com> + */ + +#include <config.h> + +#include <glib/gi18n-lib.h> + +#include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-private.h" + +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LOCAL_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LOCAL, GVirConfigDomainGraphicsLocalPrivate)) + +struct _GVirConfigDomainGraphicsLocalPrivate +{ + gboolean unused; +}; + +typedef GVirConfigObject *(*GVirConfigDomainGraphicsLocalNewFromXml)(const gchar *xml, GError **error); + +G_DEFINE_ABSTRACT_TYPE(GVirConfigDomainGraphicsLocal, gvir_config_domain_graphics_local, GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS); + +static void gvir_config_domain_graphics_local_class_init(GVirConfigDomainGraphicsLocalClass *klass) +{ + g_type_class_add_private(klass, sizeof(GVirConfigDomainGraphicsLocalPrivate)); +} + +static void gvir_config_domain_graphics_local_init(GVirConfigDomainGraphicsLocal *graphics) +{ + graphics->priv = GVIR_CONFIG_DOMAIN_GRAPHICS_LOCAL_GET_PRIVATE(graphics); +} + +GVirConfigDomainGraphicsLocal * +gvir_config_domain_graphics_local_new_from_xml(const gchar *xml, + GError **error) +{ + GVirConfigDomainGraphicsLocalNewFromXml functions[] = { + (GVirConfigDomainGraphicsLocalNewFromXml)gvir_config_domain_graphics_sdl_new_from_xml, + (GVirConfigDomainGraphicsLocalNewFromXml)gvir_config_domain_graphics_desktop_new_from_xml, + }; + GVirConfigObject *object; + + for (int i = 0; i < G_N_ELEMENTS(functions); i++) { + GVirConfigDomainGraphicsLocalNewFromXml function = functions[i]; + + object = GVIR_CONFIG_OBJECT(function(xml, error)); + if (object != NULL) + break; + } + + if (object == NULL) { + g_set_error(error, + GVIR_CONFIG_OBJECT_ERROR, + 0, + _("Unable to create a new GraphicLocal object from the XML")); + } + + return GVIR_CONFIG_DOMAIN_GRAPHICS_LOCAL(object); +} + +const gchar *gvir_config_domain_graphics_local_get_display(GVirConfigDomainGraphicsLocal *graphics) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LOCAL(graphics), NULL); + + return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(graphics), + NULL, + "display"); +} + +gboolean gvir_config_domain_graphics_local_get_fullscreen(GVirConfigDomainGraphicsLocal *graphics) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LOCAL(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-local.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-local.h new file mode 100644 index 0000000..6494e42 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-local.h @@ -0,0 +1,68 @@ +/* + * libvirt-gconfig-domain-graphics-local.h: libvirt domain graphics local configuration + * + * Copyright (C) 2016 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: Fabiano Fidêncio <fidencio@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_GRAPHICS_LOCAL_H__ +#define __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_LOCAL_H__ + +G_BEGIN_DECLS + +#define GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LOCAL (gvir_config_domain_graphics_local_get_type ()) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LOCAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LOCAL, GVirConfigDomainGraphicsLocal)) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LOCAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LOCAL, GVirConfigDomainGraphicsLocalClass)) +#define GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LOCAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LOCAL)) +#define GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LOCAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LOCAL)) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LOCAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LOCAL, GVirConfigDomainGraphicsLocalClass)) + +typedef struct _GVirConfigDomainGraphicsLocal GVirConfigDomainGraphicsLocal; +typedef struct _GVirConfigDomainGraphicsLocalPrivate GVirConfigDomainGraphicsLocalPrivate; +typedef struct _GVirConfigDomainGraphicsLocalClass GVirConfigDomainGraphicsLocalClass; + +struct _GVirConfigDomainGraphicsLocal +{ + GVirConfigDomainGraphics parent; + + GVirConfigDomainGraphicsLocalPrivate *priv; + + /* Do not add fields to this struct */ +}; + +struct _GVirConfigDomainGraphicsLocalClass +{ + GVirConfigDomainGraphicsClass parent_class; + + gpointer padding[20]; +}; + +GType gvir_config_domain_graphics_local_get_type(void); + +GVirConfigDomainGraphicsLocal *gvir_config_domain_graphics_local_new_from_xml(const gchar *xml, + GError **error); +const gchar *gvir_config_domain_graphics_local_get_display(GVirConfigDomainGraphicsLocal *graphics); +gboolean gvir_config_domain_graphics_local_get_fullscreen(GVirConfigDomainGraphicsLocal *graphics); + +G_END_DECLS + +#endif /* __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_LOCAL_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h index b6e8433..77611b8 100644 --- a/libvirt-gconfig/libvirt-gconfig.h +++ b/libvirt-gconfig/libvirt-gconfig.h @@ -62,6 +62,7 @@ #include <libvirt-gconfig/libvirt-gconfig-domain-disk-driver.h> #include <libvirt-gconfig/libvirt-gconfig-domain-filesys.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics.h> +#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-local.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.h> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 7d17b01..975c9e1 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -757,6 +757,10 @@ global: gvir_config_domain_graphics_listen_unix_new; gvir_config_domain_graphics_listen_unix_new_from_xml; gvir_config_domain_graphics_listen_unix_set_path; + gvir_config_domain_graphics_local_get_display; + gvir_config_domain_graphics_local_get_fullscreen; + gvir_config_domain_graphics_local_get_type; + gvir_config_domain_graphics_remote_get_autoport; gvir_config_domain_graphics_remote_get_port; gvir_config_domain_graphics_remote_get_type; gvir_config_domain_graphics_spice_add_listen; diff --git a/po/POTFILES.in b/po/POTFILES.in index da68459..7102849 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,5 +1,6 @@ libvirt-gconfig/libvirt-gconfig-helpers.c libvirt-gconfig/libvirt-gconfig-object.c +libvirt-gconfig/libvirt-gconfig-domain-graphics-local.c libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.c libvirt-gobject/libvirt-gobject-connection.c libvirt-gobject/libvirt-gobject-stream.c -- 2.7.4

From: Fabiano Fidêncio <fidencio@redhat.com> This patch adapts GVirConfigDomainGraphicsSdl to the new GVirConfigDomainGraphicsLocal, inheriting from it and using its helper functions for getting the display and fullscreen properties. As GVirConfigDomainGraphicsSdl now inherits from GVirConfigDomainGraphicsLocal, this patch also introduces an ABI breakage. Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> --- libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.c | 2 +- libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.c index 1740494..d0d296d 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.c @@ -33,7 +33,7 @@ struct _GVirConfigDomainGraphicsSdlPrivate gboolean unused; }; -G_DEFINE_TYPE(GVirConfigDomainGraphicsSdl, gvir_config_domain_graphics_sdl, GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS); +G_DEFINE_TYPE(GVirConfigDomainGraphicsSdl, gvir_config_domain_graphics_sdl, GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LOCAL); static void gvir_config_domain_graphics_sdl_class_init(GVirConfigDomainGraphicsSdlClass *klass) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.h index 5110f1c..3130f52 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.h @@ -42,7 +42,7 @@ typedef struct _GVirConfigDomainGraphicsSdlClass GVirConfigDomainGraphicsSdlClas struct _GVirConfigDomainGraphicsSdl { - GVirConfigDomainGraphics parent; + GVirConfigDomainGraphicsLocal parent; GVirConfigDomainGraphicsSdlPrivate *priv; @@ -51,7 +51,7 @@ struct _GVirConfigDomainGraphicsSdl struct _GVirConfigDomainGraphicsSdlClass { - GVirConfigDomainGraphicsClass parent_class; + GVirConfigDomainGraphicsLocalClass parent_class; gpointer padding[20]; }; -- 2.7.4

From: Fabiano Fidêncio <fidencio@redhat.com> This patch adapts GVirConfigDomainGraphicsDesktop to the new GVirConfigDomainGraphicsLocal, inheriting from it and using its helper functions for getting display and fullscreen properties. As GVirConfigDomainGraphicsDesktop now inherits from GVirConfigDomainGraphicsLocal, this patch also introduces an ABI breakage. Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> --- libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.c | 11 +++-------- libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.h | 4 ++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.c index dadf684..7d23b77 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.c @@ -33,7 +33,7 @@ struct _GVirConfigDomainGraphicsDesktopPrivate gboolean unused; }; -G_DEFINE_TYPE(GVirConfigDomainGraphicsDesktop, gvir_config_domain_graphics_desktop, GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS); +G_DEFINE_TYPE(GVirConfigDomainGraphicsDesktop, gvir_config_domain_graphics_desktop, GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LOCAL); static void gvir_config_domain_graphics_desktop_class_init(GVirConfigDomainGraphicsDesktopClass *klass) @@ -88,9 +88,7 @@ const gchar *gvir_config_domain_graphics_desktop_get_display(GVirConfigDomainGra { 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"); + return gvir_config_domain_graphics_local_get_display(GVIR_CONFIG_DOMAIN_GRAPHICS_LOCAL(graphics)); } @@ -111,8 +109,5 @@ gboolean gvir_config_domain_graphics_desktop_get_fullscreen(GVirConfigDomainGrap { 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); + return gvir_config_domain_graphics_local_get_fullscreen(GVIR_CONFIG_DOMAIN_GRAPHICS_LOCAL(graphics)); } diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.h index 7e7e635..c117882 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.h @@ -42,7 +42,7 @@ typedef struct _GVirConfigDomainGraphicsDesktopClass GVirConfigDomainGraphicsDes struct _GVirConfigDomainGraphicsDesktop { - GVirConfigDomainGraphics parent; + GVirConfigDomainGraphicsLocal parent; GVirConfigDomainGraphicsDesktopPrivate *priv; @@ -51,7 +51,7 @@ struct _GVirConfigDomainGraphicsDesktop struct _GVirConfigDomainGraphicsDesktopClass { - GVirConfigDomainGraphicsClass parent_class; + GVirConfigDomainGraphicsLocalClass parent_class; gpointer padding[20]; }; -- 2.7.4

This will catch (among other things) cases when gvir_config_object_get_xml_node() is called with a NULL argument. Not catching this could cause a crash later on in cases when gvir_config_object_new_from_xml() is called and returns NULL, and then we call gvir_config_object_get_attribute() on it. Now this should be caught with runtime warnings so that the underlying issue can be fixed. --- libvirt-gconfig/libvirt-gconfig-object.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c index 6225de2..8cc4065 100644 --- a/libvirt-gconfig/libvirt-gconfig-object.c +++ b/libvirt-gconfig/libvirt-gconfig-object.c @@ -284,6 +284,8 @@ gvir_config_object_get_xml_doc(GVirConfigObject *config) G_GNUC_INTERNAL xmlNodePtr gvir_config_object_get_xml_node(GVirConfigObject *config) { + g_return_val_if_fail(GVIR_CONFIG_IS_OBJECT(config), NULL); + return config->priv->node; } -- 2.7.4

It's only useful in the remote case, and removes duplication between GVirConfigDomainGraphicsSpice and GVirConfigDomainGraphicsVnc. Since the spice/vnc listen API was not in a libvirt-gconfig release, we can remove it without breaking API/ABI. --- .../libvirt-gconfig-domain-graphics-remote.c | 103 +++++++++++++++++++++ .../libvirt-gconfig-domain-graphics-remote.h | 6 ++ .../libvirt-gconfig-domain-graphics-spice.c | 103 --------------------- .../libvirt-gconfig-domain-graphics-spice.h | 6 -- .../libvirt-gconfig-domain-graphics-vnc.c | 103 --------------------- .../libvirt-gconfig-domain-graphics-vnc.h | 6 -- libvirt-gconfig/libvirt-gconfig.h | 6 +- libvirt-gconfig/libvirt-gconfig.sym | 9 +- tests/test-gconfig.c | 6 +- 9 files changed, 118 insertions(+), 230 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.c index 46b97f2..64928b6 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.c @@ -93,3 +93,106 @@ int gvir_config_domain_graphics_remote_get_port(GVirConfigDomainGraphicsRemote * return gvir_config_object_get_attribute_uint64(GVIR_CONFIG_OBJECT(graphics), NULL, "port", 0); } + +/** + * gvir_config_domain_graphics_remote_set_listen: + * @graphics: a #GVirConfigDomainGraphicsRemote + * @listens: (in) (element-type LibvirtGConfig.DomainGraphicsListen): listens + * + * This method is used to set the various listen nodes a #GVirConfigDomainGraphicsRemote + * device can handle. +*/ +void gvir_config_domain_graphics_remote_set_listen(GVirConfigDomainGraphicsRemote *graphics, + GList *listens) +{ + GList *it; + + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_REMOTE(graphics)); + + gvir_config_object_remove_attribute (GVIR_CONFIG_OBJECT(graphics), + "listen"); + gvir_config_object_remove_attribute (GVIR_CONFIG_OBJECT(graphics), + "socket"); + gvir_config_object_delete_children (GVIR_CONFIG_OBJECT (graphics), + "listen", NULL); + + for (it = listens; it != NULL; it = it->next) { + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN(it->data)); + + gvir_config_object_attach_add(GVIR_CONFIG_OBJECT(graphics), + GVIR_CONFIG_OBJECT(it->data)); + } +} + +/** + * gvir_config_domain_graphics_remote_add_listen_nodes: + * @graphics: a #GVirConfigDomainGraphicsRemote + * @listens: a #GVirConfigDomainGraphicsListen + * + * This method is used to add a listen node to a #GVirConfigDomainGraphicsRemote + * device can handle. +*/ +void gvir_config_domain_graphics_remote_add_listen(GVirConfigDomainGraphicsRemote *graphics, + GVirConfigDomainGraphicsListen *listen) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_REMOTE(graphics)); + + gvir_config_object_attach_add(GVIR_CONFIG_OBJECT(graphics), + GVIR_CONFIG_OBJECT(listen)); +} + +struct ListenData { + GVirConfigXmlDoc *doc; + const gchar *schema; + GList *listen_devices; +}; + +static gboolean add_listen(xmlNodePtr node, gpointer opaque) +{ + struct ListenData* data = (struct ListenData*)opaque; + GVirConfigObject *object; + + if (g_strcmp0((const gchar *)node->name, "listen") != 0) + return TRUE; + + object = gvir_config_object_new_from_tree + (GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_ADDRESS, + data->doc, + data->schema, + node); + if (object != NULL) + data->listen_devices = g_list_append(data->listen_devices, object); + else + g_debug("Failed to parse %s node", node->name); + + return TRUE; +} + +/** + * gvir_config_domain_graphics_remote_get_listen: + * + * Gets all the listen not of #GVirConfigDomainGraphicsRemote + * + * Returns: (element-type LibvirtGConfig.DomainGraphicsListen) (transfer full): + * a newly allocated #GList of #GVirConfigDomainGraphicsListen. + */ +GList * +gvir_config_domain_graphics_remote_get_listen(GVirConfigDomainGraphicsRemote *graphics) +{ + struct ListenData data; + + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_REMOTE(graphics), NULL); + + g_object_get(G_OBJECT(graphics), "doc", &data.doc, NULL); + g_return_val_if_fail(data.doc != NULL, NULL); + data.schema = gvir_config_object_get_schema(GVIR_CONFIG_OBJECT(graphics)); + data.listen_devices = NULL; + + gvir_config_object_foreach_child(GVIR_CONFIG_OBJECT(graphics), + NULL, + add_listen, + &data); + g_clear_object(&data.doc); + + return data.listen_devices; +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.h index cae8d21..f798501 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.h @@ -64,6 +64,12 @@ GVirConfigDomainGraphicsRemote *gvir_config_domain_graphics_remote_new_from_xml( gboolean gvir_config_domain_graphics_remote_get_autoport(GVirConfigDomainGraphicsRemote *interface); int gvir_config_domain_graphics_remote_get_port(GVirConfigDomainGraphicsRemote *interface); +void gvir_config_domain_graphics_remote_set_listen(GVirConfigDomainGraphicsRemote *graphics, + GList *listens); +void gvir_config_domain_graphics_remote_add_listen(GVirConfigDomainGraphicsRemote *graphics, + GVirConfigDomainGraphicsListen *listen); +GList *gvir_config_domain_graphics_remote_get_listen(GVirConfigDomainGraphicsRemote *graphics); + G_END_DECLS #endif /* __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_REMOTE_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c index 4538820..5590cf0 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c @@ -165,109 +165,6 @@ void gvir_config_domain_graphics_spice_set_image_compression compression); } -/** - * gvir_config_domain_graphics_spice_set_listen: - * @graphics: a #GVirConfigDomainGraphicsSpice - * @listens: (in) (element-type LibvirtGConfig.DomainGraphicsListen): listens - * - * This method is used to set the various listen nodes a #GVirConfigDomainGraphicsSpice - * device can handle. -*/ -void gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice *graphics, - GList *listens) -{ - GList *it; - - g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics)); - - gvir_config_object_remove_attribute (GVIR_CONFIG_OBJECT(graphics), - "listen"); - gvir_config_object_remove_attribute (GVIR_CONFIG_OBJECT(graphics), - "socket"); - gvir_config_object_delete_children (GVIR_CONFIG_OBJECT (graphics), - "listen", NULL); - - for (it = listens; it != NULL; it = it->next) { - g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN(it->data)); - - gvir_config_object_attach_add(GVIR_CONFIG_OBJECT(graphics), - GVIR_CONFIG_OBJECT(it->data)); - } -} - -/** - * gvir_config_domain_graphics_spice_add_listen: - * @graphics: a #GVirConfigDomainGraphicsSpice - * @listens: a #GVirConfigDomainGraphicsListen - * - * This method is used to add a listen node to a #GVirConfigDomainGraphicsSpice - * device can handle. -*/ -void gvir_config_domain_graphics_spice_add_listen(GVirConfigDomainGraphicsSpice *graphics, - GVirConfigDomainGraphicsListen *listen) -{ - g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics)); - - gvir_config_object_attach_add(GVIR_CONFIG_OBJECT(graphics), - GVIR_CONFIG_OBJECT(listen)); -} - -struct ListenData { - GVirConfigXmlDoc *doc; - const gchar *schema; - GList *listen_devices; -}; - -static gboolean add_listen(xmlNodePtr node, gpointer opaque) -{ - struct ListenData* data = (struct ListenData*)opaque; - GVirConfigObject *object; - - if (g_strcmp0((const gchar *)node->name, "listen") != 0) - return TRUE; - - object = gvir_config_object_new_from_tree - (GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_ADDRESS, - data->doc, - data->schema, - node); - if (object != NULL) - data->listen_devices = g_list_append(data->listen_devices, object); - else - g_debug("Failed to parse %s node", node->name); - - return TRUE; -} - -/** - * gvir_config_domain_graphics_spice_get_listen: - * - * Gets all the listen not of #GVirConfigDomainGraphicsSpice - * - * Returns: (element-type LibvirtGConfig.DomainGraphicsListen) (transfer full): - * a newly allocated #GList of #GVirConfigDomainGraphicsListen. - */ -GList * -gvir_config_domain_graphics_spice_get_listen(GVirConfigDomainGraphicsSpice *graphics) -{ - struct ListenData data; - - g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics), NULL); - - g_object_get(G_OBJECT(graphics), "doc", &data.doc, NULL); - g_return_val_if_fail(data.doc != NULL, NULL); - data.schema = gvir_config_object_get_schema(GVIR_CONFIG_OBJECT(graphics)); - data.listen_devices = NULL; - - gvir_config_object_foreach_child(GVIR_CONFIG_OBJECT(graphics), - NULL, - add_listen, - &data); - g_clear_object(&data.doc); - - return data.listen_devices; -} - void gvir_config_domain_graphics_spice_set_gl(GVirConfigDomainGraphicsSpice *graphics, gboolean gl) { diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h index b33c693..9c790d7 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h @@ -96,12 +96,6 @@ gvir_config_domain_graphics_spice_get_image_compression void gvir_config_domain_graphics_spice_set_gl(GVirConfigDomainGraphicsSpice *graphics, gboolean gl); -void gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice *graphics, - GList *listens); -void gvir_config_domain_graphics_spice_add_listen(GVirConfigDomainGraphicsSpice *graphics, - GVirConfigDomainGraphicsListen *listen); -GList *gvir_config_domain_graphics_spice_get_listen(GVirConfigDomainGraphicsSpice *graphics); - G_END_DECLS #endif /* __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_SPICE_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c index 0927cc9..8bcaac7 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c @@ -120,109 +120,6 @@ void gvir_config_domain_graphics_vnc_set_port(GVirConfigDomainGraphicsVnc *graph NULL); } -/** - * gvir_config_domain_graphics_vnc_set_listen: - * @graphics: a #GVirConfigDomainGraphicsVnc - * @listens: (in) (element-type LibvirtGConfig.DomainGraphicsListen): - * - * This method is used to set the various listen nodes a #GVirConfigDomainGraphicsVnc - * device can handle. -*/ -void gvir_config_domain_graphics_vnc_set_listen(GVirConfigDomainGraphicsVnc *graphics, - GList *listens) -{ - GList *it; - - g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics)); - - gvir_config_object_remove_attribute (GVIR_CONFIG_OBJECT(graphics), - "listen"); - gvir_config_object_remove_attribute (GVIR_CONFIG_OBJECT(graphics), - "socket"); - gvir_config_object_delete_children (GVIR_CONFIG_OBJECT (graphics), - "listen", NULL); - - for (it = listens; it != NULL; it = it->next) { - g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN(it->data)); - - gvir_config_object_attach_add(GVIR_CONFIG_OBJECT(graphics), - GVIR_CONFIG_OBJECT(it->data)); - } -} - -/** - * gvir_config_domain_graphics_vnc_add_listen: - * @graphics: a #GVirConfigDomainGraphicsVnc - * @listens: a #GVirConfigDomainGraphicsListen - * - * This method is used to add a listen node to a #GVirConfigDomainGraphicsVnc - * device can handle. -*/ -void gvir_config_domain_graphics_vnc_add_listen(GVirConfigDomainGraphicsVnc *graphics, - GVirConfigDomainGraphicsListen *listen) -{ - g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics)); - - gvir_config_object_attach_add(GVIR_CONFIG_OBJECT(graphics), - GVIR_CONFIG_OBJECT(listen)); -} - -struct ListenData { - GVirConfigXmlDoc *doc; - const gchar *schema; - GList *listen_devices; -}; - -static gboolean add_listen(xmlNodePtr node, gpointer opaque) -{ - struct ListenData* data = (struct ListenData*)opaque; - GVirConfigObject *object; - - if (g_strcmp0((const gchar *)node->name, "listen") != 0) - return TRUE; - - object = gvir_config_object_new_from_tree - (GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LISTEN_ADDRESS, - data->doc, - data->schema, - node); - if (object != NULL) - data->listen_devices = g_list_append(data->listen_devices, object); - else - g_debug("Failed to parse %s node", node->name); - - return TRUE; -} - -/** - * gvir_config_domain_graphics_vnc_get_listen: - * - * Gets all the listen not of #GVirConfigDomainGraphicsVnc - * - * Returns: (element-type LibvirtGConfig.DomainGraphicsListen) (transfer full): - * a newly allocated #GList of #GVirConfigDomainGraphicsListen. - */ -GList * -gvir_config_domain_graphics_vnc_get_listen(GVirConfigDomainGraphicsVnc *graphics) -{ - struct ListenData data; - - g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics), NULL); - - g_object_get(G_OBJECT(graphics), "doc", &data.doc, NULL); - g_return_val_if_fail(data.doc != NULL, NULL); - data.schema = gvir_config_object_get_schema(GVIR_CONFIG_OBJECT(graphics)); - data.listen_devices = NULL; - - gvir_config_object_foreach_child(GVIR_CONFIG_OBJECT(graphics), - NULL, - add_listen, - &data); - g_clear_object(&data.doc); - - return data.listen_devices; -} - void gvir_config_domain_graphics_vnc_set_password(GVirConfigDomainGraphicsVnc *graphics, const char *password) { diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h index 482070a..72ca287 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h @@ -73,12 +73,6 @@ int gvir_config_domain_graphics_vnc_get_port(GVirConfigDomainGraphicsVnc *graphi void gvir_config_domain_graphics_vnc_set_port(GVirConfigDomainGraphicsVnc *graphics, int port); -void gvir_config_domain_graphics_vnc_set_listen(GVirConfigDomainGraphicsVnc *graphics, - GList *listens); -void gvir_config_domain_graphics_vnc_add_listen(GVirConfigDomainGraphicsVnc *graphics, - GVirConfigDomainGraphicsListen *listen); -GList *gvir_config_domain_graphics_vnc_get_listen(GVirConfigDomainGraphicsVnc *graphics); - void gvir_config_domain_graphics_vnc_set_password(GVirConfigDomainGraphicsVnc *graphics, const char *password); diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h index 77611b8..2f65cfe 100644 --- a/libvirt-gconfig/libvirt-gconfig.h +++ b/libvirt-gconfig/libvirt-gconfig.h @@ -62,13 +62,13 @@ #include <libvirt-gconfig/libvirt-gconfig-domain-disk-driver.h> #include <libvirt-gconfig/libvirt-gconfig-domain-filesys.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics.h> -#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-local.h> -#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.h> -#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-none.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-unix.h> +#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-local.h> +#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.h> +#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 975c9e1..6f10583 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -760,17 +760,14 @@ global: gvir_config_domain_graphics_local_get_display; gvir_config_domain_graphics_local_get_fullscreen; gvir_config_domain_graphics_local_get_type; + gvir_config_domain_graphics_remote_add_listen; gvir_config_domain_graphics_remote_get_autoport; + gvir_config_domain_graphics_remote_get_listen; gvir_config_domain_graphics_remote_get_port; gvir_config_domain_graphics_remote_get_type; - gvir_config_domain_graphics_spice_add_listen; - gvir_config_domain_graphics_spice_get_listen; + gvir_config_domain_graphics_remote_set_listen; gvir_config_domain_graphics_spice_get_tls_port; gvir_config_domain_graphics_spice_set_gl; - gvir_config_domain_graphics_spice_set_listen; - gvir_config_domain_graphics_vnc_add_listen; - gvir_config_domain_graphics_vnc_get_listen; - gvir_config_domain_graphics_vnc_set_listen; gvir_config_domain_hostdev_get_boot_order; gvir_config_domain_hostdev_get_readonly; diff --git a/tests/test-gconfig.c b/tests/test-gconfig.c index 7fc0704..36e444c 100644 --- a/tests/test-gconfig.c +++ b/tests/test-gconfig.c @@ -512,12 +512,12 @@ static void test_domain_device_graphics_listen(void) /* test listen setter */ listen_list = g_list_append(listen_list, address_listen); - gvir_config_domain_graphics_spice_set_listen(graphics, listen_list); + gvir_config_domain_graphics_remote_set_listen(GVIR_CONFIG_DOMAIN_GRAPHICS_REMOTE(graphics), listen_list); g_object_unref(G_OBJECT(address_listen)); g_list_free(listen_list); - gvir_config_domain_graphics_spice_add_listen(graphics, GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN(none_listen)); - gvir_config_domain_graphics_spice_add_listen(graphics, GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN(unix_listen)); + gvir_config_domain_graphics_remote_add_listen(GVIR_CONFIG_DOMAIN_GRAPHICS_REMOTE(graphics), GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN(none_listen)); + gvir_config_domain_graphics_remote_add_listen(GVIR_CONFIG_DOMAIN_GRAPHICS_REMOTE(graphics), GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN(unix_listen)); g_object_unref(none_listen); g_object_unref(unix_listen); -- 2.7.4
participants (2)
-
Christophe Fergeau
-
Daniel P. Berrange