[Libvir] Question about XML

Daniel P. Berrange berrange at redhat.com
Thu Jul 20 16:18:04 UTC 2006


On Thu, Jul 20, 2006 at 11:44:54AM -0400, Juan Walker wrote:
> Hi,
> 
> I have a question regarding the XML format that libvir uses for domain configuration. 
> 
> I was wondering if there is a way to use the configuration format that xm uses 
> or if a tool exists to convert to XML. I'm writing an app to help users manage 
> their Xen domains but I'm hoping to be able to use any .sxp files that the user 
> already has. 

I don't know of any tool which will convert between the config files and
the libvirt XML. If the domain is currently running though, you can use
the command 'virsh dumpxml mydomain' to get an XML dump of the current
live configuration for that domai. You can later feed that XML back into
'virsh create'  or the virDomainCreateLinux()  method. 

> I suspect I missed something in the documentation about why the XML format 
> is better, but if there is no such tool maybe I should volunteer to write one?

The configuration files used by 'xm' in /etc/xen/ are really just a snippet
of python code - they're not a formal configuration file format. So you get
crazy stuff like this in the 'config' files:

  import os, re
  arch = os.uname()[4]
  if re.search('64', arch):
      arch_libdir = 'lib64'
  else:
      arch_libdir = 'lib'

  kernel = "/usr/lib/xen/boot/hvmloader"

This is fine if your application is a python app, but if you're writing
an app in C or Java, etc you really don't want the config file to be 
containing python code. XML be contrast is a very clearly defined format,
so by creating a DTD for expressing a VM config in XML we get very good
interoperability between applications, not matter what language they're
written in.

Regards,
Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 




More information about the libvir-list mailing list