[libvirt] Add a few more getters/setters to VNC/SPICE configuration

Hey, This patch series implements a few more getters/setters for GVirConfigDomainGraphicsVnc and GVirConfigDomainGraphicsSpice. They will be useful in GNOME Boxes as the same is currently achieved through XPath use. Christophe

--- libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c | 10 ++++++++++ libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h | 3 +++ libvirt-gconfig/libvirt-gconfig.sym | 2 ++ libvirt-gconfig/tests/test-domain-create.c | 1 + 4 files changed, 16 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c index e60a778..3aef0aa 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c @@ -94,6 +94,16 @@ void gvir_config_domain_graphics_spice_set_password(GVirConfigDomainGraphicsSpic NULL); } +void gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice *graphics, + const char *listen_ip) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics)); + + gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(graphics), + "listen", listen_ip, + NULL); +} + void gvir_config_domain_graphics_spice_set_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 d198813..bcaf04e 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h @@ -68,6 +68,9 @@ void gvir_config_domain_graphics_spice_set_autoport(GVirConfigDomainGraphicsSpic void gvir_config_domain_graphics_spice_set_password(GVirConfigDomainGraphicsSpice *graphics, const char *password); +void gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice *graphics, + const char *listen_ip); + void gvir_config_domain_graphics_spice_set_port(GVirConfigDomainGraphicsSpice *graphics, int port); diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index f83eabb..0f41d78 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -464,6 +464,8 @@ LIBVIRT_GCONFIG_0.1.3 { global: gvir_config_domain_get_current_memory; gvir_config_domain_set_current_memory; + + gvir_config_domain_graphics_spice_set_listen; } LIBVIRT_GCONFIG_0.1.0; # .... define new API here using predicted next version number .... diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index c3e627b..903281d 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -287,6 +287,7 @@ int main(int argc, char **argv) graphics = gvir_config_domain_graphics_spice_new(); gvir_config_domain_graphics_spice_set_port(graphics, 1234); + gvir_config_domain_graphics_spice_set_listen(graphics, "127.0.0.1"); devices = g_list_append(devices, GVIR_CONFIG_DOMAIN_DEVICE(graphics)); /* video node */ -- 1.7.11.4

On 12.09.2012 15:55, Christophe Fergeau wrote:
--- libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c | 10 ++++++++++ libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h | 3 +++ libvirt-gconfig/libvirt-gconfig.sym | 2 ++ libvirt-gconfig/tests/test-domain-create.c | 1 + 4 files changed, 16 insertions(+)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c index e60a778..3aef0aa 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c @@ -94,6 +94,16 @@ void gvir_config_domain_graphics_spice_set_password(GVirConfigDomainGraphicsSpic NULL); }
+void gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice *graphics, + const char *listen_ip) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics)); + + gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(graphics), + "listen", listen_ip, + NULL); +} + void gvir_config_domain_graphics_spice_set_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 d198813..bcaf04e 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h @@ -68,6 +68,9 @@ void gvir_config_domain_graphics_spice_set_autoport(GVirConfigDomainGraphicsSpic void gvir_config_domain_graphics_spice_set_password(GVirConfigDomainGraphicsSpice *graphics, const char *password);
+void gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice *graphics, + const char *listen_ip); + void gvir_config_domain_graphics_spice_set_port(GVirConfigDomainGraphicsSpice *graphics, int port);
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index f83eabb..0f41d78 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -464,6 +464,8 @@ LIBVIRT_GCONFIG_0.1.3 { global: gvir_config_domain_get_current_memory; gvir_config_domain_set_current_memory; + + gvir_config_domain_graphics_spice_set_listen; } LIBVIRT_GCONFIG_0.1.0;
# .... define new API here using predicted next version number .... diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index c3e627b..903281d 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -287,6 +287,7 @@ int main(int argc, char **argv)
graphics = gvir_config_domain_graphics_spice_new(); gvir_config_domain_graphics_spice_set_port(graphics, 1234); + gvir_config_domain_graphics_spice_set_listen(graphics, "127.0.0.1"); devices = g_list_append(devices, GVIR_CONFIG_DOMAIN_DEVICE(graphics));
/* video node */
libvirt supports listen on IP address or a network and I think we need to distinguish these. s/gvir_config_domain_graphics_spice_set_listen/gvir_config_domain_graphics_spice_set_listen_ip/ maybe? otherwise the code looks like doing what it promises. Michal

