* [Qemu-devel] [PATCH] block: do not allow read-only=on and snapshot=on to be used together
@ 2014-01-14 19:12 Jeff Cody
2014-01-14 19:30 ` Eric Blake
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Jeff Cody @ 2014-01-14 19:12 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, pbonzini, stefanha
Having both read-only=on and snapshot=on together does not make sense;
currently, the read-only argument is effectively ignored for the
temporary snapshot. To prevent confusion, disallow the usage of both
'snapshot=on' and 'read-only=on'.
Signed-off-by: Jeff Cody <jcody@redhat.com>
---
blockdev.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/blockdev.c b/blockdev.c
index e457494..845ff8a 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -352,6 +352,13 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
/* extract parameters */
snapshot = qemu_opt_get_bool(opts, "snapshot", 0);
ro = qemu_opt_get_bool(opts, "read-only", 0);
+
+ /* having ro and snapshot together does not make sense */
+ if (ro && snapshot) {
+ error_setg(errp, "invalid option combination: read-only and snapshot");
+ goto early_err;
+ }
+
copy_on_read = qemu_opt_get_bool(opts, "copy-on-read", false);
file = qemu_opt_get(opts, "file");
--
1.8.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] block: do not allow read-only=on and snapshot=on to be used together
2014-01-14 19:12 [Qemu-devel] [PATCH] block: do not allow read-only=on and snapshot=on to be used together Jeff Cody
@ 2014-01-14 19:30 ` Eric Blake
2014-01-16 7:00 ` Stefan Hajnoczi
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Eric Blake @ 2014-01-14 19:30 UTC (permalink / raw)
To: Jeff Cody, qemu-devel; +Cc: kwolf, pbonzini, stefanha
[-- Attachment #1: Type: text/plain, Size: 645 bytes --]
On 01/14/2014 12:12 PM, Jeff Cody wrote:
> Having both read-only=on and snapshot=on together does not make sense;
> currently, the read-only argument is effectively ignored for the
> temporary snapshot. To prevent confusion, disallow the usage of both
> 'snapshot=on' and 'read-only=on'.
>
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
> blockdev.c | 7 +++++++
> 1 file changed, 7 insertions(+)
Reviewed-by: Eric Blake <eblake@redhat.com>
No impact to libvirt, which (intentionally) doesn't use snapshot=on.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] block: do not allow read-only=on and snapshot=on to be used together
2014-01-14 19:12 [Qemu-devel] [PATCH] block: do not allow read-only=on and snapshot=on to be used together Jeff Cody
2014-01-14 19:30 ` Eric Blake
@ 2014-01-16 7:00 ` Stefan Hajnoczi
2014-01-16 9:39 ` Kevin Wolf
2014-01-24 13:33 ` Kevin Wolf
3 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2014-01-16 7:00 UTC (permalink / raw)
To: Jeff Cody; +Cc: kwolf, pbonzini, qemu-devel, stefanha
On Tue, Jan 14, 2014 at 02:12:19PM -0500, Jeff Cody wrote:
> Having both read-only=on and snapshot=on together does not make sense;
> currently, the read-only argument is effectively ignored for the
> temporary snapshot. To prevent confusion, disallow the usage of both
> 'snapshot=on' and 'read-only=on'.
>
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
> blockdev.c | 7 +++++++
> 1 file changed, 7 insertions(+)
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] block: do not allow read-only=on and snapshot=on to be used together
2014-01-14 19:12 [Qemu-devel] [PATCH] block: do not allow read-only=on and snapshot=on to be used together Jeff Cody
2014-01-14 19:30 ` Eric Blake
2014-01-16 7:00 ` Stefan Hajnoczi
@ 2014-01-16 9:39 ` Kevin Wolf
2014-01-16 19:20 ` Jeff Cody
2014-01-24 13:33 ` Kevin Wolf
3 siblings, 1 reply; 10+ messages in thread
From: Kevin Wolf @ 2014-01-16 9:39 UTC (permalink / raw)
To: Jeff Cody; +Cc: pbonzini, qemu-devel, stefanha
Am 14.01.2014 um 20:12 hat Jeff Cody geschrieben:
> Having both read-only=on and snapshot=on together does not make sense;
> currently, the read-only argument is effectively ignored for the
> temporary snapshot. To prevent confusion, disallow the usage of both
> 'snapshot=on' and 'read-only=on'.
>
> Signed-off-by: Jeff Cody <jcody@redhat.com>
I believe the reason why this was allowed was so that you can use a
read-only file with -snapshot. It might not be necessary any more since
I switched -snapshot implementation to modify the options QDict instead
of manually doing a second bdrv_open().
Did you test that this still works now?
The other question is about this code in bdrv_open_flags():
/*
* Snapshots should be writable.
*/
if (bs->is_temporary) {
open_flags |= BDRV_O_RDWR;
}
Is this dead code now because the flag is always already set?
Kevin
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] block: do not allow read-only=on and snapshot=on to be used together
2014-01-16 9:39 ` Kevin Wolf
@ 2014-01-16 19:20 ` Jeff Cody
2014-01-17 17:01 ` Kevin Wolf
0 siblings, 1 reply; 10+ messages in thread
From: Jeff Cody @ 2014-01-16 19:20 UTC (permalink / raw)
To: Kevin Wolf; +Cc: pbonzini, qemu-devel, stefanha
On Thu, Jan 16, 2014 at 10:39:30AM +0100, Kevin Wolf wrote:
> Am 14.01.2014 um 20:12 hat Jeff Cody geschrieben:
> > Having both read-only=on and snapshot=on together does not make sense;
> > currently, the read-only argument is effectively ignored for the
> > temporary snapshot. To prevent confusion, disallow the usage of both
> > 'snapshot=on' and 'read-only=on'.
> >
> > Signed-off-by: Jeff Cody <jcody@redhat.com>
>
> I believe the reason why this was allowed was so that you can use a
> read-only file with -snapshot. It might not be necessary any more since
> I switched -snapshot implementation to modify the options QDict instead
> of manually doing a second bdrv_open().
>
> Did you test that this still works now?
>
Yes, that still works.
> The other question is about this code in bdrv_open_flags():
>
> /*
> * Snapshots should be writable.
> */
> if (bs->is_temporary) {
> open_flags |= BDRV_O_RDWR;
> }
>
> Is this dead code now because the flag is always already set?
>
Yes, that ends up being dead code. From later in blockdev_init():
bdrv_flags |= ro ? 0 : BDRV_O_RDWR;
QINCREF(bs_opts);
ret = bdrv_open(dinfo->bdrv, file, bs_opts, bdrv_flags, drv, &error);
And ro is set from the read-only QemuOpts, that we check in this
patch in conjunction with snapshot. So if read-only=on is not
specified, it is opened r/w by default.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] block: do not allow read-only=on and snapshot=on to be used together
2014-01-16 19:20 ` Jeff Cody
@ 2014-01-17 17:01 ` Kevin Wolf
0 siblings, 0 replies; 10+ messages in thread
From: Kevin Wolf @ 2014-01-17 17:01 UTC (permalink / raw)
To: Jeff Cody; +Cc: pbonzini, qemu-devel, stefanha
Am 16.01.2014 um 20:20 hat Jeff Cody geschrieben:
> On Thu, Jan 16, 2014 at 10:39:30AM +0100, Kevin Wolf wrote:
> > Am 14.01.2014 um 20:12 hat Jeff Cody geschrieben:
> > > Having both read-only=on and snapshot=on together does not make sense;
> > > currently, the read-only argument is effectively ignored for the
> > > temporary snapshot. To prevent confusion, disallow the usage of both
> > > 'snapshot=on' and 'read-only=on'.
> > >
> > > Signed-off-by: Jeff Cody <jcody@redhat.com>
> >
> > I believe the reason why this was allowed was so that you can use a
> > read-only file with -snapshot. It might not be necessary any more since
> > I switched -snapshot implementation to modify the options QDict instead
> > of manually doing a second bdrv_open().
> >
> > Did you test that this still works now?
>
> Yes, that still works.
Great. :-)
> > The other question is about this code in bdrv_open_flags():
> >
> > /*
> > * Snapshots should be writable.
> > */
> > if (bs->is_temporary) {
> > open_flags |= BDRV_O_RDWR;
> > }
> >
> > Is this dead code now because the flag is always already set?
> >
>
> Yes, that ends up being dead code. From later in blockdev_init():
>
> bdrv_flags |= ro ? 0 : BDRV_O_RDWR;
>
> QINCREF(bs_opts);
> ret = bdrv_open(dinfo->bdrv, file, bs_opts, bdrv_flags, drv, &error);
>
>
> And ro is set from the read-only QemuOpts, that we check in this
> patch in conjunction with snapshot. So if read-only=on is not
> specified, it is opened r/w by default.
Good, that was my impression as well. Can you send a follow-up patch to
remove the dead code?
Kevin
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] block: do not allow read-only=on and snapshot=on to be used together
2014-01-14 19:12 [Qemu-devel] [PATCH] block: do not allow read-only=on and snapshot=on to be used together Jeff Cody
` (2 preceding siblings ...)
2014-01-16 9:39 ` Kevin Wolf
@ 2014-01-24 13:33 ` Kevin Wolf
2014-01-24 13:48 ` Jeff Cody
3 siblings, 1 reply; 10+ messages in thread
From: Kevin Wolf @ 2014-01-24 13:33 UTC (permalink / raw)
To: Jeff Cody; +Cc: pbonzini, qemu-devel, stefanha
Am 14.01.2014 um 20:12 hat Jeff Cody geschrieben:
> Having both read-only=on and snapshot=on together does not make sense;
> currently, the read-only argument is effectively ignored for the
> temporary snapshot. To prevent confusion, disallow the usage of both
> 'snapshot=on' and 'read-only=on'.
>
> Signed-off-by: Jeff Cody <jcody@redhat.com>
This breaks in a surprising way:
$ softmmu/qemu-system-x86_64 -drive file=~/images/hd.img,snapshot=on
... works fine ...
$ qemu-system-x86_64 -drive file=~/images/hd.img -snapshot
qemu-system-x86_64: invalid option combination: read-only and snapshot
qemu-iotests case 051 catches this. I'll have to remove this patch and
the follow-up from the queue for now.
Kevin
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] block: do not allow read-only=on and snapshot=on to be used together
2014-01-24 13:33 ` Kevin Wolf
@ 2014-01-24 13:48 ` Jeff Cody
2014-03-12 11:16 ` Kevin Wolf
0 siblings, 1 reply; 10+ messages in thread
From: Jeff Cody @ 2014-01-24 13:48 UTC (permalink / raw)
To: Kevin Wolf; +Cc: pbonzini, qemu-devel, stefanha
On Fri, Jan 24, 2014 at 02:33:19PM +0100, Kevin Wolf wrote:
> Am 14.01.2014 um 20:12 hat Jeff Cody geschrieben:
> > Having both read-only=on and snapshot=on together does not make sense;
> > currently, the read-only argument is effectively ignored for the
> > temporary snapshot. To prevent confusion, disallow the usage of both
> > 'snapshot=on' and 'read-only=on'.
> >
> > Signed-off-by: Jeff Cody <jcody@redhat.com>
>
> This breaks in a surprising way:
>
> $ softmmu/qemu-system-x86_64 -drive file=~/images/hd.img,snapshot=on
> ... works fine ...
>
> $ qemu-system-x86_64 -drive file=~/images/hd.img -snapshot
> qemu-system-x86_64: invalid option combination: read-only and snapshot
>
> qemu-iotests case 051 catches this. I'll have to remove this patch and
> the follow-up from the queue for now.
>
Odd - OK, I'll follow up on this and submit a series with both patches
(well, likely squashed together), and whatever is needed to fix this
as well.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] block: do not allow read-only=on and snapshot=on to be used together
2014-01-24 13:48 ` Jeff Cody
@ 2014-03-12 11:16 ` Kevin Wolf
2014-03-14 12:40 ` Jeff Cody
0 siblings, 1 reply; 10+ messages in thread
From: Kevin Wolf @ 2014-03-12 11:16 UTC (permalink / raw)
To: Jeff Cody; +Cc: pbonzini, qemu-devel, stefanha
Am 24.01.2014 um 14:48 hat Jeff Cody geschrieben:
> On Fri, Jan 24, 2014 at 02:33:19PM +0100, Kevin Wolf wrote:
> > Am 14.01.2014 um 20:12 hat Jeff Cody geschrieben:
> > > Having both read-only=on and snapshot=on together does not make sense;
> > > currently, the read-only argument is effectively ignored for the
> > > temporary snapshot. To prevent confusion, disallow the usage of both
> > > 'snapshot=on' and 'read-only=on'.
> > >
> > > Signed-off-by: Jeff Cody <jcody@redhat.com>
> >
> > This breaks in a surprising way:
> >
> > $ softmmu/qemu-system-x86_64 -drive file=~/images/hd.img,snapshot=on
> > ... works fine ...
> >
> > $ qemu-system-x86_64 -drive file=~/images/hd.img -snapshot
> > qemu-system-x86_64: invalid option combination: read-only and snapshot
> >
> > qemu-iotests case 051 catches this. I'll have to remove this patch and
> > the follow-up from the queue for now.
> >
>
> Odd - OK, I'll follow up on this and submit a series with both patches
> (well, likely squashed together), and whatever is needed to fix this
> as well.
Jeff, what happened with this? I found the two patches in an old git
branch and wondered why they didn't disappear in the rebase. But
apparently we still allow read-only and snapshot at the same time.
Kevin
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] block: do not allow read-only=on and snapshot=on to be used together
2014-03-12 11:16 ` Kevin Wolf
@ 2014-03-14 12:40 ` Jeff Cody
0 siblings, 0 replies; 10+ messages in thread
From: Jeff Cody @ 2014-03-14 12:40 UTC (permalink / raw)
To: Kevin Wolf; +Cc: pbonzini, qemu-devel, stefanha
On Wed, Mar 12, 2014 at 12:16:04PM +0100, Kevin Wolf wrote:
> Am 24.01.2014 um 14:48 hat Jeff Cody geschrieben:
> > On Fri, Jan 24, 2014 at 02:33:19PM +0100, Kevin Wolf wrote:
> > > Am 14.01.2014 um 20:12 hat Jeff Cody geschrieben:
> > > > Having both read-only=on and snapshot=on together does not make sense;
> > > > currently, the read-only argument is effectively ignored for the
> > > > temporary snapshot. To prevent confusion, disallow the usage of both
> > > > 'snapshot=on' and 'read-only=on'.
> > > >
> > > > Signed-off-by: Jeff Cody <jcody@redhat.com>
> > >
> > > This breaks in a surprising way:
> > >
> > > $ softmmu/qemu-system-x86_64 -drive file=~/images/hd.img,snapshot=on
> > > ... works fine ...
> > >
> > > $ qemu-system-x86_64 -drive file=~/images/hd.img -snapshot
> > > qemu-system-x86_64: invalid option combination: read-only and snapshot
> > >
> > > qemu-iotests case 051 catches this. I'll have to remove this patch and
> > > the follow-up from the queue for now.
> > >
> >
> > Odd - OK, I'll follow up on this and submit a series with both patches
> > (well, likely squashed together), and whatever is needed to fix this
> > as well.
>
> Jeff, what happened with this? I found the two patches in an old git
> branch and wondered why they didn't disappear in the rebase. But
> apparently we still allow read-only and snapshot at the same time.
>
The test case 051 failed because when -snapshot was specified, it was
enabled for all the default drives as well, which included
default_cdrom.
The solutions for that seemed a little hacky, and I wasn't sure it was
actually worth it, given that this is probably not a real problem to
begin with. If you think it is worth it, I can resurrect the patch
and make sure it works with both snapshot=on and -snapshot.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-03-14 12:40 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-14 19:12 [Qemu-devel] [PATCH] block: do not allow read-only=on and snapshot=on to be used together Jeff Cody
2014-01-14 19:30 ` Eric Blake
2014-01-16 7:00 ` Stefan Hajnoczi
2014-01-16 9:39 ` Kevin Wolf
2014-01-16 19:20 ` Jeff Cody
2014-01-17 17:01 ` Kevin Wolf
2014-01-24 13:33 ` Kevin Wolf
2014-01-24 13:48 ` Jeff Cody
2014-03-12 11:16 ` Kevin Wolf
2014-03-14 12:40 ` Jeff Cody
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).