From nobody Sun Oct 5 21:10:01 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565894348; cv=none; d=zoho.com; s=zohoarc; b=iCQ7IImX2+zT1ym9D/B3LiOPpd+06YCWn3UQeuOHlKB+D9UcmSS8r0VoHVO5aMGeuh/ZfrTNKJSctbh/ZJezTipkeqYR84+1TJFc56Uz7kB1YfZI6sAFu2EMIFtoxr/g2d9IniJjQwCsGDvxS5M3LxgK2tcF7RLZdQGpcW18QzI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565894348; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=BIgMSjjWbgba+pdSDYGSaWM0yEK1dd0RQ7zDG9cG0Zk=; b=JXHln8n9U1nD75ygI3FMFI/PwUT7UJ7FpMXjsplGbHJ3koEV5FyDaGs6LiT08G5spMt2f36qzl1aOxq60+GErFQfW1Xs/JTjbPz4VP/brGg84cH8E/BZbMmQ8aZ7DT3Fc62mR/lH/S70G/ePYif4jbH+0nnISmCol3/MtgHpQrA= 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 1565894348656326.3761486278935; Thu, 15 Aug 2019 11:39:08 -0700 (PDT) Received: from localhost ([::1]:46144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyKeR-0001T1-DB for importer@patchew.org; Thu, 15 Aug 2019 14:39:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37530) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyKXA-0002zi-AR for qemu-devel@nongnu.org; Thu, 15 Aug 2019 14:31:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hyKX7-0001wz-Ta for qemu-devel@nongnu.org; Thu, 15 Aug 2019 14:31:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50638) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hyKX1-0001iB-I1; Thu, 15 Aug 2019 14:31:27 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BA2DC300442C; Thu, 15 Aug 2019 18:31:25 +0000 (UTC) Received: from blue.redhat.com (ovpn-117-22.phx2.redhat.com [10.3.117.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39970600CD; Thu, 15 Aug 2019 18:31:25 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 15 Aug 2019 13:30:38 -0500 Message-Id: <20190815183039.4264-9-eblake@redhat.com> In-Reply-To: <20190815183039.4264-1-eblake@redhat.com> References: <20190815183039.4264-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 15 Aug 2019 18:31:25 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 8/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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Markus Armbruster , "open list:Network Block Dev..." , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 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 Message-Id: <20190618114328.55249-5-vsementsov@virtuozzo.com> [eblake: slipped from 4.1 to 4.2] Signed-off-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 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 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.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 =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 */ } }, }; @@ -1651,7 +1663,9 @@ static int nbd_open(BlockDriverState *bs, QDict *opti= ons, int flags, /* 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); error: if (tlscreds) { --=20 2.20.1