[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 8/9] block/nbd: add cmdline and qapi parameter reconn
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PULL 8/9] block/nbd: add cmdline and qapi parameter reconnect-delay |
Date: |
Thu, 15 Aug 2019 13:30:38 -0500 |
From: Vladimir Sementsov-Ogievskiy <address@hidden>
Reconnect will be implemented in the following commit, so for now,
in semantics below, disconnect itself is a "serious error".
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
[eblake: slipped from 4.1 to 4.2]
Signed-off-by: Eric Blake <address@hidden>
---
qapi/block-core.json | 11 ++++++++++-
block/nbd.c | 16 +++++++++++++++-
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 0d43d4f37c1a..f1e7701fbea9 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -3860,13 +3860,22 @@
# traditional "base:allocation" block status (see
# NBD_OPT_LIST_META_CONTEXT in the NBD protocol) (since 3.0)
#
+# @reconnect-delay: On an unexpected disconnect, the nbd client tries to
+# connect again until succeeding or encountering a serious
+# error. During the first @reconnect-delay seconds, all
+# requests are paused and will be rerun on a successful
+# reconnect. After that time, any delayed requests and all
+# future requests before a successful reconnect will
+# immediately fail. Default 0 (Since 4.2)
+#
# Since: 2.9
##
{ 'struct': 'BlockdevOptionsNbd',
'data': { 'server': 'SocketAddress',
'*export': 'str',
'*tls-creds': 'str',
- '*x-dirty-bitmap': 'str' } }
+ '*x-dirty-bitmap': 'str',
+ '*reconnect-delay': 'uint32' } }
##
# @BlockdevOptionsRaw:
diff --git a/block/nbd.c b/block/nbd.c
index d03b00fc30b0..de2a26097bf9 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -1275,6 +1275,7 @@ static int nbd_client_init(BlockDriverState *bs,
QCryptoTLSCreds *tlscreds,
const char *hostname,
const char *x_dirty_bitmap,
+ uint32_t reconnect_delay,
Error **errp)
{
int ret;
@@ -1600,6 +1601,17 @@ static QemuOptsList nbd_runtime_opts = {
.help = "experimental: expose named dirty bitmap in place of "
"block status",
},
+ {
+ .name = "reconnect-delay",
+ .type = QEMU_OPT_NUMBER,
+ .help = "On an unexpected disconnect, the nbd client tries to "
+ "connect again until succeeding or encountering a serious "
+ "error. During the first @reconnect-delay seconds, all "
+ "requests are paused and will be rerun on a successful "
+ "reconnect. After that time, any delayed requests and all "
+ "future requests before a successful reconnect will "
+ "immediately fail. Default 0",
+ },
{ /* end of list */ }
},
};
@@ -1651,7 +1663,9 @@ static int nbd_open(BlockDriverState *bs, QDict *options,
int flags,
/* NBD handshake */
ret = nbd_client_init(bs, s->saddr, s->export, tlscreds, hostname,
- qemu_opt_get(opts, "x-dirty-bitmap"), errp);
+ qemu_opt_get(opts, "x-dirty-bitmap"),
+ qemu_opt_get_number(opts, "reconnect-delay", 0),
+ errp);
error:
if (tlscreds) {
--
2.20.1
- [Qemu-devel] [PULL 0/9] First batch of 4.2 NBD patches, Eric Blake, 2019/08/15
- [Qemu-devel] [PULL 1/9] qapi: Add InetSocketAddress member keep-alive, Eric Blake, 2019/08/15
- [Qemu-devel] [PULL 7/9] block/nbd: move from quit to state, Eric Blake, 2019/08/15
- [Qemu-devel] [PULL 8/9] block/nbd: add cmdline and qapi parameter reconnect-delay,
Eric Blake <=
- [Qemu-devel] [PULL 6/9] block/nbd: use non-blocking io channel for nbd negotiation, Eric Blake, 2019/08/15
- [Qemu-devel] [PULL 2/9] block: implement BDRV_REQ_PREFETCH, Eric Blake, 2019/08/15
- [Qemu-devel] [PULL 3/9] block/stream: use BDRV_REQ_PREFETCH, Eric Blake, 2019/08/15
- [Qemu-devel] [PULL 4/9] nbd: improve CMD_CACHE: use BDRV_REQ_PREFETCH, Eric Blake, 2019/08/15
- [Qemu-devel] [PULL 5/9] block/nbd: split connection_co start out of nbd_client_connect, Eric Blake, 2019/08/15
- [Qemu-devel] [PULL 9/9] block/nbd: refactor nbd connection parameters, Eric Blake, 2019/08/15
- Re: [Qemu-devel] [PULL 0/9] First batch of 4.2 NBD patches, Peter Maydell, 2019/08/16