I use the NBD protocol to connect a virtual machine to a disk image.
I'd like to allow the client to specify the file to use.
Here is what I propose, all your comments are welcome:
* NBD server side:
- put all the disk images in a directory, for instance:
# ls /ISO
ubuntu-6.06-desktop-amd64.iso
ubuntu-7.10-desktop-amd64.iso
ubuntu-8.04-desktop-i386.iso
- run the NBD server with a new parameter to specify the directory
instead of the filename
# nbd-server 1024 --read-only --directory /ISO
* NBD client side
nbd-client isoserver 1024 /dev/nbd0 ubuntu-8.04-desktop-i386.iso
* protocol changes:
- when used with "--directory", nbd-server sends a disk size of 0 in the
negotiate operation.
- when nbd-client receive a disk size of zero, it sends a filename
(first bytes is the size of the filename, following bytes are the
filename).
- nbd-server receives the filename, opens the file (to avoid security
issues, we use "basename(filename)"), and re-sends a negotiate packet
with the good size.
- next is as ususal.