[Libvir] Question about XML

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 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? Thanks.

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.
This is basically impossible in general, as the xm current configuration format is a Python *script*, it is code, not data. Have a look at /etc/xen/xmexample.vti shipped as part of the Xen distribution, you will see imports and variables. This is recognized as a problem by the Xen people themselve now, and one of the reason that they are migrating to an XML format too.
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?
If you have xm configuration files containing just the declarations needed for xm in static form, then such a tool should be relatively easy, especially if written into Python, but as said it's not possible in the general case. Maybe such a python script could be provided in the distribution, if you provide one, but I expect the Xensource people to provide conversion to XML python code too, the only question is how differetn their XML will end up being compared to libvirt one now ;-) Daniel -- Daniel Veillard | Red Hat http://redhat.com/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

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 -=|
participants (3)
-
Daniel P. Berrange
-
Daniel Veillard
-
Juan Walker