Blame SOURCES/kvm-qemu-nbd-drop-old-style-negotiation.patch

7711c0
From e7b2b502ad9b10b852c507447e34e3212a274cee Mon Sep 17 00:00:00 2001
7711c0
From: John Snow <jsnow@redhat.com>
7711c0
Date: Fri, 22 Mar 2019 03:22:24 +0100
7711c0
Subject: [PATCH 057/163] qemu-nbd: drop old-style negotiation
7711c0
7711c0
RH-Author: John Snow <jsnow@redhat.com>
7711c0
Message-id: <20190322032241.8111-12-jsnow@redhat.com>
7711c0
Patchwork-id: 85096
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 11/28] qemu-nbd: 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
Use new-style negotiation always, with default "" (empty) export name
7711c0
if it is not specified with '-x' option.
7711c0
7711c0
qemu as client can manage either style since 2.6.0, commit 69b49502d8
7711c0
7711c0
For comparison:
7711c0
7711c0
nbd 3.10 dropped oldstyle long ago (Mar 2015):
7711c0
https://github.com/NetworkBlockDevice/nbd/commit/36940193
7711c0
7711c0
nbdkit 1.3 switched its default to newstyle (Jan 2018):
7711c0
https://github.com/libguestfs/nbdkit/commit/b2a8aecc
7711c0
https://github.com/libguestfs/nbdkit/commit/8158e773
7711c0
7711c0
Furthermore, if a client that only speaks oldstyle still needs to
7711c0
communicate to qemu, nbdkit remains available to perform the
7711c0
translation between the two protocols.
7711c0
7711c0
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7711c0
Message-Id: <20181003170228.95973-2-vsementsov@virtuozzo.com>
7711c0
Reviewed-by: Eric Blake <eblake@redhat.com>
7711c0
[eblake: enhance commit message]
7711c0
Signed-off-by: Eric Blake <eblake@redhat.com>
7711c0
(cherry picked from commit f5cd0bb5174dcd6e8c160d7992fb89f09f264ef0)
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 qemu-nbd.c | 25 ++++++-------------------
7711c0
 1 file changed, 6 insertions(+), 19 deletions(-)
7711c0
7711c0
diff --git a/qemu-nbd.c b/qemu-nbd.c
7711c0
index 66e023f..6aaebe7 100644
7711c0
--- a/qemu-nbd.c
7711c0
+++ b/qemu-nbd.c
7711c0
@@ -56,7 +56,6 @@
7711c0
 #define MBR_SIZE 512
7711c0
 
7711c0
 static NBDExport *exp;
7711c0
-static bool newproto;
7711c0
 static int verbose;
7711c0
 static char *srcpath;
7711c0
 static SocketAddress *saddr;
7711c0
@@ -84,8 +83,8 @@ static void usage(const char *name)
7711c0
 "  -e, --shared=NUM          device can be shared by NUM clients (default '1')\n"
7711c0
 "  -t, --persistent          don't exit on the last connection\n"
7711c0
 "  -v, --verbose             display extra debugging information\n"
7711c0
-"  -x, --export-name=NAME    expose export by name\n"
7711c0
-"  -D, --description=TEXT    with -x, also export a human-readable description\n"
7711c0
+"  -x, --export-name=NAME    expose export by name (default is empty string)\n"
7711c0
+"  -D, --description=TEXT    export a human-readable description\n"
7711c0
 "\n"
7711c0
 "Exposing part of the image:\n"
7711c0
 "  -o, --offset=OFFSET       offset into the image\n"
7711c0
@@ -355,8 +354,7 @@ static void nbd_accept(QIONetListener *listener, QIOChannelSocket *cioc,
7711c0
 
7711c0
     nb_fds++;
7711c0
     nbd_update_server_watch();
7711c0
-    nbd_client_new(newproto ? NULL : exp, cioc,
7711c0
-                   tlscreds, NULL, nbd_client_closed);
7711c0
+    nbd_client_new(NULL, cioc, tlscreds, NULL, nbd_client_closed);
7711c0
 }
7711c0
 
7711c0
 static void nbd_update_server_watch(void)
7711c0
@@ -550,7 +548,7 @@ int main(int argc, char **argv)
7711c0
     Error *local_err = NULL;
7711c0
     BlockdevDetectZeroesOptions detect_zeroes = BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF;
7711c0
     QDict *options = NULL;
7711c0
-    const char *export_name = NULL;
7711c0
+    const char *export_name = ""; /* Default export name */
7711c0
     const char *export_description = NULL;
7711c0
     const char *tlscredsid = NULL;
7711c0
     bool imageOpts = false;
7711c0
@@ -809,11 +807,6 @@ int main(int argc, char **argv)
7711c0
             error_report("TLS is not supported with a host device");
7711c0
             exit(EXIT_FAILURE);
7711c0
         }
7711c0
-        if (!export_name) {
7711c0
-            /* Set the default NBD protocol export name, since
7711c0
-             * we *must* use new style protocol for TLS */
7711c0
-            export_name = "";
7711c0
-        }
7711c0
         tlscreds = nbd_get_tls_creds(tlscredsid, &local_err);
7711c0
         if (local_err) {
7711c0
             error_report("Failed to get TLS creds %s",
7711c0
@@ -1014,14 +1007,8 @@ int main(int argc, char **argv)
7711c0
         error_report_err(local_err);
7711c0
         exit(EXIT_FAILURE);
7711c0
     }
7711c0
-    if (export_name) {
7711c0
-        nbd_export_set_name(exp, export_name);
7711c0
-        nbd_export_set_description(exp, export_description);
7711c0
-        newproto = true;
7711c0
-    } else if (export_description) {
7711c0
-        error_report("Export description requires an export name");
7711c0
-        exit(EXIT_FAILURE);
7711c0
-    }
7711c0
+    nbd_export_set_name(exp, export_name);
7711c0
+    nbd_export_set_description(exp, export_description);
7711c0
 
7711c0
     if (device) {
7711c0
         int ret;
7711c0
-- 
7711c0
1.8.3.1
7711c0