|
|
7711c0 |
From 15a4aec1e61d9b1e1ad212fc60058d9ee95620f7 Mon Sep 17 00:00:00 2001
|
|
|
7711c0 |
From: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Date: Fri, 22 Mar 2019 03:22:25 +0100
|
|
|
7711c0 |
Subject: [PATCH 058/163] nbd/server: drop old-style negotiation
|
|
|
7711c0 |
|
|
|
7711c0 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Message-id: <20190322032241.8111-13-jsnow@redhat.com>
|
|
|
7711c0 |
Patchwork-id: 85110
|
|
|
7711c0 |
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 12/28] nbd/server: drop old-style negotiation
|
|
|
7711c0 |
Bugzilla: 1691563
|
|
|
7711c0 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
After the previous commit, nbd_client_new's first parameter is always
|
|
|
7711c0 |
NULL. Let's drop it with all corresponding old-style negotiation code
|
|
|
7711c0 |
path which is unreachable now.
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
7711c0 |
Message-Id: <20181003170228.95973-3-vsementsov@virtuozzo.com>
|
|
|
7711c0 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
[eblake: re-wrap short line]
|
|
|
7711c0 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
(cherry picked from commit 7f7dfe2a53446072c136d349e3150c84d322b2bc)
|
|
|
7711c0 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
---
|
|
|
7711c0 |
blockdev-nbd.c | 3 +--
|
|
|
7711c0 |
include/block/nbd.h | 3 +--
|
|
|
7711c0 |
nbd/server.c | 53 +++++++++++++++--------------------------------------
|
|
|
7711c0 |
qemu-nbd.c | 2 +-
|
|
|
7711c0 |
4 files changed, 18 insertions(+), 43 deletions(-)
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
|
|
|
7711c0 |
index 1ef1104..1d170c8 100644
|
|
|
7711c0 |
--- a/blockdev-nbd.c
|
|
|
7711c0 |
+++ b/blockdev-nbd.c
|
|
|
7711c0 |
@@ -36,8 +36,7 @@ static void nbd_accept(QIONetListener *listener, QIOChannelSocket *cioc,
|
|
|
7711c0 |
gpointer opaque)
|
|
|
7711c0 |
{
|
|
|
7711c0 |
qio_channel_set_name(QIO_CHANNEL(cioc), "nbd-server");
|
|
|
7711c0 |
- nbd_client_new(NULL, cioc,
|
|
|
7711c0 |
- nbd_server->tlscreds, NULL,
|
|
|
7711c0 |
+ nbd_client_new(cioc, nbd_server->tlscreds, NULL,
|
|
|
7711c0 |
nbd_blockdev_client_closed);
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/include/block/nbd.h b/include/block/nbd.h
|
|
|
7711c0 |
index a53b0cf..6a5bfe5 100644
|
|
|
7711c0 |
--- a/include/block/nbd.h
|
|
|
7711c0 |
+++ b/include/block/nbd.h
|
|
|
7711c0 |
@@ -310,8 +310,7 @@ void nbd_export_set_name(NBDExport *exp, const char *name);
|
|
|
7711c0 |
void nbd_export_set_description(NBDExport *exp, const char *description);
|
|
|
7711c0 |
void nbd_export_close_all(void);
|
|
|
7711c0 |
|
|
|
7711c0 |
-void nbd_client_new(NBDExport *exp,
|
|
|
7711c0 |
- QIOChannelSocket *sioc,
|
|
|
7711c0 |
+void nbd_client_new(QIOChannelSocket *sioc,
|
|
|
7711c0 |
QCryptoTLSCreds *tlscreds,
|
|
|
7711c0 |
const char *tlsaclname,
|
|
|
7711c0 |
void (*close_fn)(NBDClient *, bool));
|
|
|
7711c0 |
diff --git a/nbd/server.c b/nbd/server.c
|
|
|
7711c0 |
index df76324..d414861 100644
|
|
|
7711c0 |
--- a/nbd/server.c
|
|
|
7711c0 |
+++ b/nbd/server.c
|
|
|
7711c0 |
@@ -1253,7 +1253,6 @@ static coroutine_fn int nbd_negotiate(NBDClient *client, Error **errp)
|
|
|
7711c0 |
const uint16_t myflags = (NBD_FLAG_HAS_FLAGS | NBD_FLAG_SEND_TRIM |
|
|
|
7711c0 |
NBD_FLAG_SEND_FLUSH | NBD_FLAG_SEND_FUA |
|
|
|
7711c0 |
NBD_FLAG_SEND_WRITE_ZEROES | NBD_FLAG_SEND_CACHE);
|
|
|
7711c0 |
- bool oldStyle;
|
|
|
7711c0 |
|
|
|
7711c0 |
/* Old style negotiation header, no room for options
|
|
|
7711c0 |
[ 0 .. 7] passwd ("NBDMAGIC")
|
|
|
7711c0 |
@@ -1274,33 +1273,19 @@ static coroutine_fn int nbd_negotiate(NBDClient *client, Error **errp)
|
|
|
7711c0 |
trace_nbd_negotiate_begin();
|
|
|
7711c0 |
memcpy(buf, "NBDMAGIC", 8);
|
|
|
7711c0 |
|
|
|
7711c0 |
- oldStyle = client->exp != NULL && !client->tlscreds;
|
|
|
7711c0 |
- if (oldStyle) {
|
|
|
7711c0 |
- trace_nbd_negotiate_old_style(client->exp->size,
|
|
|
7711c0 |
- client->exp->nbdflags | myflags);
|
|
|
7711c0 |
- stq_be_p(buf + 8, NBD_CLIENT_MAGIC);
|
|
|
7711c0 |
- stq_be_p(buf + 16, client->exp->size);
|
|
|
7711c0 |
- stl_be_p(buf + 24, client->exp->nbdflags | myflags);
|
|
|
7711c0 |
+ stq_be_p(buf + 8, NBD_OPTS_MAGIC);
|
|
|
7711c0 |
+ stw_be_p(buf + 16, NBD_FLAG_FIXED_NEWSTYLE | NBD_FLAG_NO_ZEROES);
|
|
|
7711c0 |
|
|
|
7711c0 |
- if (nbd_write(client->ioc, buf, sizeof(buf), errp) < 0) {
|
|
|
7711c0 |
- error_prepend(errp, "write failed: ");
|
|
|
7711c0 |
- return -EINVAL;
|
|
|
7711c0 |
- }
|
|
|
7711c0 |
- } else {
|
|
|
7711c0 |
- stq_be_p(buf + 8, NBD_OPTS_MAGIC);
|
|
|
7711c0 |
- stw_be_p(buf + 16, NBD_FLAG_FIXED_NEWSTYLE | NBD_FLAG_NO_ZEROES);
|
|
|
7711c0 |
-
|
|
|
7711c0 |
- if (nbd_write(client->ioc, buf, 18, errp) < 0) {
|
|
|
7711c0 |
- error_prepend(errp, "write failed: ");
|
|
|
7711c0 |
- return -EINVAL;
|
|
|
7711c0 |
- }
|
|
|
7711c0 |
- ret = nbd_negotiate_options(client, myflags, errp);
|
|
|
7711c0 |
- if (ret != 0) {
|
|
|
7711c0 |
- if (ret < 0) {
|
|
|
7711c0 |
- error_prepend(errp, "option negotiation failed: ");
|
|
|
7711c0 |
- }
|
|
|
7711c0 |
- return ret;
|
|
|
7711c0 |
+ if (nbd_write(client->ioc, buf, 18, errp) < 0) {
|
|
|
7711c0 |
+ error_prepend(errp, "write failed: ");
|
|
|
7711c0 |
+ return -EINVAL;
|
|
|
7711c0 |
+ }
|
|
|
7711c0 |
+ ret = nbd_negotiate_options(client, myflags, errp);
|
|
|
7711c0 |
+ if (ret != 0) {
|
|
|
7711c0 |
+ if (ret < 0) {
|
|
|
7711c0 |
+ error_prepend(errp, "option negotiation failed: ");
|
|
|
7711c0 |
}
|
|
|
7711c0 |
+ return ret;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
assert(!client->optlen);
|
|
|
7711c0 |
@@ -2396,13 +2381,8 @@ static void nbd_client_receive_next_request(NBDClient *client)
|
|
|
7711c0 |
static coroutine_fn void nbd_co_client_start(void *opaque)
|
|
|
7711c0 |
{
|
|
|
7711c0 |
NBDClient *client = opaque;
|
|
|
7711c0 |
- NBDExport *exp = client->exp;
|
|
|
7711c0 |
Error *local_err = NULL;
|
|
|
7711c0 |
|
|
|
7711c0 |
- if (exp) {
|
|
|
7711c0 |
- nbd_export_get(exp);
|
|
|
7711c0 |
- QTAILQ_INSERT_TAIL(&exp->clients, client, next);
|
|
|
7711c0 |
- }
|
|
|
7711c0 |
qemu_co_mutex_init(&client->send_lock);
|
|
|
7711c0 |
|
|
|
7711c0 |
if (nbd_negotiate(client, &local_err)) {
|
|
|
7711c0 |
@@ -2417,13 +2397,11 @@ static coroutine_fn void nbd_co_client_start(void *opaque)
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
/*
|
|
|
7711c0 |
- * Create a new client listener on the given export @exp, using the
|
|
|
7711c0 |
- * given channel @sioc. Begin servicing it in a coroutine. When the
|
|
|
7711c0 |
- * connection closes, call @close_fn with an indication of whether the
|
|
|
7711c0 |
- * client completed negotiation.
|
|
|
7711c0 |
+ * Create a new client listener using the given channel @sioc.
|
|
|
7711c0 |
+ * Begin servicing it in a coroutine. When the connection closes, call
|
|
|
7711c0 |
+ * @close_fn with an indication of whether the client completed negotiation.
|
|
|
7711c0 |
*/
|
|
|
7711c0 |
-void nbd_client_new(NBDExport *exp,
|
|
|
7711c0 |
- QIOChannelSocket *sioc,
|
|
|
7711c0 |
+void nbd_client_new(QIOChannelSocket *sioc,
|
|
|
7711c0 |
QCryptoTLSCreds *tlscreds,
|
|
|
7711c0 |
const char *tlsaclname,
|
|
|
7711c0 |
void (*close_fn)(NBDClient *, bool))
|
|
|
7711c0 |
@@ -2433,7 +2411,6 @@ void nbd_client_new(NBDExport *exp,
|
|
|
7711c0 |
|
|
|
7711c0 |
client = g_new0(NBDClient, 1);
|
|
|
7711c0 |
client->refcount = 1;
|
|
|
7711c0 |
- client->exp = exp;
|
|
|
7711c0 |
client->tlscreds = tlscreds;
|
|
|
7711c0 |
if (tlscreds) {
|
|
|
7711c0 |
object_ref(OBJECT(client->tlscreds));
|
|
|
7711c0 |
diff --git a/qemu-nbd.c b/qemu-nbd.c
|
|
|
7711c0 |
index 6aaebe7..e76fe30 100644
|
|
|
7711c0 |
--- a/qemu-nbd.c
|
|
|
7711c0 |
+++ b/qemu-nbd.c
|
|
|
7711c0 |
@@ -354,7 +354,7 @@ static void nbd_accept(QIONetListener *listener, QIOChannelSocket *cioc,
|
|
|
7711c0 |
|
|
|
7711c0 |
nb_fds++;
|
|
|
7711c0 |
nbd_update_server_watch();
|
|
|
7711c0 |
- nbd_client_new(NULL, cioc, tlscreds, NULL, nbd_client_closed);
|
|
|
7711c0 |
+ nbd_client_new(cioc, tlscreds, NULL, nbd_client_closed);
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
static void nbd_update_server_watch(void)
|
|
|
7711c0 |
--
|
|
|
7711c0 |
1.8.3.1
|
|
|
7711c0 |
|