From nobody Tue May 7 20:00:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507643038173507.3788317852907; Tue, 10 Oct 2017 06:43:58 -0700 (PDT) Received: from localhost ([::1]:35157 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1uox-0002jh-NW for importer@patchew.org; Tue, 10 Oct 2017 09:43:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1unn-0002Fv-V7 for qemu-devel@nongnu.org; Tue, 10 Oct 2017 09:42:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1unk-0006Xu-0i for qemu-devel@nongnu.org; Tue, 10 Oct 2017 09:42:32 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:37197 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1unj-0006XH-LY for qemu-devel@nongnu.org; Tue, 10 Oct 2017 09:42:27 -0400 Received: from kvm.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v9ADg5tL017239; Tue, 10 Oct 2017 16:42:05 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Tue, 10 Oct 2017 16:42:05 +0300 Message-Id: <20171010134205.6120-1-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.1 X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH RFC] file-posix: make lock_fd read-only X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, mreitz@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We do not reopen lock_fd on bdrv_reopen which leads to problems on reopen image RO. So, lets make lock_fd be always RO. This is correct, because qemu_lock_fd always called with exclusive=3Dfalse on lock_fd. Signed-off-by: Vladimir Sementsov-Ogievskiy --- Hi all! We've faced the following problem with our shared-storage migration scheme. We make an external snapshot and need base image to be reopened RO. However, bdrv_reopen reopens only .fd of BDRVRawState but not .lock_fd. So, .lock_fd is left opened RW and this breaks the whole thing. The simple fix is here: let's just open lock_fd as RO always. This looks fine for current code, as we never try to set write locks (qemu_lock_fd always called with exclusive=3Dfalse). However it will not work if we are going to use write locks. block/file-posix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index 36ee89e940..5c52df9174 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -514,7 +514,8 @@ static int raw_open_common(BlockDriverState *bs, QDict = *options, =20 s->lock_fd =3D -1; if (s->use_lock) { - fd =3D qemu_open(filename, s->open_flags); + /* open it read-only, as we do not reopen it on bdrv_reopen */ + fd =3D qemu_open(filename, (s->open_flags & ~BDRV_O_RDWR)); if (fd < 0) { ret =3D -errno; error_setg_errno(errp, errno, "Could not open '%s' for locking= ", --=20 2.11.1