Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7179F606A321 for ; Tue, 24 Nov 2026 15:03:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=pond.sub.org header.i=@pond.sub.org header.a=rsa-sha256 header.s=mail header.b=RhfUq9sS Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xVs2C-0004aw-E2; Tue, 24 Nov 2026 10:02:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xVs1w-0004Xz-Gl; Tue, 24 Nov 2026 10:02:01 -0500 Received: from oxygen.pond.sub.org ([2a01:4f8:13b:3ad0:1::3]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xVs1t-0007Si-9t; Tue, 24 Nov 2026 10:02:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=pond.sub.org; s=mail; t=1795532504; bh=twKTSQ0QC5e2S47pzOAamu8WvRskTQvlTXz+34XsnFk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=RhfUq9sSiXT9RYDyNISz+4DwtoSQJJOdJaLNP9uuFu8FXMplBoPmnBYKCBvTzA2k/ cdfDhWQrWFIA3BpEpFIdp9ZRgMnGWnmlEI7MqfND1ZkiYNT5jgPttgXRsKCfN4zIJQ wKdklIsUSp2mKVuG4fJfgk1l8L7ChmCpyatF8b14= Received: from blackfin.pond.sub.org (p4fd045cf.dip0.t-ipconnect.de [79.208.69.207]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by oxygen.pond.sub.org (Postfix) with ESMTPSA id 24CAD2001B; Tue, 24 Nov 2026 16:01:43 +0100 (CET) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 76C5F21E6A04; Tue, 24 Nov 2026 16:01:51 +0100 (CET) From: Markus Armbruster To: Kevin Wolf Cc: Peter Krempa , qemu-block@nongnu.org, stefanha@redhat.com, afaria@redhat.com, eblake@redhat.com, qemu-devel@nongnu.org Subject: Re: [PATCH v2 1/2] file-posix: Add 'accept-read-only-device' option In-Reply-To: (Kevin Wolf's message of "Tue, 24 Nov 2026 15:42:11 +0100") References: <20261029164522.103918-1-kwolf@redhat.com> <20261029164522.103918-2-kwolf@redhat.com> <87cxruh857.fsf@pond.sub.org> <87pkvue4ge.fsf@pond.sub.org> Date: Tue, 24 Nov 2026 16:01:51 +0100 Message-ID: <87cxrue0io.fsf@pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a01:4f8:13b:3ad0:1::3; envelope-from=armbru@pond.sub.org; helo=oxygen.pond.sub.org X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Kevin Wolf writes: > Am 24.11.2026 um 14:36 hat Markus Armbruster geschrieben: >> Kevin Wolf writes: >> >> > Am 24.11.2026 um 10:48 hat Markus Armbruster geschrieben: >> >> I almost missed this. My apologies for the delay! >> >> >> >> Peter Krempa writes: >> >> >> >> > CC'd Markus for QAPI generator input. >> >> > >> >> > On Thu, Oct 29, 2026 at 17:45:21 +0100, Kevin Wolf wrote: >> >> >> The host_device block driver refuses to open a block device read-write >> >> >> if the BLKROGET ioctl tells it that it's actually read-only. For such >> >> >> devices it's possible to open a read-write file descriptor, but any >> >> >> writes to the device would fail. >> >> >> >> >> >> There are valid use cases for which this check gets in the way, as >> >> >> explained in the bug report: >> >> >> >> >> >> However, this behavior prevents a legitimate enterprise use case: >> >> >> running VMs against storage replication target LUNs in a disaster >> >> >> recovery configuration. Enterprise storage arrays (Dell Powermax, >> >> >> Pure Storage) set the SCSI Write Protect bit on replication target >> >> >> LUNs, causing the Linux kernel to mark them read-only via BLKROGET. >> >> >> The VMs on the passive DR site need to start with these LUNs >> >> >> attached - writes are expected to fail (the application middleware >> >> >> knows it's on the passive side), and after a DR role swap the LUN >> >> >> becomes writable and writes should succeed immediately without any >> >> >> VM restart. >> >> >> >> >> >> In order to allow such use cases in which a currently read-only device >> >> >> is deliberately opened read-write, add a new option to the host_device >> >> >> driver that allows the user to skip the check. >> >> >> >> >> >> Buglink: https://redhat.atlassian.net/browse/RHEL-186136 >> >> >> Signed-off-by: Kevin Wolf >> >> >> Reviewed-by: Eric Blake >> >> >> Reviewed-by: Stefan Hajnoczi >> >> >> --- >> >> >> qapi/block-core.json | 19 ++++++++++++++++++- >> >> >> block/file-posix.c | 23 ++++++++++++++++++++--- >> >> >> 2 files changed, 38 insertions(+), 4 deletions(-) >> >> >> >> >> >> diff --git a/qapi/block-core.json b/qapi/block-core.json >> >> >> index 741c8165c06..80272b878c5 100644 >> >> >> --- a/qapi/block-core.json >> >> >> +++ b/qapi/block-core.json >> >> >> @@ -3390,6 +3390,23 @@ >> >> >> 'features': [ { 'name': 'dynamic-auto-read-only', >> >> >> 'if': 'CONFIG_POSIX' } ] } >> >> >> >> >> >> +## >> >> >> +# @BlockdevOptionsHostDevice: >> >> >> +# Driver specific block device options for the host_device >> >> >> +# backend. >> >> >> +# >> >> >> +# @accept-read-only-device: allow opening a read-only device as >> >> >> +# read-write. If this is false, opening a host device read-write >> >> >> +# requires on Linux that the BLKROGET ioctl considers the device >> >> >> +# writable. If it is true, this check is skipped. (since: 11.2, >> >> >> +# default: false) >> >> >> +# >> >> >> +# Since: 11.2 >> >> >> +## >> >> >> +{ 'struct': 'BlockdevOptionsHostDevice', >> >> >> + 'base': 'BlockdevOptionsFile', >> >> >> + 'data': { '*accept-read-only-device': 'bool' } } >> >> >> + >> >> >> ## >> >> >> # @BlockdevOptionsNull: >> >> >> # Driver specific block device options for the null backend. >> >> >> @@ -4777,7 +4794,7 @@ >> >> >> 'ftps': 'BlockdevOptionsCurlFtps', >> >> >> 'host_cdrom': { 'type': 'BlockdevOptionsFile', >> >> >> 'if': 'HAVE_HOST_BLOCK_DEVICE' }, >> >> >> - 'host_device': { 'type': 'BlockdevOptionsFile', >> >> >> + 'host_device': { 'type': 'BlockdevOptionsHostDevice', >> >> >> 'if': 'HAVE_HOST_BLOCK_DEVICE' }, >> >> >> 'http': 'BlockdevOptionsCurlHttp', >> >> >> 'https': 'BlockdevOptionsCurlHttps', >> >> > >> >> > After the two hunks above the 'host_device' type in the resulting QMP >> >> > schema will no longer have the 'dynamic-auto-read-only' feature which it >> >> > had when it used 'BlockdevOptionsFile' directly rather than the >> >> > 'BlockdevOptionsHostDevice' type which 'inherits' from >> >> > 'BlockdevOptionsFile'. >> >> >> >> Reproduced. >> >> >> >> > Markus, after chatting with Kevin, we're not sure if it's intention that >> >> > features are not inherited in the above case, and thus the >> >> > 'dynamic-auto-read-only' feature would need to be propagated also to >> >> > 'BlockdevOptionsHostDevice' or it's a mistake in the generator. >> >> >> >> The generator does what the programmer(s) intended it to do: 'base' >> >> splices in the members, and nothing else. Further evidence of intent: >> >> the explanation of 'base' in docs/devel/qapi-code-gen.rst talks only >> >> about members. >> >> >> >> Should it do more? >> >> >> >> Kevin, did you expect the feature to be inherited? Or did you simply >> >> not remember there's a feature, and therefore didn't think about what >> >> the generator might do with it? >> > >> > I simply didn't think of it, and when Peter pointed it out, I was unsure >> > what the behaviour really should be. I think inheriting would usually be >> > what you want, but maybe not always. >> > >> > I think we have two options to fix the regression: Either change the >> > QAPI generator to inherit features from 'base' (and avoid similar >> > problems in the future), or just manually duplicate the feature in the >> > schema for BlockdevOptionsHostDevice. >> > >> > Which one do you like better? I don't mind too much either way. >> >> Let's duplicate manually at least for now. We want a fix for 11.2, and >> it's last minute. I don't want to mess with the generator this late in >> the freeze. Manual duplication is simple and safe. >> >> Bases with features are rare. I can see three instances: >> >> Base of has feature >> BlockdevOptionsFile BlockdevOptionsHostDevice dynamic-auto-read-only >> SevCommonProperties SevGuestProperties confidential-guest-reset >> SevCommonProperties SevSnpGuestProperties confidential-guest-reset >> >> I'm reluctant to accept generator complexity for something as rare as >> this. > > My concern is not about the existing cases, but rather the question if > we'll catch the fourth case when it is introduced (e.g. some field of a > struct used somewhere as a base is deprecated). Members are inherited with their features. Features tacked to the base type aren't. The former is a lot more common than the latter. >> On the other hand, all three need the feature duplicated, I think. > > Yes, it looks like the feature in SevCommonProperties is invisible on > the external interface (which probably means that it isn't needed at > all). > >> On the third hand, we can manually add features, but not remove them. >> So if we make the generator inherit them, we're stuck with them. >> >> Would you like me to post patches? > > That would be good, especially now that you found instances of the > problem outside the block layer. Okay!