All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Peter Krempa <pkrempa@redhat.com>,
	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
Date: Tue, 24 Nov 2026 13:33:03 +0100	[thread overview]
Message-ID: <awWD_4Y9xsYMKdS9@redhat.com> (raw)
In-Reply-To: <87cxruh857.fsf@pond.sub.org>

Am 24.11.2026 um 10:48 hat Markus Armbruster geschrieben:
> I almost missed this.  My apologies for the delay!
> 
> Peter Krempa <pkrempa@redhat.com> 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 <kwolf@redhat.com>
> >> Reviewed-by: Eric Blake <eblake@redhat.com>
> >> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> >> ---
> >>  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.

Kevin



  reply	other threads:[~2026-11-24 12:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 16:45 [PATCH v2 0/2] file-posix: Add 'accept-read-only-device' option Kevin Wolf
2026-10-29 16:45 ` [PATCH v2 1/2] " Kevin Wolf
2026-11-06 10:21   ` Peter Krempa
2026-11-24  9:48     ` Markus Armbruster
2026-11-24 12:33       ` Kevin Wolf [this message]
2026-11-24 13:36         ` Markus Armbruster
2026-11-24 14:42           ` Kevin Wolf
2026-11-24 15:01             ` Markus Armbruster
2026-10-29 16:45 ` [PATCH v2 2/2] iotests: Add loop-accept-ro-dev test Kevin Wolf
2026-10-30 19:15   ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=awWD_4Y9xsYMKdS9@redhat.com \
    --to=kwolf@redhat.com \
    --cc=afaria@redhat.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=pkrempa@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.