From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38913) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTZhu-0006ky-ME for qemu-devel@nongnu.org; Wed, 10 Feb 2016 13:41:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTZht-0005nA-H1 for qemu-devel@nongnu.org; Wed, 10 Feb 2016 13:41:42 -0500 From: "Daniel P. Berrange" Date: Wed, 10 Feb 2016 18:41:08 +0000 Message-Id: <1455129674-17255-11-git-send-email-berrange@redhat.com> In-Reply-To: <1455129674-17255-1-git-send-email-berrange@redhat.com> References: <1455129674-17255-1-git-send-email-berrange@redhat.com> Subject: [Qemu-devel] [PATCH v6 10/16] nbd: allow setting of an export name for qemu-nbd server List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , qemu-block@nongnu.org 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 --- qemu-nbd.c | 14 ++++++++++++-- qemu-nbd.texi | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/qemu-nbd.c b/qemu-nbd.c index 5e54290..9710a26 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -44,6 +44,7 @@ #define QEMU_NBD_OPT_OBJECT 5 static NBDExport *exp; +static bool newproto; static int verbose; static char *srcpath; static SocketAddress *saddr; @@ -339,7 +340,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; @@ -413,7 +414,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", 0, NULL, 'h' }, { "version", 0, NULL, 'V' }, @@ -437,6 +438,7 @@ int main(int argc, char **argv) { "persistent", 0, NULL, 't' }, { "verbose", 0, NULL, 'v' }, { "object", 1, NULL, QEMU_NBD_OPT_OBJECT }, + { "export-name", 1, NULL, 'x' }, { NULL, 0, NULL, 0 } }; int ch; @@ -453,6 +455,7 @@ int main(int argc, char **argv) Error *local_err = NULL; BlockdevDetectZeroesOptions detect_zeroes = BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF; QDict *options = NULL; + 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. @@ -604,6 +607,9 @@ int main(int argc, char **argv) case 't': persistent = 1; break; + case 'x': + export_name = optarg; + break; case 'v': verbose = 1; break; @@ -783,6 +789,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) { diff --git a/qemu-nbd.texi b/qemu-nbd.texi index a56ebc3..2516963 100644 --- a/qemu-nbd.texi +++ b/qemu-nbd.texi @@ -73,6 +73,9 @@ Disconnect the device @var{dev} Allow up to @var{num} clients to share the device (default @samp{1}) @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 -- 2.5.0