From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDXfe-0002zX-1g for qemu-devel@nongnu.org; Fri, 19 Oct 2018 12:30:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDXfc-0002CU-SG for qemu-devel@nongnu.org; Fri, 19 Oct 2018 12:30:41 -0400 From: Kevin Wolf Date: Fri, 19 Oct 2018 18:30:09 +0200 Message-Id: <20181019163013.11787-6-kwolf@redhat.com> In-Reply-To: <20181019163013.11787-1-kwolf@redhat.com> References: <20181019163013.11787-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v4 05/11] nbd: Support auto-read-only option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, mreitz@redhat.com, eblake@redhat.com, pkrempa@redhat.com, qemu-devel@nongnu.org If read-only=3Doff, but auto-read-only=3Don is given, open a read-write N= BD connection if the server provides a read-write export, but instead of erroring out for read-only exports, just degrade to read-only. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block/nbd-client.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/block/nbd-client.c b/block/nbd-client.c index 9686ecbd5e..76e9ca3abe 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -992,11 +992,11 @@ int nbd_client_init(BlockDriverState *bs, logout("Failed to negotiate with the NBD server\n"); return ret; } - if (client->info.flags & NBD_FLAG_READ_ONLY && - !bdrv_is_read_only(bs)) { - error_setg(errp, - "request for write access conflicts with read-only ex= port"); - return -EACCES; + if (client->info.flags & NBD_FLAG_READ_ONLY) { + ret =3D bdrv_apply_auto_read_only(bs, "NBD export is read-only",= errp); + if (ret < 0) { + return ret; + } } if (client->info.flags & NBD_FLAG_SEND_FUA) { bs->supported_write_flags =3D BDRV_REQ_FUA; --=20 2.19.1