@@ -47,6 +47,7 @@
#define QEMU_NBD_OPT_IMAGE_OPTS 261
static NBDExport *exp;
+static bool newproto;
static int verbose;
static char *srcpath;
static SocketAddress *saddr;
@@ -342,7 +343,7 @@ static gboolean nbd_accept(QIOChannel *ioc, GIOCondition cond, gpointer opaque)
nb_fds++;
nbd_update_server_watch();
- nbd_client_new(exp, cioc, nbd_client_closed);
+ nbd_client_new(newproto ? NULL : exp, cioc, nbd_client_closed);
object_unref(OBJECT(cioc));
return TRUE;
@@ -445,7 +446,7 @@ int main(int argc, char **argv)
off_t fd_size;
QemuOpts *sn_opts = NULL;
const char *sn_id_or_name = NULL;
- const char *sopt = "hVb:o:p:rsnP:c:dvk:e:f:tl:";
+ const char *sopt = "hVb:o:p:rsnP:c:dvk:e:f:tl:x:";
struct option lopt[] = {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
@@ -471,6 +472,7 @@ int main(int argc, char **argv)
{ "verbose", no_argument, NULL, 'v' },
{ "object", required_argument, NULL, QEMU_NBD_OPT_OBJECT },
{ "image-opts", no_argument, NULL, QEMU_NBD_OPT_IMAGE_OPTS },
+ { "export-name", required_argument, NULL, 'x' },
{ NULL, 0, NULL, 0 }
};
int ch;
@@ -489,6 +491,7 @@ int main(int argc, char **argv)
QDict *options = NULL;
QemuOpts *opts;
bool imageOpts = false;
+ const char *export_name = NULL;
/* The client thread uses SIGTERM to interrupt the server. A signal
* handler ensures that "qemu-nbd -v -c" exits with a nice status code.
@@ -640,6 +643,9 @@ int main(int argc, char **argv)
case 't':
persistent = 1;
break;
+ case 'x':
+ export_name = optarg;
+ break;
case 'v':
verbose = 1;
break;
@@ -840,6 +846,10 @@ int main(int argc, char **argv)
error_report_err(local_err);
exit(EXIT_FAILURE);
}
+ if (export_name) {
+ nbd_export_set_name(exp, export_name);
+ newproto = true;
+ }
server_ioc = qio_channel_socket_new();
if (qio_channel_socket_listen_sync(server_ioc, saddr, &local_err) < 0) {
@@ -63,6 +63,9 @@ Export QEMU disk image using NBD protocol.
force block driver for format @var{fmt} instead of auto-detecting
@item -t, --persistent
don't exit on the last connection
+@item -x NAME, --export-name=NAME
+ set the NDB volume export name. This switches the server to use
+ the new style NBD protocol negotiation
@item -v, --verbose
display extra debugging information
@item -h, --help
The qemu-nbd server currently always uses the old style protocol since it never sets any export name. This is a problem because future TLS support will require use of the new style protocol negotiation. This adds "--exportname NAME" / "-x NAME" arguments to qemu-nbd which allow the user to set an explicit export name. When an export name is set the server will always use the new style NBD protocol. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- qemu-nbd.c | 14 ++++++++++++-- qemu-nbd.texi | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-)