On Tue, Sep 25, 2012 at 02:07:39PM +0200, Michal Privoznik wrote: Hey,
libvirt supports listen on IP address or a network and I think we need to distinguish these.
As I understand it, to listen on an IP address or a network, you'd use a <listen> child node to the <graphics> node. This patch sets the 'listen' attribute on the <graphics> node, which is only about listening on an IP address if I didn't miss anything (?). <listen> nodes would be handled in a separate class, but there could indeed be an ambiguity between a setter for an object of this type, and this API.
s/gvir_config_domain_graphics_spice_set_listen/gvir_config_domain_graphics_spice_set_listen_ip/ maybe?
It seems it's not necessarily an IP address but this can be a hostname if the .rng is to be trusted. I had in the back of my mind the possibility of adding _set_listen_address which accepts a GInetAddress or something like that (just vague thoughts, I don't have a clear idea about that ;). So maybe _set_listen_str would work to avoid the ambiguity? Though as I write this mail, this looks weird too... Christophe

On 25.09.2012 14:47, Christophe Fergeau wrote:
On Tue, Sep 25, 2012 at 02:07:39PM +0200, Michal Privoznik wrote: Hey,
libvirt supports listen on IP address or a network and I think we need to distinguish these.
As I understand it, to listen on an IP address or a network, you'd use a <listen> child node to the <graphics> node. This patch sets the 'listen' attribute on the <graphics> node, which is only about listening on an IP address if I didn't miss anything (?).
No you didn't.
<listen> nodes would be handled in a separate class, but there could indeed be an ambiguity between a setter for an object of this type, and this API.
Yeah, this is what I had in mind. So if we ever add support for <listen> child elements we may wish _set_listen to be reserved just for this case: void gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice *graphics, GList *listen); Same scenario is already happening for gvir_config_domain_set_devices().
s/gvir_config_domain_graphics_spice_set_listen/gvir_config_domain_graphics_spice_set_listen_ip/ maybe?
It seems it's not necessarily an IP address but this can be a hostname if the .rng is to be trusted. I had in the back of my mind the possibility of adding _set_listen_address which accepts a GInetAddress or something like that (just vague thoughts, I don't have a clear idea about that ;). So maybe _set_listen_str would work to avoid the ambiguity? Though as I write this mail, this looks weird too...
what about _listen_address(GVirConfigDomainGraphicsSpice *, const char *addr); with @addr being either IP or hostname (in fact anything that is acceptable for libvirt)?
Christophe

