thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-qemu-nbd-Pass-max-connections-to-blockdev-layer.patch

586cba
From e6aae1d0368a152924c38775e517f4e83c1d898b Mon Sep 17 00:00:00 2001
586cba
From: Eric Blake <eblake@redhat.com>
586cba
Date: Wed, 11 May 2022 19:49:23 -0500
586cba
Subject: [PATCH 1/2] qemu-nbd: Pass max connections to blockdev layer
586cba
MIME-Version: 1.0
586cba
Content-Type: text/plain; charset=UTF-8
586cba
Content-Transfer-Encoding: 8bit
586cba
586cba
RH-Author: Eric Blake <eblake@redhat.com>
586cba
RH-MergeRequest: 90: Advertise MULTI_CONN on writeable NBD servers
586cba
RH-Commit: [1/2] b0e33fd125bf3523b8b9a4dead3c8bb2342bfd4e (ebblake/centos-qemu-kvm)
586cba
RH-Bugzilla: 1708300
586cba
RH-Acked-by: Nir Soffer <None>
586cba
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
586cba
RH-Acked-by: Daniel P. Berrangé <berrange@redhat.com>
586cba
586cba
The next patch wants to adjust whether the NBD server code advertises
586cba
MULTI_CONN based on whether it is known if the server limits to
586cba
exactly one client.  For a server started by QMP, this information is
586cba
obtained through nbd_server_start (which can support more than one
586cba
export); but for qemu-nbd (which supports exactly one export), it is
586cba
controlled only by the command-line option -e/--shared.  Since we
586cba
already have a hook function used by qemu-nbd, it's easiest to just
586cba
alter its signature to fit our needs.
586cba
586cba
Signed-off-by: Eric Blake <eblake@redhat.com>
586cba
Message-Id: <20220512004924.417153-2-eblake@redhat.com>
586cba
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
586cba
(cherry picked from commit a5fced40212ed73c715ca298a2929dd4d99c9999)
586cba
Signed-off-by: Eric Blake <eblake@redhat.com>
586cba
---
586cba
 blockdev-nbd.c      | 8 ++++----
586cba
 include/block/nbd.h | 2 +-
586cba
 qemu-nbd.c          | 2 +-
586cba
 3 files changed, 6 insertions(+), 6 deletions(-)
586cba
586cba
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
586cba
index 9840d25a82..add41a23af 100644
586cba
--- a/blockdev-nbd.c
586cba
+++ b/blockdev-nbd.c
586cba
@@ -30,18 +30,18 @@ typedef struct NBDServerData {
586cba
 } NBDServerData;
586cba
 
586cba
 static NBDServerData *nbd_server;
586cba
-static bool is_qemu_nbd;
586cba
+static int qemu_nbd_connections = -1; /* Non-negative if this is qemu-nbd */
586cba
 
586cba
 static void nbd_update_server_watch(NBDServerData *s);
586cba
 
586cba
-void nbd_server_is_qemu_nbd(bool value)
586cba
+void nbd_server_is_qemu_nbd(int max_connections)
586cba
 {
586cba
-    is_qemu_nbd = value;
586cba
+    qemu_nbd_connections = max_connections;
586cba
 }
586cba
 
586cba
 bool nbd_server_is_running(void)
586cba
 {
586cba
-    return nbd_server || is_qemu_nbd;
586cba
+    return nbd_server || qemu_nbd_connections >= 0;
586cba
 }
586cba
 
586cba
 static void nbd_blockdev_client_closed(NBDClient *client, bool ignored)
586cba
diff --git a/include/block/nbd.h b/include/block/nbd.h
586cba
index a98eb665da..c5a29ce1c6 100644
586cba
--- a/include/block/nbd.h
586cba
+++ b/include/block/nbd.h
586cba
@@ -344,7 +344,7 @@ void nbd_client_new(QIOChannelSocket *sioc,
586cba
 void nbd_client_get(NBDClient *client);
586cba
 void nbd_client_put(NBDClient *client);
586cba
 
586cba
-void nbd_server_is_qemu_nbd(bool value);
586cba
+void nbd_server_is_qemu_nbd(int max_connections);
586cba
 bool nbd_server_is_running(void);
586cba
 void nbd_server_start(SocketAddress *addr, const char *tls_creds,
586cba
                       const char *tls_authz, uint32_t max_connections,
586cba
diff --git a/qemu-nbd.c b/qemu-nbd.c
586cba
index 713e7557a9..8c25ae93df 100644
586cba
--- a/qemu-nbd.c
586cba
+++ b/qemu-nbd.c
586cba
@@ -1087,7 +1087,7 @@ int main(int argc, char **argv)
586cba
 
586cba
     bs->detect_zeroes = detect_zeroes;
586cba
 
586cba
-    nbd_server_is_qemu_nbd(true);
586cba
+    nbd_server_is_qemu_nbd(shared);
586cba
 
586cba
     export_opts = g_new(BlockExportOptions, 1);
586cba
     *export_opts = (BlockExportOptions) {
586cba
-- 
586cba
2.31.1
586cba