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