[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] qemu-namespace handling?



On Tue, Apr 12, 2011 at 09:29:15AM +0200, Philipp Hahn wrote:
> Hello,
> 
> some time ago I hand to manipulate the domain XML description using Pythons 
> Elemtree XML implementation, which had problems generating the right format 
> for libvirt: elemtree just supports adding Qname elements (that 
> is "{http://libvirt.org/schemas/domain/qemu/1.0}commandline";) which 
> internally would create a temporary binding of this namespace to the "ns0" 
> Prefix.
> 
> My work-around for Elemtree was the add the name-space mapping for "qemu" 
> to "http://libvirt.org/schemas/domain/qemu/1.0"; to ETs internal mapping table 
> and add an "xmlns:qemu" attribute by hand:
>        ET._namespace_map[QEMU_URI] = 'qemu'
>         domain.attrib['xmlns:qemu'] = QEMU_URI
>
> libvirt on the other hand expects the prefix to be "qemu" and only checks, 
> that this prefix is bound to the URI mentioned above at the root node).

This is definitely a libvirt bug we should fix. The namespace prefix should
not be used as anything other than a key to match to a corresponding namespace
URI. So libvirt should not look for "qemu", it should allow anything which
ultimately maps to "http://libvirt.org/schemas/domain/qemu/1.0";

> The following examples would be XML valid, but are not accepted by libvirt:
> 
> <domain>...
>   <qemu:commandline xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0";>
>   ...</qemu:commandline>
> </domain>
> 
> <domain xmlns:ns0="http://libvirt.org/schemas/domain/qemu/1.0";>...
>   <ns0:commandline>
>   ...</ns0:commandline>
> </domain>

Yes, we should fix our code to accept both of those.

> The following (esoteric) example might be wrongly accepted by libvirt 
> (untested):
> 
> <domain xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0";>
>   <qemu:commandline xmlns:qemu="urn:foo">
>   ...</qemu:commandline>
> </domain>

Eww, nasty.

> I don't know if this is worth fixing, but I still encountered the first two 
> problems myself and had to spend some time to detecting what I did wrong. So 
> at least I want to share my finding with others, so they don't do the same 
> mistake.

Thanks for pointing this out. We really want to fix this, because when
building up an XML doc via an API, it is all too easy to skip over the
addition of the fixed prefix<->URI mapping, and just let your XML API
auto-generate a prefix.

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 :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]