[libvirt] [libvirt-glib 03/20] gconfig: Introduce GVirConfigDomainGraphicsListenAddress

Christophe Fergeau cfergeau at redhat.com
Wed Oct 5 07:37:52 UTC 2016


hey,

On Tue, Oct 04, 2016 at 04:30:14PM +0100, Daniel P. Berrange wrote:
> > +
> > +/**
> > + * gvir_config_domain_graphics_listen_address_get_inet_address:
> > + *
> > + * Returns the #GInetAddress associated with the #GVirConfigDomainGraphicsListenAddress.
> > + *
> > + * Returns: (transfer full): a #GInetAddress.
> > + *
> > + */
> > +GInetAddress *
> > +gvir_config_domain_graphics_listen_address_get_inet_address(GVirConfigDomainGraphicsListenAddress *listen)
> > +{
> > +    g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LISTEN_ADDRESS(listen), NULL);
> > +
> > +    const gchar *address = gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(listen),
> > +                                                            NULL,
> > +                                                            "address");
> > +    return g_inet_address_new_from_string(address);
> > +}
> 
> IIUC GInetAddress only supports numeric IP addresses, where as libvirt
> also allows hostnames anywhere that an IP address is used. So apps
> using get_inet_address are liable to get NULL returned if we use
> GInetAddress.
> 
> So IMHO we should not use GInetAddress as it'd lead to apps which
> blindly use this API not realising they'll break if someone put a
> hostname in the XML until it is too late.

Good point. Should we keep _set_inet_address() which would limit what we
can set, but would not lead to unexpected results depending on the XML
content, or should we just drop the GInetAddress altogether, and only
keep the string based API (which is what Visarion initially proposed).

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20161005/056ea7f6/attachment-0001.sig>


More information about the libvir-list mailing list