[libvirt] qemu-namespace handling?

Philipp Hahn hahn at univention.de
Tue Apr 12 07:29:15 UTC 2011


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).

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>

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>

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.

Sincerely
Philipp Hahn
-- 
Philipp Hahn           Open Source Software Engineer      hahn at univention.de
Univention GmbH        Linux for Your Business        fon: +49 421 22 232- 0
Mary-Somerville-Str.1  D-28359 Bremen                 fax: +49 421 22 232-99
                                                   http://www.univention.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110412/f04e5a1f/attachment-0001.sig>


More information about the libvir-list mailing list