qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	qemu-block@nongnu.org, Wouter Verhelst <w@uter.be>
Subject: [Qemu-devel] [PATCH 10/15] nbd: allow setting of an export name for qemu-nbd server
Date: Fri, 27 Nov 2015 12:20:48 +0000	[thread overview]
Message-ID: <1448626853-27450-11-git-send-email-berrange@redhat.com> (raw)
In-Reply-To: <1448626853-27450-1-git-send-email-berrange@redhat.com>

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 a "--exportname NAME" argument to qemu-nbd which allows
the user to set an explicit export name. When --exportname is
set the server will always use the new style 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(-)

diff --git a/qemu-nbd.c b/qemu-nbd.c
index 42ccf05..3f7f2222 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -47,6 +47,7 @@
 #define QEMU_NBD_OPT_OBJECT        5
 
 static NBDExport *exp;
+static bool newproto;
 static int verbose;
 static char *srcpath;
 static SocketAddress *saddr;
@@ -341,7 +342,7 @@ static gboolean nbd_accept(QIOChannel *ioc, GIOCondition cond, gpointer opaque)
         return TRUE;
     }
 
-    if (nbd_client_new(exp, cioc, nbd_client_closed)) {
+    if (nbd_client_new(newproto ? NULL : exp, cioc, nbd_client_closed)) {
         nb_fds++;
         nbd_update_server_watch();
     }
@@ -469,7 +470,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' },
@@ -493,6 +494,7 @@ int main(int argc, char **argv)
         { "persistent", 0, NULL, 't' },
         { "verbose", 0, NULL, 'v' },
         { "object", 1, NULL, QEMU_NBD_OPT_OBJECT },
+        { "exportname", 1, NULL, 'x' },
         { NULL, 0, NULL, 0 }
     };
     int ch;
@@ -510,6 +512,7 @@ int main(int argc, char **argv)
     BlockdevDetectZeroesOptions detect_zeroes = BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF;
     QDict *options = NULL;
     QemuOpts *opts;
+    const char *exportname = 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.
@@ -645,6 +648,9 @@ int main(int argc, char **argv)
         case 't':
             persistent = 1;
             break;
+        case 'x':
+            exportname = optarg;
+            break;
         case 'v':
             verbose = 1;
             break;
@@ -812,6 +818,10 @@ int main(int argc, char **argv)
     if (!exp) {
         errx(EXIT_FAILURE, "%s", error_get_pretty(local_err));
     }
+    if (exportname) {
+        nbd_export_set_name(exp, exportname);
+        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 3b2004e..6ff3920 100644
--- a/qemu-nbd.texi
+++ b/qemu-nbd.texi
@@ -64,6 +64,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, --exportname=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

  parent reply	other threads:[~2015-11-27 12:21 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-27 12:20 [Qemu-devel] [PATCH 00/15] Implement TLS support to QEMU NBD server & client Daniel P. Berrange
2015-11-27 12:20 ` [Qemu-devel] [PATCH 01/15] qom: add user_creatable_add & user_creatable_del methods Daniel P. Berrange
2015-11-27 12:20 ` [Qemu-devel] [PATCH 02/15] qemu-nbd: add support for --object command line arg Daniel P. Berrange
2015-11-27 12:20 ` [Qemu-devel] [PATCH 03/15] nbd: convert block client to use I/O channels for connection setup Daniel P. Berrange
2015-11-27 12:20 ` [Qemu-devel] [PATCH 04/15] nbd: convert qemu-nbd server " Daniel P. Berrange
2015-11-27 12:20 ` [Qemu-devel] [PATCH 05/15] nbd: convert blockdev NBD " Daniel P. Berrange
2015-11-27 12:20 ` [Qemu-devel] [PATCH 06/15] nbd: convert to using I/O channels for actual socket I/O Daniel P. Berrange
2015-11-27 12:20 ` [Qemu-devel] [PATCH 07/15] nbd: invert client logic for negotiating protocol version Daniel P. Berrange
2015-11-27 12:20 ` [Qemu-devel] [PATCH 08/15] nbd: make server compliant with fixed newstyle spec Daniel P. Berrange
2015-11-27 12:20 ` [Qemu-devel] [PATCH 09/15] nbd: make client request fixed new style if advertized Daniel P. Berrange
2015-11-27 12:20 ` Daniel P. Berrange [this message]
2015-11-27 12:20 ` [Qemu-devel] [PATCH 11/15] nbd: pick first exported volume if no export name is requested Daniel P. Berrange
2015-11-27 12:20 ` [Qemu-devel] [PATCH 12/15] nbd: implement TLS support in the protocol negotiation Daniel P. Berrange
2015-11-28 10:28   ` Wouter Verhelst
2015-12-02 10:45     ` Daniel P. Berrange
2015-11-27 12:20 ` [Qemu-devel] [PATCH 13/15] nbd: enable use of TLS with NBD block driver Daniel P. Berrange
2015-11-27 12:20 ` [Qemu-devel] [PATCH 14/15] nbd: enable use of TLS with qemu-nbd server Daniel P. Berrange
2015-11-27 12:20 ` [Qemu-devel] [PATCH 15/15] nbd: enable use of TLS with nbd-server-start command Daniel P. Berrange
2015-11-27 14:06 ` [Qemu-devel] [PATCH 00/15] Implement TLS support to QEMU NBD server & client Wouter Verhelst
2015-12-03 14:53   ` Wouter Verhelst
2015-12-02 12:56 ` Wouter Verhelst
2015-12-02 13:37   ` Daniel P. Berrange
2015-12-02 13:45     ` Wouter Verhelst

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1448626853-27450-11-git-send-email-berrange@redhat.com \
    --to=berrange@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=w@uter.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).