[libvirt] Adding VirtualBox support to libvirt

Daniel P. Berrange berrange at redhat.com
Thu Feb 26 15:17:03 UTC 2009


On Thu, Feb 26, 2009 at 03:26:34PM +0100, Pritesh Kothari wrote:
> Hi,
> 
> As mentioned in the earlier mail, I have started the work on 
> adding Virtualbox support to libvirt. I have completed almost
> all the basic functionality. Currently I can start, shutdown,
> reboot, list and suspend/resume the domains.
> 
> Now I am in the process writing code for creating/defining the domains
> and thats where i need some help. I am not familiar with the exact XML format 
> required. I have gone through the docs at http://libvirt.org/formatdomain.html 
> as well as the code and have few question regarding the same as below:
> 
> Is the XML format for defining the Domains common to all the hypervisors? If 
> not then how should I start about defining it for Virtualbox?

The XML format has always been intended to be the same across drivers. A
few releases ago, we introduced generic internal API for parsing the domain
XML format, to guarentee that all drivers use the same format. You can
see the APIs to use in src/domain_conf.h, and the schema in docs/schemas/.

That said, we need to do some additions for VirtualBox eventually, depending
on just what configs it supports. So if you find things you need that are
not yet covered by our domain XML schema, post details to the list and we
can figure out the best way to represent them.

> What exactly does the tag <os_type>xen</os_type> exactly mean? how can xen, 
> hvm, etc be an os type?

This tag refers to the ABI of the guest kernel

 - hvm :  unmodified bare metal OS - ie FullyVirtualized
 - xen:   xen 3.0  paravirt ABI


VirtualBox is a fullyvirt technology, so I expect you'll only want to
support 'hvm' as an os type. 

You declare what architectures, and SO types you support when creating
your capabilities data - virCapabilityPtr - see src/capabities.h

> why virDomainCreate doesn't actually create the domain but it just starts it? 
> (virDomainCreateXML actually creates it)

virDomainCreateXML() spawns an unmanaged guest, with no config file.

For a managed guest, virDomainDefineXML() writes the config file, and
virDomainCreate() launches a guest from that config.

> The rest of my question are more general and not related to XML def.
> 
> In src/qemu_driver.c:qemudGetVersion() why does the qemu driver have to take 
> the lock, i mean what can change while extracting the version info? is there 
> any specific reason? (this is true for other drivers like openvz, uml, etc as 
> well )

As of 0.6.0, the libvirtd daemon is fully multi-threaded. This means
that many API calls can be using your driver concurrently. So every
driver API call you have (ie those registered in the 'virDriver' struct
must use one or more mutexs to ensure safe access to internal state.

> 
> I am using dlopen() and friends to open the VirtualBox library at runtime, is 
> it ok? cause I didn't see any driver doing something like this.

I think it depends on exactly how you are doing it - best to just post the
patches and we can discuss whether it looks reasonable then. Why did you
dlopen() instead of just linking to it directly ?

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




More information about the libvir-list mailing list