[libvirt] NBD server for libvirt domains using virDomainBlockPeek

Richard W.M. Jones rjones at redhat.com
Fri Jun 21 14:35:56 UTC 2013


This might be of interest to developers on this list.  I've written an
NBD server which can serve libvirt guest disks.  It uses the
virDomainBlockPeek API and so is necessarily read-only.

https://github.com/libguestfs/nbdkit
https://github.com/libguestfs/nbdkit/tree/master/plugins/libvirt

Example:

$ sudo ./src/nbdkit ./plugins/libvirt/.libs/libnbdkit-libvirt-plugin.so domain=f18x64 disk=vda -f -v

In another window:

$ guestfish --format=raw -a nbd://localhost -i

Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.

Type: 'help' for help on commands
      'man' to read the manual
      'quit' to quit the shell

Operating system: Fedora release 18 (Spherical Cow)
/dev/fedora/root mounted on /
/dev/sda1 mounted on /boot

><fs> ll /
total 90
dr-xr-xr-x.  18 root root  4096 Jan  9 17:14 .
drwxr-xr-x   23 1000 1000  4096 Jun 21 15:24 ..
lrwxrwxrwx.   1 root root     7 Jan  9 17:14 bin -> usr/bin
dr-xr-xr-x.   5 root root  1024 Mar 13 23:00 boot
drwxr-xr-x.   2 root root  4096 Feb 11 20:15 dev
drwxr-xr-x. 129 root root 12288 Mar 14 15:22 etc
drwxr-xr-x.   3 root root  4096 Feb 11 20:23 home
lrwxrwxrwx.   1 root root     7 Jan  9 17:14 lib -> usr/lib
lrwxrwxrwx.   1 root root     9 Jan  9 17:14 lib64 -> usr/lib64
drwx------.   2 root root 16384 Jan  9 17:12 lost+found
drwxr-xr-x.   2 root root  4096 Jul 19  2012 media
drwxr-xr-x.   4 root root  4096 Feb 12 08:59 mnt
drwxr-xr-x.   2 root root  4096 Jul 19  2012 opt
drwxr-xr-x.   2 root root  4096 Feb 11 20:15 proc
dr-xr-x---.   6 root root  4096 Mar 13 22:55 root
drwxr-xr-x.  26 root root  4096 Feb 11 20:20 run
lrwxrwxrwx.   1 root root     8 Jan  9 17:14 sbin -> usr/sbin
drwxr-xr-x.   2 root root  4096 Jul 19  2012 srv
drwxr-xr-x.   2 root root  4096 Feb 11 20:15 sys
drwxrwxrwt.  16 root root  4096 Mar 13 23:00 tmp
drwxr-xr-x.  13 root root  4096 Jan  9 17:14 usr
drwxr-xr-x.  19 root root  4096 Jan  9 17:17 var

><fs> cat /etc/redhat-release 
Fedora release 18 (Spherical Cow)

><fs> 

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top




More information about the libvir-list mailing list