[libvirt] Support for older libxml2 [Was: [PATCH] Fixed URI parsing]

Eric Blake eblake at redhat.com
Wed Feb 15 22:37:15 UTC 2012


On 02/15/2012 08:01 AM, Daniel Veillard wrote:

> I completely missed this, I'm not sure I understand comment 2:
> 
>  paphio:~/XML -> testURI --debug 'qemu+ssh://[3ffe::102]/system'
>  scheme: qemu+ssh
>  server: [3ffe::102]
>  path: /system
>  qemu+ssh://[3ffe::102]/system
>  paphio:~/XML ->
> 
> Seems to me that libxml2 URI parsing works as expected
> if I look at http://www.ietf.org/rfc/rfc3986.txt which is the level
> of the URI spec that libxml2 implements:

> so it seems to me that the "[" and "]" are part of the host address
> per the RFC spec and well libxml2 parsing is adequate. I'm not sure
> I understand the parsing problem,

It boils down to an ease-of-use question.  Within a URI, I agree with
you that IPv6 addresses in the 'host' element of 'authority' have a
mandatory [].  Outside of a URI, IPv6 addresses must not have [] for use
in any other libc functions.  So either all clients of libxml2 must
strip [] when reading the server: field of the broken-down struct, and
reinstate [] before asking libxml to reconstruct a valid URI, or libxml2
could be taught to provide some convenient hooks:

server: remains as is
server_cooked: new field, which matches server for IPv4 and hostnames,
and which for IPv6 strips the []

and when constructing a URI from user-provided elements, automatically
add in the needed [] around IPv6 addresses (which are otherwise invalid
as they are not IPv4 nor hostnames) to create a valid URI without the
user having to track [].

However, since any ease-of-use improvements to libxml2 will only show up
in new libxml2 versions, and we must still interoperate with old
versions, I think this patch is on the right track of abstracting the
fact that libvirt must manage [] (strip it on parse, re-add it on
format) rather than relying on libxml2.

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120215/56158b8d/attachment-0001.sig>


More information about the libvir-list mailing list