Skip to content

Commit 3dcf56e

Browse files
committed
qemu-nbd: Permit --shared=0 for unlimited clients
This gives us better feature parity with QMP nbd-server-start, where max-connections defaults to 0 for unlimited. Signed-off-by: Eric Blake <[email protected]> Message-Id: <[email protected]> Reviewed-by: Daniel P. Berrangé <[email protected]>
1 parent 582d421 commit 3dcf56e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

docs/tools/qemu-nbd.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ driver options if ``--image-opts`` is specified.
136136
.. option:: -e, --shared=NUM
137137

138138
Allow up to *NUM* clients to share the device (default
139-
``1``). Safe for readers, but for now, consistency is not
140-
guaranteed between multiple writers.
139+
``1``), 0 for unlimited. Safe for readers, but for now,
140+
consistency is not guaranteed between multiple writers.
141141

142142
.. option:: -t, --persistent
143143

qemu-nbd.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ static void *nbd_client_thread(void *arg)
328328

329329
static int nbd_can_accept(void)
330330
{
331-
return state == RUNNING && nb_fds < shared;
331+
return state == RUNNING && (shared == 0 || nb_fds < shared);
332332
}
333333

334334
static void nbd_update_server_watch(void);
@@ -707,7 +707,7 @@ int main(int argc, char **argv)
707707
break;
708708
case 'e':
709709
if (qemu_strtoi(optarg, NULL, 0, &shared) < 0 ||
710-
shared < 1) {
710+
shared < 0) {
711711
error_report("Invalid shared device number '%s'", optarg);
712712
exit(EXIT_FAILURE);
713713
}
@@ -966,7 +966,7 @@ int main(int argc, char **argv)
966966
if (socket_activation == 0) {
967967
int backlog;
968968

969-
if (persistent) {
969+
if (persistent || shared == 0) {
970970
backlog = SOMAXCONN;
971971
} else {
972972
backlog = MIN(shared, SOMAXCONN);

0 commit comments

Comments
 (0)