[Libguestfs] [PATCH libnbd 0/2] api: Add support for AF_VSOCK.

Richard W.M. Jones rjones at redhat.com
Fri Oct 18 15:39:11 UTC 2019


This is a series of patches to libnbd and nbdkit adding AF_VSOCK
support.

On the host side it allows you to start an nbdkit instance which
listens on a virtio-vsock socket:

$ ./nbdkit -fv --vsock memory 1G 
...
nbdkit: debug: bound to vsock 2:10809

On the guest side you can then use libnbd to connect to the server:

$ ./run nbdsh -c 'h.connect_vsock(2, 10809)' -c 'print(h.get_size())'
1073741824

$ ./run nbdfuse mp --vsock 2 10809 &
$ ll mp/
total 0
-rw-rw-rw-. 1 rjones rjones 1073741824 Oct 18 16:23 nbd
$ dd if=/dev/random of=mp/nbd bs=1024 count=100 conv=notrunc,nocreat
dd: warning: partial read (84 bytes); suggest iflag=fullblock
0+100 records in
0+100 records out
6851 bytes (6.9 kB, 6.7 KiB) copied, 0.013797 s, 497 kB/s

(Performance of FUSE is not great, it should be better using raw
libnbd.)

I mainly wrote this to show that it can be done.  It's unclear if this
would be faster or slower than the usual way that NBD devices are
exposed to guests via virtio-blk/-scsi.

https://wiki.qemu.org/Features/VirtioVsock

Thanks: Stefan Hajnoczi for help with debugging this.





More information about the Libguestfs mailing list