On Tue, Sep 25, 2012 at 03:04:47PM +0200, Michal Privoznik wrote:
On 25.09.2012 14:47, Christophe Fergeau wrote:
It seems it's not necessarily an IP address but this can be a hostname if the .rng is to be trusted. I had in the back of my mind the possibility of adding _set_listen_address which accepts a GInetAddress or something like that (just vague thoughts, I don't have a clear idea about that ;). So maybe _set_listen_str would work to avoid the ambiguity? Though as I write this mail, this looks weird too...
what about
_listen_address(GVirConfigDomainGraphicsSpice *, const char *addr);
with @addr being either IP or hostname (in fact anything that is acceptable for libvirt)?
I had kind of reserved this name for an API taking a GInetSocketAddress or GInetAddress argument ( http://developer.gnome.org/gio/stable/GInetSocketAddress.html http://developer.gnome.org/gio/stable/GInetAddress.html ), but as they only wrap an IP address and not a hostname, this might not be a very useful API. So why not on the _listen_address name. Daniel, any thoughts on that? ;) Christophe

On Tue, Sep 25, 2012 at 02:47:30PM +0200, Christophe Fergeau wrote:
On Tue, Sep 25, 2012 at 02:07:39PM +0200, Michal Privoznik wrote: Hey,
libvirt supports listen on IP address or a network and I think we need to distinguish these.
As I understand it, to listen on an IP address or a network, you'd use a <listen> child node to the <graphics> node. This patch sets the 'listen' attribute on the <graphics> node, which is only about listening on an IP address if I didn't miss anything (?).
<listen> nodes would be handled in a separate class, but there could indeed be an ambiguity between a setter for an object of this type, and this API.
I wonder if we should simply not expose an API for the listen= attribute at all. Only have APIs for reading/writing the <listen> elements, and then for the first <listen> element propagate writes to the listen= attribute when applicable. Likewise if no <listen> element is found when parsing, auto-create one based on the listen= attribute. IOW, I don't think applications should need to care about the listen= attribute at all. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On Tue, Sep 25, 2012 at 03:32:10PM +0100, Daniel P. Berrange wrote:
I wonder if we should simply not expose an API for the listen= attribute at all. Only have APIs for reading/writing the <listen> elements [...]
IOW, I don't think applications should need to care about the listen= attribute at all.
Indeed, this makes sense. I'll drop the listen work from these patches for now, proper <listen> support can be added later. Christophe

Implement gvir_config_domain_graphics_vnc_set_listen and gvir_config_domain_graphics_vnc_set_socket. --- libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c | 19 +++++++++++++++++++ libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h | 6 ++++++ libvirt-gconfig/libvirt-gconfig.sym | 3 +++ 3 files changed, 28 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c index d9d1303..46cc723 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c @@ -74,6 +74,25 @@ gvir_config_domain_graphics_vnc_new_from_xml(const gchar *xml, return GVIR_CONFIG_DOMAIN_GRAPHICS_VNC(object); } +void gvir_config_domain_graphics_vnc_set_listen(GVirConfigDomainGraphicsVnc *graphics, + const char *listen_ip) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics)); + + gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(graphics), + "listen", listen_ip, + NULL); +} + +void gvir_config_domain_graphics_vnc_set_socket(GVirConfigDomainGraphicsVnc *graphics, + const char *socket) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics)); + + gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(graphics), + "socket", socket, + NULL); +} void gvir_config_domain_graphics_vnc_set_autoport(GVirConfigDomainGraphicsVnc *graphics, gboolean autoport) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h index e3183d7..f2bc402 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h @@ -62,6 +62,12 @@ GVirConfigDomainGraphicsVnc *gvir_config_domain_graphics_vnc_new(void); GVirConfigDomainGraphicsVnc *gvir_config_domain_graphics_vnc_new_from_xml(const gchar *xml, GError **error); +void gvir_config_domain_graphics_vnc_set_listen(GVirConfigDomainGraphicsVnc *graphics, + const char *listen_ip); + +void gvir_config_domain_graphics_vnc_set_socket(GVirConfigDomainGraphicsVnc *graphics, + const char *socket); + void gvir_config_domain_graphics_vnc_set_autoport(GVirConfigDomainGraphicsVnc *graphics, gboolean autoport); diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 0f41d78..11d1d81 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -466,6 +466,9 @@ LIBVIRT_GCONFIG_0.1.3 { gvir_config_domain_set_current_memory; gvir_config_domain_graphics_spice_set_listen; + + gvir_config_domain_graphics_vnc_set_listen; + gvir_config_domain_graphics_vnc_set_socket; } LIBVIRT_GCONFIG_0.1.0; # .... define new API here using predicted next version number .... -- 1.7.11.4

