qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Cc: alxndr@bu.edu, qemu-devel@nongnu.org, mreitz@redhat.com
Subject: Re: [PATCH 1/2] block: Separate blk_is_writable() and blk_supports_write_perm()
Date: Mon, 18 Jan 2021 16:55:49 +0100	[thread overview]
Message-ID: <a35ee6f1-e5b5-1261-16df-e986c5a05a03@redhat.com> (raw)
In-Reply-To: <20210118123448.307825-2-kwolf@redhat.com>

On 1/18/21 1:34 PM, Kevin Wolf wrote:
> Currently, blk_is_read_only() tells whether a given BlockBackend can
> only be used in read-only mode because its root node is read-only. Some
> callers actually try to answer a slightly different question: Is the
> BlockBackend configured to be writable, by taking write permissions on
> the root node?
> 
> This can differ, for example, for CD-ROM devices which don't take write
> permissions, but may be backed by a writable image file. scsi-cd allows
> write requests to the drive if blk_is_read_only() returns false.
> However, the write request will immediately run into an assertion
> failure because the write permission is missing.
> 
> This patch introduces separate functions for both questions.
> blk_supports_write_perm() answers the question whether the block
> node/image file can support writable devices, whereas blk_is_writable()
> tells whether the BlockBackend is currently configured to be writable.
> 
> All calls of blk_is_read_only() are converted to one of the two new
> functions.
> 
> Fixes: https://bugs.launchpad.net/bugs/1906693
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  include/sysemu/block-backend.h |  3 ++-
>  block/block-backend.c          | 19 ++++++++++++++++---
>  hw/block/dataplane/xen-block.c |  2 +-
>  hw/block/fdc.c                 |  9 +++++----
>  hw/block/m25p80.c              |  6 +++---
>  hw/block/nand.c                |  2 +-
>  hw/block/nvme-ns.c             |  7 ++++---
>  hw/block/onenand.c             |  2 +-
>  hw/block/pflash_cfi01.c        |  2 +-
>  hw/block/pflash_cfi02.c        |  2 +-
>  hw/block/swim.c                |  6 +++---
>  hw/block/virtio-blk.c          |  6 +++---
>  hw/block/xen-block.c           |  2 +-
>  hw/ide/core.c                  |  2 +-
>  hw/misc/sifive_u_otp.c         |  2 +-
>  hw/ppc/pnv_pnor.c              |  2 +-
>  hw/scsi/scsi-disk.c            | 10 +++++-----
>  hw/scsi/scsi-generic.c         |  4 ++--
>  hw/sd/sd.c                     |  6 +++---
>  hw/usb/dev-storage.c           |  4 ++--
>  20 files changed, 57 insertions(+), 41 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



  reply	other threads:[~2021-01-18 15:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-18 12:34 [PATCH 0/2] block: Fix crash on write to read-only devices Kevin Wolf
2021-01-18 12:34 ` [PATCH 1/2] block: Separate blk_is_writable() and blk_supports_write_perm() Kevin Wolf
2021-01-18 15:55   ` Philippe Mathieu-Daudé [this message]
2021-01-19 15:03   ` Max Reitz
2021-01-18 12:34 ` [PATCH 2/2] virtio-scsi-test: Test writing to scsi-cd device Kevin Wolf
2021-01-18 16:02   ` Philippe Mathieu-Daudé
2021-01-19 15:26   ` Max Reitz

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=a35ee6f1-e5b5-1261-16df-e986c5a05a03@redhat.com \
    --to=philmd@redhat.com \
    --cc=alxndr@bu.edu \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).