[Libguestfs] Provide NBD via Browser over Websockets

Eric Blake eblake at redhat.com
Sat Oct 13 19:07:55 UTC 2018


[adding nbdkit readers]

On 10/13/18 1:39 PM, Eric Wheeler wrote:
> Hello all,
> 
> It might be neat to attach ISOs to KVM guests via websockets.  Basically
> the  browser would be the NBD "server" and an NBD client would run on the
> hypervisor, then use `virsh change-media vm1 hdc --insert /dev/nbd0` could
> use an ISO from my desk to boot from.

Are you using qemu as the hypervisor?  If you are using something else, 
like vmware, then using the kernel NBD module as the NBD client to 
expose the browser-as-server via /dev/nbd0 is reasonable since 
practically any hypervisor will attach to a raw block device.  But if 
you are using qemu, I'd suggest that you use qemu directly as the NBD 
client, rather than indirecting through the kernel module (for that 
matter, qemu's NBD client knows how to efficiently handle sparse files 
if the server is capable, while to date the kernel nbd module does not). 
  Since you are using virsh, the libvirt list is a better resource for 
figuring out the command line and/or XML changes to direct qemu to 
connect as an NBD client.

> 
> Here's an HTML5 open file example:
> https://stackoverflow.com/questions/3582671/how-to-open-a-local-disk-file-with-javascript
> 
> and the NBD protocol looks simple enough to implement in javascript:
> https://stackoverflow.com/questions/17295140/where-is-the-network-block-device-format-describled
> 
> What do you think? Does anyone have an interest in doing this?

The nbdkit project (under the libguestfs umbrella) has already 
implemented an NBD server that can bridge to an image served over http, 
if you want to use that as a starting point.

Then the obvious question - do you really need to implement a solution 
using websockets through your browser in order to serve up a file on 
your desktop, or can you reuse existing solutions of a userspace NBD 
server to directly serve the file without involving the browser in the 
middle.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org




More information about the Libguestfs mailing list