On 12.09.2012 15:55, Christophe Fergeau wrote:
Implement gvir_config_domain_graphics_vnc_set_listen and gvir_config_domain_graphics_vnc_set_socket. --- libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c | 19 +++++++++++++++++++ libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h | 6 ++++++ libvirt-gconfig/libvirt-gconfig.sym | 3 +++ 3 files changed, 28 insertions(+)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c index d9d1303..46cc723 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c @@ -74,6 +74,25 @@ gvir_config_domain_graphics_vnc_new_from_xml(const gchar *xml, return GVIR_CONFIG_DOMAIN_GRAPHICS_VNC(object); }
+void gvir_config_domain_graphics_vnc_set_listen(GVirConfigDomainGraphicsVnc *graphics, + const char *listen_ip) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics)); + + gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(graphics), + "listen", listen_ip, + NULL); +} + +void gvir_config_domain_graphics_vnc_set_socket(GVirConfigDomainGraphicsVnc *graphics, + const char *socket) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics)); + + gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(graphics), + "socket", socket, + NULL); +}
void gvir_config_domain_graphics_vnc_set_autoport(GVirConfigDomainGraphicsVnc *graphics, gboolean autoport) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h index e3183d7..f2bc402 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h @@ -62,6 +62,12 @@ GVirConfigDomainGraphicsVnc *gvir_config_domain_graphics_vnc_new(void); GVirConfigDomainGraphicsVnc *gvir_config_domain_graphics_vnc_new_from_xml(const gchar *xml, GError **error);
+void gvir_config_domain_graphics_vnc_set_listen(GVirConfigDomainGraphicsVnc *graphics, + const char *listen_ip); + +void gvir_config_domain_graphics_vnc_set_socket(GVirConfigDomainGraphicsVnc *graphics, + const char *socket); + void gvir_config_domain_graphics_vnc_set_autoport(GVirConfigDomainGraphicsVnc *graphics, gboolean autoport);
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 0f41d78..11d1d81 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -466,6 +466,9 @@ LIBVIRT_GCONFIG_0.1.3 { gvir_config_domain_set_current_memory;
gvir_config_domain_graphics_spice_set_listen; + + gvir_config_domain_graphics_vnc_set_listen; + gvir_config_domain_graphics_vnc_set_socket; } LIBVIRT_GCONFIG_0.1.0;
# .... define new API here using predicted next version number ....
ACK to socket part; for _set_listen() see my previous e-mail. NB we should update libvirt docs as well as listening to network is mentioned only for SPICE not VNC but libvirt does support both. Michal

