Permalink
Browse files

lib: Add direct support for the NBD (Network Block Device) protocol.

You can now add remote NBD drives using:

 ><fs> add-drive "" format:raw protocol:nbd server:localhost

(Note that you also need to add port:NNNN if the server is running on
a non-standard port).

The corresponding qemu-nbd service can be started by doing:

 qemu-nbd disk.img -t

This commit also adds a test.
  • Loading branch information...
rwmjones committed Mar 14, 2013
1 parent e7e2b56 commit 694a091d3faac78acbd0b5a368856b569c7ba5e2
Showing with 614 additions and 164 deletions.
  1. +1 −0 Makefile.am
  2. +2 −0 README
  3. +1 −0 configure.ac
  4. +35 −1 generator/actions.ml
  5. +190 −48 src/drives.c
  6. +17 −2 src/guestfs-internal.h
  7. +34 −0 src/guestfs.pod
  8. +44 −35 src/launch-appliance.c
  9. +180 −78 src/launch-libvirt.c
  10. +26 −0 tests/nbd/Makefile.am
  11. +84 −0 tests/nbd/test-nbd.pl
View
@@ -56,6 +56,7 @@ SUBDIRS += tests/rsync
SUBDIRS += tests/bigdirs
SUBDIRS += tests/disk-labels
SUBDIRS += tests/hotplug
SUBDIRS += tests/nbd
SUBDIRS += tests/regressions
endif
View
2 README
@@ -155,6 +155,8 @@ The full requirements are described below.
+--------------+-------------+---+-----------------------------------------+
| static glibc | | O | Used for testing only. |
+--------------+-------------+---+-----------------------------------------+
| qemu-nbd | | O | Used for testing only. |
+--------------+-------------+---+-----------------------------------------+
| findlib | | O | For the OCaml bindings. |
+--------------+-------------+---+-----------------------------------------+
| ocaml-gettext| | O | For localizing OCaml virt-* tools. |
View
@@ -1574,6 +1574,7 @@ AC_CONFIG_FILES([Makefile
tests/md/Makefile
tests/mount-local/Makefile
tests/mountable/Makefile
tests/nbd/Makefile
tests/ntfsclone/Makefile
tests/parallel/Makefile
tests/protocol/Makefile
View
@@ -1247,7 +1247,7 @@ not all belong to a single logical operating system
{ defaults with
name = "add_drive";
style = RErr, [String "filename"], [OBool "readonly"; OString "format"; OString "iface"; OString "name"; OString "label"];
style = RErr, [String "filename"], [OBool "readonly"; OString "format"; OString "iface"; OString "name"; OString "label"; OString "protocol"; OString "server"; OInt "port"];
once_had_no_optargs = true;
blocking = false;
fish_alias = ["add"];
@@ -1319,6 +1319,40 @@ the drive will also be named C</dev/disk/guestfs/I<label>>.
See L<guestfs(3)/DISK LABELS>.
=item C<protocol>
The optional protocol argument can be used to select an alternate
source protocol:
=over 4
=item C<protocol = \"file\">
C<filename> is interpreted as a local file or device.
This is the default if the optional protocol parameter
is omitted.
=item C<protocol = \"nbd\">
Connect to the Network Block Device server at C<server:port>.
See: L<guestfs(3)/NETWORK BLOCK DEVICES>.
=back
=item C<server>
For protocols which require access to a remote server, this
is the name of the server.
=item C<port>
For protocols which require access to a remote server, this
is the port number of the service.
If not specified, this defaults to the standard port for
the protocol, eg. 10809 when C<protocol> is C<\"nbd\">.
=back" };
{ defaults with
Oops, something went wrong.

0 comments on commit 694a091

Please sign in to comment.