All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Kevin Shanahan <kmshanah@disenchant.net>
Cc: libvir-list@redhat.com, Markus Armbruster <armbru@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] block: Set cdrom device read only flag
Date: Mon, 13 Aug 2012 09:54:11 +0200	[thread overview]
Message-ID: <5028B2A3.9010307@redhat.com> (raw)
In-Reply-To: <20120812024854.GA2661@tuon.disenchant.local>

Am 12.08.2012 04:48, schrieb Kevin Shanahan:
> So qmp_change_blockdev uses bdrv_is_read_only() to check whether to
> try and open the backing file read only, which uses the ->read_only
> member of struct BlockDriverState to decide whether to pass the
> BDRV_O_RDRW flag to qmp_bdrv_open_encypted() and then bdrv_open().
> 
> I would assume we want to set this flag in drive_init() when the block
> driver state is initialised. How about a patch like this instead?
> 
> diff --git a/blockdev.c b/blockdev.c
> index 8669142..ba22064 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -526,6 +526,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
>                       if_name[type], mediastr, unit_id);
>      }
>      dinfo->bdrv = bdrv_new(dinfo->id);
> +    dinfo->bdrv->read_only = ro;
>      dinfo->devaddr = devaddr;
>      dinfo->type = type;
>      dinfo->bus = bus_id;

Ah, yes, this looks much more like the proper fix. Basically we need to
set everything that is retained after a 'change' command. We have this
code in qmp_change_blockdev():

    bdrv_flags = bdrv_is_read_only(bs) ? 0 : BDRV_O_RDWR;
    bdrv_flags |= bdrv_is_snapshot(bs) ? BDRV_O_SNAPSHOT : 0;

    qmp_bdrv_open_encrypted(bs, filename, bdrv_flags, drv, NULL, errp);

bdrv_is_read_only() is covered by your patch, bdrv_is_snapshot()
additionally requires bs->open_flags to be right.

Markus, how will this look in the -blockdev world? There seem to be
properties that belong to host state, but are not coupled to a medium.

Kevin

  reply	other threads:[~2012-08-13  7:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-02  1:32 [Qemu-devel] [PATCH] block: Set cdrom device read only flag Kevin Shanahan
2012-08-02  2:16 ` Kevin Shanahan
2012-08-02  5:19   ` Kevin Shanahan
2012-08-02  7:20     ` Kevin Shanahan
2012-08-06 10:07       ` Kevin Wolf
2012-08-07  8:47         ` Markus Armbruster
2012-08-07  9:46           ` ronnie sahlberg
2012-08-07 11:54             ` Markus Armbruster
2012-08-09  8:42           ` Kevin Wolf
2012-08-12  2:48             ` Kevin Shanahan
2012-08-13  7:54               ` Kevin Wolf [this message]
2012-08-13 11:57                 ` Markus Armbruster
2012-08-13 13:20                   ` Kevin Wolf
2012-09-20  8:22                 ` Kevin Wolf

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=5028B2A3.9010307@redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kmshanah@disenchant.net \
    --cc=libvir-list@redhat.com \
    --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 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.