--- .../libvirt-gconfig-domain-graphics-vnc.c | 24 ++++++++++++++++++++++ .../libvirt-gconfig-domain-graphics-vnc.h | 3 +++ libvirt-gconfig/libvirt-gconfig.sym | 3 +++ 3 files changed, 30 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c index 46cc723..353a789 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c @@ -74,6 +74,14 @@ gvir_config_domain_graphics_vnc_new_from_xml(const gchar *xml, return GVIR_CONFIG_DOMAIN_GRAPHICS_VNC(object); } +const char *gvir_config_domain_graphics_vnc_get_listen(GVirConfigDomainGraphicsVnc *graphics) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics), NULL); + + return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(graphics), + NULL, "listen"); +} + void gvir_config_domain_graphics_vnc_set_listen(GVirConfigDomainGraphicsVnc *graphics, const char *listen_ip) { @@ -84,6 +92,14 @@ void gvir_config_domain_graphics_vnc_set_listen(GVirConfigDomainGraphicsVnc *gra NULL); } +const char *gvir_config_domain_graphics_vnc_get_socket(GVirConfigDomainGraphicsVnc *graphics) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics), NULL); + + return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(graphics), + NULL, "socket"); +} + void gvir_config_domain_graphics_vnc_set_socket(GVirConfigDomainGraphicsVnc *graphics, const char *socket) { @@ -104,6 +120,14 @@ void gvir_config_domain_graphics_vnc_set_autoport(GVirConfigDomainGraphicsVnc *g NULL); } +int gvir_config_domain_graphics_vnc_get_port(GVirConfigDomainGraphicsVnc *graphics) +{ + 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); +} + void gvir_config_domain_graphics_vnc_set_port(GVirConfigDomainGraphicsVnc *graphics, int port) { diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h index f2bc402..2caf9fb 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h @@ -62,15 +62,18 @@ GVirConfigDomainGraphicsVnc *gvir_config_domain_graphics_vnc_new(void); GVirConfigDomainGraphicsVnc *gvir_config_domain_graphics_vnc_new_from_xml(const gchar *xml, GError **error); +const char *gvir_config_domain_graphics_vnc_get_listen(GVirConfigDomainGraphicsVnc *graphics); void gvir_config_domain_graphics_vnc_set_listen(GVirConfigDomainGraphicsVnc *graphics, const char *listen_ip); +const char *gvir_config_domain_graphics_vnc_get_socket(GVirConfigDomainGraphicsVnc *graphics); void gvir_config_domain_graphics_vnc_set_socket(GVirConfigDomainGraphicsVnc *graphics, const char *socket); void gvir_config_domain_graphics_vnc_set_autoport(GVirConfigDomainGraphicsVnc *graphics, gboolean autoport); +int gvir_config_domain_graphics_vnc_get_port(GVirConfigDomainGraphicsVnc *graphics); void gvir_config_domain_graphics_vnc_set_port(GVirConfigDomainGraphicsVnc *graphics, int port); diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 11d1d81..b66b28e 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -467,7 +467,10 @@ LIBVIRT_GCONFIG_0.1.3 { gvir_config_domain_graphics_spice_set_listen; + gvir_config_domain_graphics_vnc_get_listen; gvir_config_domain_graphics_vnc_set_listen; + gvir_config_domain_graphics_vnc_get_port; + gvir_config_domain_graphics_vnc_get_socket; gvir_config_domain_graphics_vnc_set_socket; } LIBVIRT_GCONFIG_0.1.0; -- 1.7.11.4

On 12.09.2012 15:55, Christophe Fergeau wrote:
--- .../libvirt-gconfig-domain-graphics-vnc.c | 24 ++++++++++++++++++++++ .../libvirt-gconfig-domain-graphics-vnc.h | 3 +++ libvirt-gconfig/libvirt-gconfig.sym | 3 +++ 3 files changed, 30 insertions(+)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c index 46cc723..353a789 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c @@ -74,6 +74,14 @@ gvir_config_domain_graphics_vnc_new_from_xml(const gchar *xml, return GVIR_CONFIG_DOMAIN_GRAPHICS_VNC(object); }
+const char *gvir_config_domain_graphics_vnc_get_listen(GVirConfigDomainGraphicsVnc *graphics) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics), NULL); + + return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(graphics), + NULL, "listen"); +} + void gvir_config_domain_graphics_vnc_set_listen(GVirConfigDomainGraphicsVnc *graphics, const char *listen_ip) { @@ -84,6 +92,14 @@ void gvir_config_domain_graphics_vnc_set_listen(GVirConfigDomainGraphicsVnc *gra NULL); }
+const char *gvir_config_domain_graphics_vnc_get_socket(GVirConfigDomainGraphicsVnc *graphics) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_VNC(graphics), NULL); + + return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(graphics), + NULL, "socket"); +} + void gvir_config_domain_graphics_vnc_set_socket(GVirConfigDomainGraphicsVnc *graphics, const char *socket) { @@ -104,6 +120,14 @@ void gvir_config_domain_graphics_vnc_set_autoport(GVirConfigDomainGraphicsVnc *g NULL); }
+int gvir_config_domain_graphics_vnc_get_port(GVirConfigDomainGraphicsVnc *graphics) +{ + 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); +} + void gvir_config_domain_graphics_vnc_set_port(GVirConfigDomainGraphicsVnc *graphics, int port) { diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h index f2bc402..2caf9fb 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h @@ -62,15 +62,18 @@ GVirConfigDomainGraphicsVnc *gvir_config_domain_graphics_vnc_new(void); GVirConfigDomainGraphicsVnc *gvir_config_domain_graphics_vnc_new_from_xml(const gchar *xml, GError **error);
+const char *gvir_config_domain_graphics_vnc_get_listen(GVirConfigDomainGraphicsVnc *graphics); void gvir_config_domain_graphics_vnc_set_listen(GVirConfigDomainGraphicsVnc *graphics, const char *listen_ip);
+const char *gvir_config_domain_graphics_vnc_get_socket(GVirConfigDomainGraphicsVnc *graphics); void gvir_config_domain_graphics_vnc_set_socket(GVirConfigDomainGraphicsVnc *graphics, const char *socket);
void gvir_config_domain_graphics_vnc_set_autoport(GVirConfigDomainGraphicsVnc *graphics, gboolean autoport);
+int gvir_config_domain_graphics_vnc_get_port(GVirConfigDomainGraphicsVnc *graphics); void gvir_config_domain_graphics_vnc_set_port(GVirConfigDomainGraphicsVnc *graphics, int port);
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 11d1d81..b66b28e 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -467,7 +467,10 @@ LIBVIRT_GCONFIG_0.1.3 {
gvir_config_domain_graphics_spice_set_listen;
+ gvir_config_domain_graphics_vnc_get_listen; gvir_config_domain_graphics_vnc_set_listen; + gvir_config_domain_graphics_vnc_get_port; + gvir_config_domain_graphics_vnc_get_socket; gvir_config_domain_graphics_vnc_set_socket; } LIBVIRT_GCONFIG_0.1.0;
Same applies here; ACK to the code but we need to decide on _listen() first. Michal

--- libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c | 16 ++++++++++++++++ libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h | 2 ++ libvirt-gconfig/libvirt-gconfig.sym | 2 ++ libvirt-gconfig/tests/test-domain-create.c | 2 ++ 4 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 3aef0aa..8426f4a 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c @@ -94,6 +94,14 @@ void gvir_config_domain_graphics_spice_set_password(GVirConfigDomainGraphicsSpic NULL); } +const char *gvir_config_domain_graphics_spice_get_listen(GVirConfigDomainGraphicsSpice *graphics) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics), NULL); + + return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(graphics), + NULL, "listen"); +} + void gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice *graphics, const char *listen_ip) { @@ -104,6 +112,14 @@ void gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice NULL); } +int gvir_config_domain_graphics_spice_get_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, "port", 0); +} + void gvir_config_domain_graphics_spice_set_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 bcaf04e..2fec9d8 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h @@ -68,9 +68,11 @@ void gvir_config_domain_graphics_spice_set_autoport(GVirConfigDomainGraphicsSpic void gvir_config_domain_graphics_spice_set_password(GVirConfigDomainGraphicsSpice *graphics, const char *password); +const char *gvir_config_domain_graphics_spice_get_listen(GVirConfigDomainGraphicsSpice *graphics); void gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice *graphics, const char *listen_ip); +int gvir_config_domain_graphics_spice_get_port(GVirConfigDomainGraphicsSpice *graphics); void gvir_config_domain_graphics_spice_set_port(GVirConfigDomainGraphicsSpice *graphics, int port); diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index b66b28e..5b2ebf4 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -465,7 +465,9 @@ LIBVIRT_GCONFIG_0.1.3 { gvir_config_domain_get_current_memory; gvir_config_domain_set_current_memory; + gvir_config_domain_graphics_spice_get_listen; gvir_config_domain_graphics_spice_set_listen; + gvir_config_domain_graphics_spice_get_port; gvir_config_domain_graphics_vnc_get_listen; gvir_config_domain_graphics_vnc_set_listen; diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index 903281d..5b64459 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -287,7 +287,9 @@ int main(int argc, char **argv) graphics = gvir_config_domain_graphics_spice_new(); gvir_config_domain_graphics_spice_set_port(graphics, 1234); + g_assert(gvir_config_domain_graphics_spice_get_port(graphics) == 1234); gvir_config_domain_graphics_spice_set_listen(graphics, "127.0.0.1"); + g_str_const_check(gvir_config_domain_graphics_spice_get_listen(graphics), "127.0.0.1"); devices = g_list_append(devices, GVIR_CONFIG_DOMAIN_DEVICE(graphics)); /* video node */ -- 1.7.11.4

On 12.09.2012 15:55, Christophe Fergeau wrote:
--- libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c | 16 ++++++++++++++++ libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h | 2 ++ libvirt-gconfig/libvirt-gconfig.sym | 2 ++ libvirt-gconfig/tests/test-domain-create.c | 2 ++ 4 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 3aef0aa..8426f4a 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c @@ -94,6 +94,14 @@ void gvir_config_domain_graphics_spice_set_password(GVirConfigDomainGraphicsSpic NULL); }
+const char *gvir_config_domain_graphics_spice_get_listen(GVirConfigDomainGraphicsSpice *graphics) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_SPICE(graphics), NULL); + + return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(graphics), + NULL, "listen"); +} + void gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice *graphics, const char *listen_ip) { @@ -104,6 +112,14 @@ void gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice NULL); }
+int gvir_config_domain_graphics_spice_get_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, "port", 0); +} + void gvir_config_domain_graphics_spice_set_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 bcaf04e..2fec9d8 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h @@ -68,9 +68,11 @@ void gvir_config_domain_graphics_spice_set_autoport(GVirConfigDomainGraphicsSpic void gvir_config_domain_graphics_spice_set_password(GVirConfigDomainGraphicsSpice *graphics, const char *password);
+const char *gvir_config_domain_graphics_spice_get_listen(GVirConfigDomainGraphicsSpice *graphics); void gvir_config_domain_graphics_spice_set_listen(GVirConfigDomainGraphicsSpice *graphics, const char *listen_ip);
+int gvir_config_domain_graphics_spice_get_port(GVirConfigDomainGraphicsSpice *graphics); void gvir_config_domain_graphics_spice_set_port(GVirConfigDomainGraphicsSpice *graphics, int port);
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index b66b28e..5b2ebf4 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -465,7 +465,9 @@ LIBVIRT_GCONFIG_0.1.3 { gvir_config_domain_get_current_memory; gvir_config_domain_set_current_memory;
+ gvir_config_domain_graphics_spice_get_listen; gvir_config_domain_graphics_spice_set_listen; + gvir_config_domain_graphics_spice_get_port;
gvir_config_domain_graphics_vnc_get_listen; gvir_config_domain_graphics_vnc_set_listen; diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index 903281d..5b64459 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -287,7 +287,9 @@ int main(int argc, char **argv)
graphics = gvir_config_domain_graphics_spice_new(); gvir_config_domain_graphics_spice_set_port(graphics, 1234); + g_assert(gvir_config_domain_graphics_spice_get_port(graphics) == 1234); gvir_config_domain_graphics_spice_set_listen(graphics, "127.0.0.1"); + g_str_const_check(gvir_config_domain_graphics_spice_get_listen(graphics), "127.0.0.1"); devices = g_list_append(devices, GVIR_CONFIG_DOMAIN_DEVICE(graphics));
/* video node */
And again. ACK once we agreed on _listen() func name. Overall, I'm giving ACK to whole patch set. I think it's worth renaming _listen() funcs to _listen_ip() to denote IP address is set. On the other hand, if we ever invent listening on network, we can stick to _listen_network(). So if you prefer the sorter name I can live with that and you can go ahead and push as is. If you don't mind doing a little of substitution, then do and push afterwards. Or third option is to get another opinion if somebody wants to chime in ... Michal

Ping? On Wed, Sep 12, 2012 at 03:55:25PM +0200, Christophe Fergeau wrote:
Hey,
This patch series implements a few more getters/setters for GVirConfigDomainGraphicsVnc and GVirConfigDomainGraphicsSpice. They will be useful in GNOME Boxes as the same is currently achieved through XPath use.
Christophe
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
participants (3)
-
Christophe Fergeau
-
Daniel P. Berrange
-
Michal Privoznik