[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 10/16] nbd: allow setting of an export name for q
From: |
Daniel P. Berrange |
Subject: |
[Qemu-devel] [PATCH v5 10/16] nbd: allow setting of an export name for qemu-nbd server |
Date: |
Thu, 4 Feb 2016 13:50:16 +0000 |
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 <address@hidden>
---
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 c96e3ab..bf9a609 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -45,6 +45,7 @@
#define QEMU_NBD_OPT_OBJECT 5
static NBDExport *exp;
+static bool newproto;
static int verbose;
static char *srcpath;
static SocketAddress *saddr;
@@ -340,7 +341,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;
@@ -414,7 +415,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' },
@@ -438,6 +439,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;
@@ -454,6 +456,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.
@@ -605,6 +608,9 @@ int main(int argc, char **argv)
case 't':
persistent = 1;
break;
+ case 'x':
+ export_name = optarg;
+ break;
case 'v':
verbose = 1;
break;
@@ -784,6 +790,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 9f9daca..5fbe486 100644
--- a/qemu-nbd.texi
+++ b/qemu-nbd.texi
@@ -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
address@hidden -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
- [Qemu-devel] [PATCH v5 02/16] qemu-nbd: add support for --object command line arg, (continued)
- [Qemu-devel] [PATCH v5 02/16] qemu-nbd: add support for --object command line arg, Daniel P. Berrange, 2016/02/04
- [Qemu-devel] [PATCH v5 03/16] nbd: convert block client to use I/O channels for connection setup, Daniel P. Berrange, 2016/02/04
- [Qemu-devel] [PATCH v5 07/16] nbd: invert client logic for negotiating protocol version, Daniel P. Berrange, 2016/02/04
- [Qemu-devel] [PATCH v5 05/16] nbd: convert blockdev NBD server to use I/O channels for connection setup, Daniel P. Berrange, 2016/02/04
- [Qemu-devel] [PATCH v5 08/16] nbd: make server compliant with fixed newstyle spec, Daniel P. Berrange, 2016/02/04
- [Qemu-devel] [PATCH v5 11/16] nbd: always query export list in fixed new style protocol, Daniel P. Berrange, 2016/02/04
- [Qemu-devel] [PATCH v5 12/16] nbd: use "" as a default export name if none provided, Daniel P. Berrange, 2016/02/04
- [Qemu-devel] [PATCH v5 09/16] nbd: make client request fixed new style if advertized, Daniel P. Berrange, 2016/02/04
- [Qemu-devel] [PATCH v5 06/16] nbd: convert to using I/O channels for actual socket I/O, Daniel P. Berrange, 2016/02/04
- [Qemu-devel] [PATCH v5 13/16] nbd: implement TLS support in the protocol negotiation, Daniel P. Berrange, 2016/02/04
- [Qemu-devel] [PATCH v5 10/16] nbd: allow setting of an export name for qemu-nbd server,
Daniel P. Berrange <=
- [Qemu-devel] [PATCH v5 14/16] nbd: enable use of TLS with NBD block driver, Daniel P. Berrange, 2016/02/04
- [Qemu-devel] [PATCH v5 15/16] nbd: enable use of TLS with qemu-nbd server, Daniel P. Berrange, 2016/02/04
- [Qemu-devel] [PATCH v5 16/16] nbd: enable use of TLS with nbd-server-start command, Daniel P. Berrange, 2016/02/04