From: Kevin Wolf <kwolf@redhat.com>
To: Kevin Shanahan <kmshanah@disenchant.net>
Cc: libvir-list@redhat.com, Michael Tokarev <mjt@tls.msk.ru>,
Markus Armbruster <armbru@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] block: Set cdrom device read only flag
Date: Thu, 20 Sep 2012 10:22:52 +0200 [thread overview]
Message-ID: <505AD25C.8040104@redhat.com> (raw)
In-Reply-To: <5028B2A3.9010307@redhat.com>
Am 13.08.2012 09:54, schrieb Kevin Wolf:
> 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.
Kevin, would you like to resend this as a proper patch with a
Signed-off-by line?
If you like, you can also add a dinfo->bdrv->open_flags = snapshot ?
BDRV_O_SNAPSHOT : 0. This would fix the second bug I mentioned above,
that snapshot=on is lost on empty drives.
Kevin
prev parent reply other threads:[~2012-09-20 8:23 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
2012-08-13 11:57 ` Markus Armbruster
2012-08-13 13:20 ` Kevin Wolf
2012-09-20 8:22 ` Kevin Wolf [this message]
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=505AD25C.8040104@redhat.com \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=kmshanah@disenchant.net \
--cc=libvir-list@redhat.com \
--cc=mjt@tls.msk.ru \
--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).