[libvirt] [gconfig v2 0/4] Add support for changing listen address

From: Visarion Alexandru <viorel.visarion@gmail.com> libvirt-domain-graphics-listen defines an abstract class used to represent one listen node. libvirt-domain-graphics-liste-address defines a class that represents a listen node of type 'address', for the graphics device. We have to first remove the 'listen' attribute of the graphics device before adding child 'listen' nodes, to avoid inconsistencies check. Visarion Alexandru (4): Introduce libvirt-domain-graphics-listen Introduce libvirt-gconfig-domain-graphics-listen-address config: Add vnc host setter config: Add spice host setter libvirt-gconfig/Makefile.am | 4 ++ ...ibvirt-gconfig-domain-graphics-listen-address.c | 79 ++++++++++++++++++++++ ...ibvirt-gconfig-domain-graphics-listen-address.h | 67 ++++++++++++++++++ .../libvirt-gconfig-domain-graphics-listen.c | 48 +++++++++++++ .../libvirt-gconfig-domain-graphics-listen.h | 64 ++++++++++++++++++ .../libvirt-gconfig-domain-graphics-spice.c | 28 ++++++++ .../libvirt-gconfig-domain-graphics-spice.h | 3 + .../libvirt-gconfig-domain-graphics-vnc.c | 28 ++++++++ .../libvirt-gconfig-domain-graphics-vnc.h | 3 + libvirt-gconfig/libvirt-gconfig.h | 2 + libvirt-gconfig/libvirt-gconfig.sym | 6 ++ 11 files changed, 332 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 create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.c create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.h -- 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 | 48 ++++++++++++++++ .../libvirt-gconfig-domain-graphics-listen.h | 64 ++++++++++++++++++++++ libvirt-gconfig/libvirt-gconfig.h | 1 + libvirt-gconfig/libvirt-gconfig.sym | 1 + 5 files changed, 116 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 0400343..27c6df1 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -45,6 +45,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-domain-disk-driver.h \ libvirt-gconfig-domain-filesys.h \ libvirt-gconfig-domain-graphics.h \ + libvirt-gconfig-domain-graphics-listen.h\ libvirt-gconfig-domain-graphics-desktop.h \ libvirt-gconfig-domain-graphics-rdp.h \ libvirt-gconfig-domain-graphics-sdl.h \ @@ -138,6 +139,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-disk-driver.c \ libvirt-gconfig-domain-filesys.c \ libvirt-gconfig-domain-graphics.c \ + libvirt-gconfig-domain-graphics-listen.c\ libvirt-gconfig-domain-graphics-desktop.c \ libvirt-gconfig-domain-graphics-rdp.c \ libvirt-gconfig-domain-graphics-sdl.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..c89f126 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.c @@ -0,0 +1,48 @@ +/* + * libvirt-gconfig-domain-graphics-listen.c: libvirt domain graphics listen base class + * + * 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: 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..dba3811 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.h @@ -0,0 +1,64 @@ +/* + * libvirt-gconfig-domain-graphics-listen.h: libvirt domain graphics listen base class + * + * 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: 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..ecf1322 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-listen.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> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 4ef4bf7..b112399 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -764,6 +764,7 @@ global: gvir_config_domain_video_get_model; gvir_config_domain_video_set_accel3d; + gvir_config_domain_graphics_listen_get_type; } LIBVIRT_GCONFIG_0.2.2; # .... define new API here using predicted next version number .... -- 2.7.4

Hey, On Mon, Aug 01, 2016 at 11:52:37PM +0300, Visarion Alexandru wrote:
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 | 48 ++++++++++++++++ .../libvirt-gconfig-domain-graphics-listen.h | 64 ++++++++++++++++++++++ libvirt-gconfig/libvirt-gconfig.h | 1 + libvirt-gconfig/libvirt-gconfig.sym | 1 + 5 files changed, 116 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 0400343..27c6df1 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -45,6 +45,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-domain-disk-driver.h \ libvirt-gconfig-domain-filesys.h \ libvirt-gconfig-domain-graphics.h \ + libvirt-gconfig-domain-graphics-listen.h\ libvirt-gconfig-domain-graphics-desktop.h \ libvirt-gconfig-domain-graphics-rdp.h \ libvirt-gconfig-domain-graphics-sdl.h \ @@ -138,6 +139,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-disk-driver.c \ libvirt-gconfig-domain-filesys.c \ libvirt-gconfig-domain-graphics.c \ + libvirt-gconfig-domain-graphics-listen.c\ libvirt-gconfig-domain-graphics-desktop.c \ libvirt-gconfig-domain-graphics-rdp.c \ libvirt-gconfig-domain-graphics-sdl.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..c89f126 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.c @@ -0,0 +1,48 @@ +/* + * libvirt-gconfig-domain-graphics-listen.c: libvirt domain graphics listen base class + *
Since you write this code and not Red Hat, this should read:
+ * Copyright (C) 2016 Visarion Alexandru <viorel.visarion@gmail.com>
If you copied the code from another file and want to keep the copyright history, just keep the previous (C) line, and add another one with your name on it.
+ * + * 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..dba3811 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen.h @@ -0,0 +1,64 @@ +/* + * libvirt-gconfig-domain-graphics-listen.h: libvirt domain graphics listen base class + * + * 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: 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..ecf1322 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-listen.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> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 4ef4bf7..b112399 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -764,6 +764,7 @@ global:
gvir_config_domain_video_get_model; gvir_config_domain_video_set_accel3d; + gvir_config_domain_graphics_listen_get_type;
This needs to be alphabetically ordered or 'make check'/'make syntax-check' will fail. Looks good otherwise, Christophe

From: Visarion Alexandru <viorel.visarion@gmail.com> This is needed to be able to change the address a graphics device is listening on. --- libvirt-gconfig/Makefile.am | 2 + ...ibvirt-gconfig-domain-graphics-listen-address.c | 79 ++++++++++++++++++++++ ...ibvirt-gconfig-domain-graphics-listen-address.h | 67 ++++++++++++++++++ libvirt-gconfig/libvirt-gconfig.h | 1 + libvirt-gconfig/libvirt-gconfig.sym | 3 + 5 files changed, 152 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 27c6df1..6be860b 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-listen.h\ + libvirt-gconfig-domain-graphics-listen-address.h\ libvirt-gconfig-domain-graphics-desktop.h \ libvirt-gconfig-domain-graphics-rdp.h \ libvirt-gconfig-domain-graphics-sdl.h \ @@ -140,6 +141,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-filesys.c \ libvirt-gconfig-domain-graphics.c \ libvirt-gconfig-domain-graphics-listen.c\ + libvirt-gconfig-domain-graphics-listen-address.c\ libvirt-gconfig-domain-graphics-desktop.c \ libvirt-gconfig-domain-graphics-rdp.c \ libvirt-gconfig-domain-graphics-sdl.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..460ca23 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.c @@ -0,0 +1,79 @@ +/* + * libvirt-gconfig-domain-graphics-listen-address.c: libvirt domain graphics listen address 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: 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_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(const char *address) +{ + 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); + gvir_config_object_set_attribute(object, + "address", 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); +} 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..a11beb2 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.h @@ -0,0 +1,67 @@ +/* + * libvirt-gconfig-domain-graphics-listen-address.h: libvirt domain graphics listen address 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: 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__ + +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(const char *address); +GVirConfigDomainGraphicsListenAddress *gvir_config_domain_graphics_listen_address_new_from_xml(const gchar *xml, + GError **error); +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 ecf1322..a25c44b 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-listen.h> +#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.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> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index b112399..fab6059 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -765,6 +765,9 @@ global: gvir_config_domain_video_get_model; gvir_config_domain_video_set_accel3d; gvir_config_domain_graphics_listen_get_type; + gvir_config_domain_graphics_listen_address_get_type; + gvir_config_domain_graphics_listen_address_new; + gvir_config_domain_graphics_listen_address_new_from_xml; } LIBVIRT_GCONFIG_0.2.2; # .... define new API here using predicted next version number .... -- 2.7.4

On Mon, Aug 01, 2016 at 11:52:38PM +0300, Visarion Alexandru wrote:
From: Visarion Alexandru <viorel.visarion@gmail.com>
This is needed to be able to change the address a graphics device is listening on. --- libvirt-gconfig/Makefile.am | 2 + ...ibvirt-gconfig-domain-graphics-listen-address.c | 79 ++++++++++++++++++++++ ...ibvirt-gconfig-domain-graphics-listen-address.h | 67 ++++++++++++++++++ libvirt-gconfig/libvirt-gconfig.h | 1 + libvirt-gconfig/libvirt-gconfig.sym | 3 + 5 files changed, 152 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 27c6df1..6be860b 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-listen.h\ + libvirt-gconfig-domain-graphics-listen-address.h\ libvirt-gconfig-domain-graphics-desktop.h \ libvirt-gconfig-domain-graphics-rdp.h \ libvirt-gconfig-domain-graphics-sdl.h \ @@ -140,6 +141,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-filesys.c \ libvirt-gconfig-domain-graphics.c \ libvirt-gconfig-domain-graphics-listen.c\ + libvirt-gconfig-domain-graphics-listen-address.c\ libvirt-gconfig-domain-graphics-desktop.c \ libvirt-gconfig-domain-graphics-rdp.c \ libvirt-gconfig-domain-graphics-sdl.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..460ca23 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.c @@ -0,0 +1,79 @@ +/* + * libvirt-gconfig-domain-graphics-listen-address.c: libvirt domain graphics listen address configuration + * + * Copyright (C) 2016 Red Hat, Inc.
Same comment about the copyright, this should contain your name.
+ * + * 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_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(const char *address) +{ + 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); + gvir_config_object_set_attribute(object, + "address", address, + NULL); + + return GVIR_CONFIG_DOMAIN_GRAPHICS_LISTEN_ADDRESS(object); +}
Couple of comments here: all other libvirt-gconfig _new() functions don't take arguments, ie gvir_config_domain_graphics_listen_address_new(void); Here it might be good to be consistent. I'd add gvir_config_domain_graphics_listen_address_set_address() regardless of whether you change the prototype or not. Imo we should also accept a GInetAddress (maybe it should be the main way of setting this, with the _string version being a convenience helper).
+ + +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); +} 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..a11beb2 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.h @@ -0,0 +1,67 @@ +/* + * libvirt-gconfig-domain-graphics-listen-address.h: libvirt domain graphics listen address 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: 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__ + +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(const char *address); +GVirConfigDomainGraphicsListenAddress *gvir_config_domain_graphics_listen_address_new_from_xml(const gchar *xml, + GError **error); +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 ecf1322..a25c44b 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-listen.h> +#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-listen-address.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> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index b112399..fab6059 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -765,6 +765,9 @@ global: gvir_config_domain_video_get_model; gvir_config_domain_video_set_accel3d; gvir_config_domain_graphics_listen_get_type; + gvir_config_domain_graphics_listen_address_get_type; + gvir_config_domain_graphics_listen_address_new; + gvir_config_domain_graphics_listen_address_new_from_xml;
This also needs to be alphabetically ordered. Christophe

From: Visarion Alexandru <viorel.visarion@gmail.com> Learn to set the address that vnc is listening on. We 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 | 28 ++++++++++++++++++++++ .../libvirt-gconfig-domain-graphics-vnc.h | 3 +++ libvirt-gconfig/libvirt-gconfig.sym | 1 + 3 files changed, 32 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c index fc26bb9..dc7641b 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c @@ -120,6 +120,34 @@ void gvir_config_domain_graphics_vnc_set_port(GVirConfigDomainGraphicsVnc *graph NULL); } +/** + * gvir_config_domain_graphics_vnc_set_listen_address: + * @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_address(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)); + } +} + 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..f524dcc 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h @@ -73,6 +73,9 @@ 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_address(GVirConfigDomainGraphicsVnc *graphics, + GList *listens); + 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 fab6059..117a648 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -768,6 +768,7 @@ global: 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_vnc_set_listen_address; } LIBVIRT_GCONFIG_0.2.2; # .... define new API here using predicted next version number .... -- 2.7.4

On Mon, Aug 01, 2016 at 11:52:39PM +0300, Visarion Alexandru wrote:
From: Visarion Alexandru <viorel.visarion@gmail.com>
Learn to set the address that vnc is listening on.
We 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 | 28 ++++++++++++++++++++++ .../libvirt-gconfig-domain-graphics-vnc.h | 3 +++ libvirt-gconfig/libvirt-gconfig.sym | 1 + 3 files changed, 32 insertions(+)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c index fc26bb9..dc7641b 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c @@ -120,6 +120,34 @@ void gvir_config_domain_graphics_vnc_set_port(GVirConfigDomainGraphicsVnc *graph NULL); }
+/** + * gvir_config_domain_graphics_vnc_set_listen_address: + * @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_address(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_domain_set_devices() warns but continues trying the other devices, we probably can do the same here: if (!GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN(it->data)) { g_warn_if_reached(); continue; }
+ gvir_config_object_attach_add(GVIR_CONFIG_OBJECT(graphics), + GVIR_CONFIG_OBJECT(it->data)); + } +} + 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..f524dcc 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h @@ -73,6 +73,9 @@ 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_address(GVirConfigDomainGraphicsVnc *graphics, + GList *listens);
Indentation is off here, you need 4 more spaces.
+ 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 fab6059..117a648 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -768,6 +768,7 @@ global: 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_vnc_set_listen_address; } LIBVIRT_GCONFIG_0.2.2;
Be careful to the alphabetical sorting as in the other patches. Acked-by: Christophe Fergeau <cfergeau@redhat.com> Christophe

From: Visarion Alexandru <viorel.visarion@gmail.com> Learn to set the address that spice is listening on. We 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-spice.c | 28 ++++++++++++++++++++++ .../libvirt-gconfig-domain-graphics-spice.h | 3 +++ libvirt-gconfig/libvirt-gconfig.sym | 1 + 3 files changed, 32 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c index 079ea27..4219ff0 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c @@ -157,6 +157,34 @@ void gvir_config_domain_graphics_spice_set_image_compression compression); } +/** + * gvir_config_domain_graphics_spice_set_listen_address: + * @graphics: a #GVirConfigDomainGraphicsSpice + * @listens: (in) (element-type LibvirtGConfig.DomainGraphicsListen): + * + * This method is used to set the various listen nodes a #GVirConfigDomainGraphicsSpice + * device can handle. +*/ +void gvir_config_domain_graphics_spice_set_listen_address(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)); + } +} + 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..03abe5b 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h @@ -95,6 +95,9 @@ 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_address(GVirConfigDomainGraphicsSpice *graphics, + GList *listens); + 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 117a648..73fd977 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -769,6 +769,7 @@ global: gvir_config_domain_graphics_listen_address_new; gvir_config_domain_graphics_listen_address_new_from_xml; gvir_config_domain_graphics_vnc_set_listen_address; + gvir_config_domain_graphics_spice_set_listen_address; } LIBVIRT_GCONFIG_0.2.2; # .... define new API here using predicted next version number .... -- 2.7.4

