From nobody Tue Nov 11 03:18:54 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1560858854; cv=none; d=zoho.com; s=zohoarc; b=I9RjfPLLfGbqn5N5crvBkIduBiL7mL85M0xDyf1eNm4F+WnrhIrJohk8YIF2GTElvoYDMCUKGc3W7D64NPeiFU7DJpG7r9P81Tj57g16CWyTxpilfNV5/0cb9Kig3KPuktNFrYFU1wKcYDjgzzGGMGa/v5LOAtLttby4fnIdMWg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560858854; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=jpJrFoSJPTw7XkE+YM97oITyKrihYUW5eHVtz98lGyY=; b=b2/mxggR9EVaHijjHx7+Vq7ycCpaRPvrm124skeDk+O5c1fqNs+Hbh5Y8EWidqN/oIJNoM0gDgeL/JhS8xYkHZTx2ioLByLKDrN4T4+k5/VgjW40d/a9y+YSCOq6V5J/DmmPK84MBvqxuUjwKIgYQSEJ64ohn/Vx2JSm/uKoxxQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560858854421932.3963352311428; Tue, 18 Jun 2019 04:54:14 -0700 (PDT) Received: from localhost ([::1]:55914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdCgn-0004bP-GI for importer@patchew.org; Tue, 18 Jun 2019 07:54:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48336) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdCWX-00041t-AH for qemu-devel@nongnu.org; Tue, 18 Jun 2019 07:43:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hdCWV-0000NB-7b for qemu-devel@nongnu.org; Tue, 18 Jun 2019 07:43:37 -0400 Received: from relay.sw.ru ([185.231.240.75]:58004) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hdCWU-0000Jj-Rn; Tue, 18 Jun 2019 07:43:35 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1hdCWP-00016b-9e; Tue, 18 Jun 2019 14:43:29 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Tue, 18 Jun 2019 14:43:23 +0300 Message-Id: <20190618114328.55249-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190618114328.55249-1-vsementsov@virtuozzo.com> References: <20190618114328.55249-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v7 4/9] block/nbd: add cmdline and qapi parameter reconnect-delay X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Eric Blake --- 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 61124431d8..17faf723e0 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -3858,13 +3858,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 serio= us +# 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 a= ll +# future requests before a successful reconnect will +# immediately fail. Default 0 (Since 4.1) +# # Since: 2.9 ## { 'struct': 'BlockdevOptionsNbd', 'data': { 'server': 'SocketAddress', '*export': 'str', '*tls-creds': 'str', - '*x-dirty-bitmap': 'str' } } + '*x-dirty-bitmap': 'str', + '*reconnect-delay': 'uint32' } } =20 ## # @BlockdevOptionsRaw: diff --git a/block/nbd.c b/block/nbd.c index 9e505c895a..df9b0a2c8a 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1276,6 +1276,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; @@ -1601,6 +1602,17 @@ static QemuOptsList nbd_runtime_opts =3D { .help =3D "experimental: expose named dirty bitmap in place of= " "block status", }, + { + .name =3D "reconnect-delay", + .type =3D QEMU_OPT_NUMBER, + .help =3D "On an unexpected disconnect, the nbd client tries t= o " + "connect again until succeeding or encountering a seri= ous " + "error. During the first @reconnect-delay seconds, al= l " + "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 */ } }, }; @@ -1652,7 +1664,9 @@ static int nbd_open(BlockDriverState *bs, QDict *opti= ons, int flags, =20 /* NBD handshake */ ret =3D 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); =20 error: if (tlscreds) { --=20 2.18.0