Support for User Mode Linux in libvirt[1] may be of interest to people
on this list.

Regards,
Daniel

[1] http://libvirt.org/

----- Forwarded message from "Daniel P. Berrange" <[EMAIL PROTECTED]> -----

> Date: Thu, 16 Oct 2008 12:42:17 +0100
> From: "Daniel P. Berrange" <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: [libvirt] PATCH: Experimental User Mode Linux driver for libvirt
> 
> This patch implements a driver supporting User Mode Linux guests. User mode
> linux is a kind of paravirtualized kernel which runs on a plain Linux host.
> It requires no elevated privileges at all, except for some of the network
> integration. It is a pretty straightforward thing to invoke, so I figured
> it would be easy to write a driver to support it. I was right :-)
> 
> As with the QEMU driver, there are two styles of invocation
> 
>   uml:///system  - a single privileged, per host driver instance as root
>   uml:///session - a per-user unprivileged instance
> 
> The user mode linux docs recommend against running as root, so naturally
> I recommend use of uml:///session, though my testing is so far with
> uml:///system.
> 
> It supports the bare minimum  neccessary for a libvirt driver, namely start,
> stop, define, create, destroy, undefine against domains. For configuration
> it supports setting of memory limit, virtual disk devices, and paravirt
> console devices - good enough to get 'virsh console' working over a PTY,
> and dump XML config.
> 
> Like QEMU, UML has an admin monitor console. It is a little different
> though, using a UNIX domain socket, in datagram mode, sending command
> strings back & forth. This actaully makes it a little easier to deal
> with in libvirt. User mode linux has a uml_mconsole command line tool
> to interact with it, but I directly implement the socket support in
> libvirt instead, so this driver does not (yet) have any dependancy on
> the UML utilities.
> 
> The driver is largely a clone of the QEMU driver, replacing the bit which
> builds the command line argv, and all code dealing with the QEMU monitor.
> Since the monitor socket is datagram based, we can't make use of it for
> detecting VM shutdown  as we do with QEMU/LXC. So instead, I make use of
> inotify, to monitor $HOME/.uml which is populated witha directory for
> each VM. When we see a directory created, libvirt marks the corresponding
> VM as running, finds it PID & probes the monitor for the PTY config. When
> we see a directory deleted, libvirt makes the VM as shutoff and frees any
> resources its holding. This actually works very nicely & simply.
> 
> An example config I'm using for testing is
> 
> <domain type='uml'>
>   <name>demo</name>
>   <uuid>b4433fc2-a22e-ffb3-0a3d-9c173b395800</uuid>
>   <memory>500000</memory>
>   <os>
>     <type arch='x86_64'>uml</type>
>     <kernel>/home/berrange/linux</kernel>
>   </os>
>   <devices>
>     <disk type='file' device='disk'>
>       <source file='/home/berrange/FedoraCore6-AMD64-root_fs'/>
>       <target dev='ubd0' bus='uml'/>
>     </disk>
>     <console type='pty'>
>        <target port='0'/>
>     </console>
>     <serial type='tcp'>
>        <source mode='bind' host='localhost' service='9000'/>
>        <target port='0'/>
>     </serial>
>     <serial type='pty'>
>        <target port='3'/>
>     </serial>
>   </devices>
> </domain>
> 
> The user mode linux kernel, has the device emulator built-in, so there's no
> need to specify the device emulator path explicitly. The kernel I built
> straight from latest 2.6.27 sources, and the root filesystem I downloaded
> from the UML website. I've been testing with latest libvirt CVS, on  a
> Fedora 9 x86_64 host.
> 
> If you save that config to a file 'demo.xml', you ought to be able todo
> 
>    virsh --connect uml:///system define demo.xml
>    virsh --connect uml:///system start demo
>    virsh --connect uml:///system console demo
> 
> Though  there is still a small race whereby we can ask for the PTY device
> before its been created, causing console to fail.
> 
> If things go wrong /var/log/libvirt/uml/$NAME.log contains log messages,
> The configuration is stored in /etc/libvirt/uml/$NAME.xml, or in
> $HOME/.libvirt/uml/$NAME.xml, and you can also query stuff with mconsole
> by doing  'uml_mconsole $NAME'
> 
> This isn't quite ready to merge, but I thought I'd send it here to make
> people aware of it.
> 
>  configure.in                |    8 
>  include/libvirt/virterror.h |    1 
>  src/Makefile.am             |    9 
>  src/domain_conf.c           |   47 -
>  src/domain_conf.h           |    1 
>  src/driver.h                |    3 
>  src/libvirt.c               |    6 
>  src/qemu_conf.c             |    3 
>  src/remote_internal.c       |   16 
>  src/uml_conf.c              |  404 ++++++++++
>  src/uml_conf.h              |   72 +
>  src/uml_driver.c            | 1771 
> ++++++++++++++++++++++++++++++++++++++++++++
>  src/uml_driver.h            |   34 
>  src/virterror.c             |    4 
>  14 files changed, 2355 insertions(+), 24 deletions(-)
> 
> 
> Daniel
----- End forwarded message -----

-- 
|: 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 :|

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

Reply via email to