Same minor comments as the previous patch, Adding some test case to tests/test-gconfig.c would be good to have imo. Acked-by: Christophe Fergeau <cfergeau@redhat.com> Christophe On Mon, Aug 01, 2016 at 11:52:40PM +0300, Visarion Alexandru wrote:
From: Visarion Alexandru <viorel.visarion@gmail.com>
Learn to set the address that spice is listening on.
We 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-spice.c | 28 ++++++++++++++++++++++ .../libvirt-gconfig-domain-graphics-spice.h | 3 +++ libvirt-gconfig/libvirt-gconfig.sym | 1 + 3 files changed, 32 insertions(+)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c index 079ea27..4219ff0 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c @@ -157,6 +157,34 @@ void gvir_config_domain_graphics_spice_set_image_compression compression); }
+/** + * gvir_config_domain_graphics_spice_set_listen_address: + * @graphics: a #GVirConfigDomainGraphicsSpice + * @listens: (in) (element-type LibvirtGConfig.DomainGraphicsListen): + * + * This method is used to set the various listen nodes a #GVirConfigDomainGraphicsSpice + * device can handle. +*/ +void gvir_config_domain_graphics_spice_set_listen_address(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)); + } +} + 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..03abe5b 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h @@ -95,6 +95,9 @@ 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_address(GVirConfigDomainGraphicsSpice *graphics, + GList *listens); + 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 117a648..73fd977 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -769,6 +769,7 @@ global: gvir_config_domain_graphics_listen_address_new; gvir_config_domain_graphics_listen_address_new_from_xml; gvir_config_domain_graphics_vnc_set_listen_address; + gvir_config_domain_graphics_spice_set_listen_address; } LIBVIRT_GCONFIG_0.2.2;
# .... define new API here using predicted next version number .... -- 2.7.4
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
participants (2)
-
Christophe Fergeau
-
Visarion Alexandru