[libvirt] [gconfig v2 1/2] config: Add spice listen setter

Learn to set the address that spice is listening on. --- .../libvirt-gconfig-domain-graphics-spice.c | 18 ++++++++++++++++++ .../libvirt-gconfig-domain-graphics-spice.h | 3 +++ libvirt-gconfig/libvirt-gconfig.sym | 1 + 3 files changed, 22 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c index 079ea27..a773084 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c @@ -165,3 +165,21 @@ void gvir_config_domain_graphics_spice_set_gl(GVirConfigDomainGraphicsSpice *gra gvir_config_object_replace_child_with_attribute_enum (GVIR_CONFIG_OBJECT(graphics), "gl", "enable", G_TYPE_BOOLEAN, gl); } + +void gvir_config_domain_graphics_spice_set_listen_address(GVirConfigDomainGraphicsSpice *graphics, + const char *address) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics)); + + gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(graphics), "listen", address, NULL); + + gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(graphics), + "listen", + "address", + address); + + gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(graphics), + "listen", + "type", + "address"); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h index 25c132e..4bca850 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, + const char *address); + 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 f11f97a..86768ae 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -736,6 +736,7 @@ global: LIBVIRT_GCONFIG_0.2.4 { gvir_config_domain_graphics_spice_set_gl; gvir_config_domain_video_set_accel3d; + gvir_config_domain_graphics_spice_set_listen_address; } LIBVIRT_GCONFIG_0.2.2; # .... define new API here using predicted next version number .... -- 2.5.5

Learn to set the address that vnc is listening on. --- libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c | 18 ++++++++++++++++++ libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h | 3 +++ libvirt-gconfig/libvirt-gconfig.sym | 1 + 3 files changed, 22 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c index fc26bb9..4187a8e 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c @@ -129,3 +129,21 @@ void gvir_config_domain_graphics_vnc_set_password(GVirConfigDomainGraphicsVnc *g "passwd", password, NULL); } + +void gvir_config_domain_graphics_vnc_set_listen_address(GVirConfigDomainGraphicsVnc *graphics, + const char *address) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics)); + + gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(graphics), "listen", address, NULL); + + gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(graphics), + "listen", + "address", + address); + + gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(graphics), + "listen", + "type", + "address"); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h index fe78621..e848cd7 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h @@ -76,6 +76,9 @@ void gvir_config_domain_graphics_vnc_set_port(GVirConfigDomainGraphicsVnc *graph void gvir_config_domain_graphics_vnc_set_password(GVirConfigDomainGraphicsVnc *graphics, const char *password); +void gvir_config_domain_graphics_vnc_set_listen_address(GVirConfigDomainGraphicsVnc *graphics, + const char *address); + G_END_DECLS #endif /* __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_VNC_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 86768ae..58b78b4 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -737,6 +737,7 @@ LIBVIRT_GCONFIG_0.2.4 { gvir_config_domain_graphics_spice_set_gl; gvir_config_domain_video_set_accel3d; gvir_config_domain_graphics_spice_set_listen_address; + gvir_config_domain_graphics_vnc_set_listen_address; } LIBVIRT_GCONFIG_0.2.2; # .... define new API here using predicted next version number .... -- 2.5.5

Hey, On Mon, Jul 18, 2016 at 04:36:40PM +0300, Visarion Alexandru wrote:
Learn to set the address that vnc is listening on.
For what it's worth, this patch series https://www.redhat.com/archives/libvir-list/2016-March/msg00993.html would have allowed not to have to implement this both for VNC and SPICE. Not sure why it did not land so far, I'll have to read back the old thread/check with Fidencio. Christophe

For what it's worth, this patch series https://www.redhat.com/archives/libvir-list/2016-March/msg00993.html would have allowed not to have to implement this both for VNC and SPICE. Not sure why it did not land so far, I'll have to read back the old
I made this discussion a private one by mistake, so it's time for some storytelling: *Christophe Fergeau wrote:* thread/check with Fidencio. *>I wrote: * The host setter for SPICE from the patch list isn't working. If the machine is running and the host is already set, you get this error: "Failed to set domain configuration: XML error: graphics listen attribute 127.0.0.1 must match address attribute of first listen element (found 0.0.0.0)" You either have to set both addresses at the same time (what I did in my patch) or maybe remove the <listen type="address"> child, but I haven't tried. Actually, you can get the same error on VNC as well, so both setters from the list aren't good. :( *>Cristophe Fergeau wrote:* Ah right, I remember these checks being added in libvirt. If you only set a <listen addr> node when there is no listen="xx" attribute, do you know if a listen="xx" attribute is automatically added? I expect that if the XML has both attributes, changing only the <listen addr> node and not the listen="xx" attribute is going to cause the same error? *>I wrote:* Yes and yes. Changing only the <listen addr> node when the listen attribute is present causes the same error. When setting the <listen addr> node, if there is no listen attribute, the listen attribute is automatically added. Should I try to do this ? Sorry for the mistake and let's continue finding a solution ! :) On Mon, Jul 18, 2016 at 6:37 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
Hey,
On Mon, Jul 18, 2016 at 04:36:40PM +0300, Visarion Alexandru wrote:
Learn to set the address that vnc is listening on.
For what it's worth, this patch series https://www.redhat.com/archives/libvir-list/2016-March/msg00993.html would have allowed not to have to implement this both for VNC and SPICE. Not sure why it did not land so far, I'll have to read back the old thread/check with Fidencio.
Christophe
-- Visarion-Mingopol Alexandru-Viorel Telefon : 0729614060 Best Bucuresti

Hey, On Mon, Jul 18, 2016 at 04:36:39PM +0300, Visarion Alexandru wrote:
Learn to set the address that spice is listening on. --- .../libvirt-gconfig-domain-graphics-spice.c | 18 ++++++++++++++++++ .../libvirt-gconfig-domain-graphics-spice.h | 3 +++ libvirt-gconfig/libvirt-gconfig.sym | 1 + 3 files changed, 22 insertions(+)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c index 079ea27..a773084 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c @@ -165,3 +165,21 @@ void gvir_config_domain_graphics_spice_set_gl(GVirConfigDomainGraphicsSpice *gra gvir_config_object_replace_child_with_attribute_enum (GVIR_CONFIG_OBJECT(graphics), "gl", "enable", G_TYPE_BOOLEAN, gl); } + +void gvir_config_domain_graphics_spice_set_listen_address(GVirConfigDomainGraphicsSpice *graphics, + const char *address) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics)); + + gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(graphics), "listen", address, NULL);
<spice listen="xxx"/>
+ + gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(graphics), + "listen", + "address", + address); + + gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(graphics), + "listen", + "type", + "address");
and <spice><listen type="address" address="xxx"/></spice> are 2 ways of expressing the same thing, with the <listen type="address"> one being fairly new, and <spice listen="xxx"/> is slowly being deprecated. When <spice listen="xxx"/> is used, a <listen> node is automatically created iirc. To handle the <listen> nodes, I think it would make more sense to have dedicated classes to handle it, and a gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice *graphics, GVirConfigDomainListen *listen) method. So for now, in gvir_config_domain_graphics_spice_set_listen_address I would only set the "listen" attribute. Then I wonder if the function should take a GInetAddress rather than a const char *? The alignment of the code is also odd, we try to align the split argumetns to function calls with the parens on the first line, does this show up this way in your editor? For example gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(graphics), "listen", "type", "address"); Christophe
participants (3)
-
Christophe Fergeau
-
Visarion Alexandru
-
Visarion-Mingopol Alexandru-Viorel