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

Re: [libvirt] Alternative to XML Creation and Parsing?

On Mon, May 03, 2010 at 10:23:11PM +0530, Ganesh Pagade wrote:
> Hello,
> We plan to develop a fancy GUI which would help creating and managing
> VMs/Domains for RHEL 5.4 KVM.
> However looking at the schemas provided in docs/schemas/ (Ex:
> domain.rng) generating
> the XML file from the inputs taken from the GUI and pass it on to
> virDomainDefineXML() turns out to be a huge tasks in itself. I was wondering
> if there is an better way for me to provide my configurations to the library
> and also to read data from it (instead of creating, parsing XMLs)? If an
> alternate approach exist, are there any limitations with it?

The only supported APIs at the libvirt level work in terms of the XML
since this is the most flexible & extensible format. Applications will
either operate on XML directly (virt-manager), or have their own data 
model for representing guest configs (oVirt, RHEV) and have a XML 
serializer/deserializer in their apps. 

> Also the schema given in docs/schemas/ would be generic for all hyper visor.
> How can I identify the tags applicable only for a particular hyper visor?

We don't currently document what tags are applicable per hypervisor, because
it is not in fact that easy to determine. It also varies tremendously based
on the version of the hypervisor, and even the options that the hypervisor
was compiled with. For example, QEMU 0.9 added SCSI support, but QEMU 0.12
in RHEL turns off the SCSI support.  Instead libvirt aims to raise an error
at the time you start the guest if you have a config that won't work.

> I found:
> virConnectDomainXMLFromNative(virConnectPtr conn, const char * nativeFormat,
> const char * nativeConfig, unsigned int flags)
> in API reference, which could solve my first problem but couldn't figure out
> what nativeFormat would be.

The 'nativeFormat' refers to any hypervisor specific configuration style.
In the case of QEMU this covers the command line argument syntax. There is
an example at


We don't really recommend applications use this API in normal operation. It
is really a tool to help migration from a non-libvirt solution into libvirt.
The XML it generates will typically need hand-editing afterwards to fix up
bits we couldn't convert automatically - in particular networking config.

|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

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