Regression opening read-only cdroms
qemu used to be quite happy opening read-only cdrom images, and I was quite happy feeding kvm-autotest a library of read-only iso images. However since
commit 0e1d8f4c549e51fd19793a154862979fdc199477
Author: Christoph Hellwig <[email protected]>
Date: Mon Jun 15 13:53:26 2009 +0200
raw-posix: always store open flags
Both the Linux floppy and the FreeBSD CDROM host device need to
store
the open flags so that they can re-open the device later.
Store the
open flags unconditionally to remove the ifdef mess and simply the calling conventions for the later patches in the series.
this state of happiness no longer exists.
Can you look at what caused this?
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 2 lines · Avi Kivity
qemu used to be quite happy opening read-only cdrom images, and I was quite happy feeding kvm-autotest a library of read-only iso images.
1. While we're here, an _option_ to open an image read-only even when you have write permission would be useful, for those occasions when you want to boot from some valuable image and be certain you aren't modifying it - without having to chmod back and forth in Qemu-wrapper scripts, or copy the image first.
2. Would it make sense to open CD-ROM images read-only all the time, when they are opened with media=cdrom, or can QEMU's CD-ROM devices write to the images?
-- Jamie
Quoted 9 lines · Jamie Lokier
Quoted 2 lines · Avi Kivity
qemu used to be quite happy opening read-only cdrom images, and I was quite happy feeding kvm-autotest a library of read-only iso images.
1. While we're here, an _option_ to open an image read-only even when you have write permission would be useful, for those occasions when you want to boot from some valuable image and be certain you aren't modifying it - without having to chmod back and forth in Qemu-wrapper scripts, or copy the image first.
Indeed.
I have a patch that adds bdrv_set_read_only that set bs->read_only = 1 so that bdrv_open2 can check if the flag is set and act accordingly. The problem is that in xen we read whether the device should be opened read only in the VM config file, I don't think the user can specify to open a drive read-only in qemu.
Quoted 4 lines
2. Would it make sense to open CD-ROM images read-only all the time, when they are opened with media=cdrom, or can QEMU's CD-ROM devices write to the images?
not at the moment, it may be possible in the future.
Quoted 13 lines · Stefano Stabellini
Quoted 9 lines · Jamie Lokier
Quoted 2 lines · Avi Kivity
qemu used to be quite happy opening read-only cdrom images, and I was quite happy feeding kvm-autotest a library of read-only iso images.
1. While we're here, an _option_ to open an image read-only even when you have write permission would be useful, for those occasions when you want to boot from some valuable image and be certain you aren't modifying it - without having to chmod back and forth in Qemu-wrapper scripts, or copy the image first.
Quoted 6 lines
Indeed.
I have a patch that addsbdrv_set_read_onlythat setbs->read_only= 1 so thatbdrv_open2can check if the flag is set and act accordingly. The problem is that in xen we read whether the device should be opened read only in the VM config file, I don't think the user can specify to open a drive read-only in qemu.
What's missing is a "ro" sub-option to "-drive".
-- Jamie
Quoted 6 lines · Jamie Lokier
Quoted 3 lines · Avi Kivity
qemu used to be quite happy opening read-only cdrom images, and I was quite happy feeding kvm-autotest a library of read-only iso images.
Quoted 6 lines
1. While we're here, an _option_ to open an image read-only even when you have write permission would be useful, for those occasions when you want to boot from some valuable image and be certain you aren't modifying it - without having to chmod back and forth in Qemu-wrapper scripts, or copy the image first.
read-only disk images don't make much sense.
Using -snapshot will generally ensure the image is not modified, while allowing the guest to write.
Quoted 4 lines
2. Would it make sense to open CD-ROM images read-only all the time, when they are opened with media=cdrom, or can QEMU's CD-ROM devices write to the images?
We don't emulate cd writers yet, so it makes sense to restict ourselves to O_RDONLY for now.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 7 lines · Avi Kivity
Quoted 6 lines · Jamie Lokier
Quoted 3 lines · Avi Kivity
qemu used to be quite happy opening read-only cdrom images, and I was quite happy feeding kvm-autotest a library of read-only iso images.
Quoted 8 lines
Quoted 6 lines
1. While we're here, an _option_ to open an image read-only even when you have write permission would be useful, for those occasions when you want to boot from some valuable image and be certain you aren't modifying it - without having to chmod back and forth in Qemu-wrapper scripts, or copy the image first.
read-only disk images don't make much sense.
And yet "chmod 444 image; qemu ..." works.
If you're booting from a disk you don't need to write to, obviously. Generally it'll need to be mounted read-only in the guest.
Quoted 2 lines
Using -snapshot will generally ensure the image is not modified, while allowing the guest to write.
I never do that with _valuable_ images because:
- Valuable images are expensive/difficult/impossible to recreate. But too large to copy about casually.
- I don't have that much faith in QEMU's correctness, having already been bitten by a number it's bugs, or in the guest's correctness if I were to rely on the guest doing read-only mount instead of using -snapshot.
- It's too easy to accidentally write back the changes over the the original image. Man page:
"the raw disk image you use is not written back. You can however force the write back by pressing C-a s".
And I don't do it when booting a guest where I have _both_ a disk a do want to write, and another valuable image that I don't want written, because:
- How would I use -snapshot and then commit changes to the disk I do want to write (either C-a s or "commit" in the monitor), but never write changes to the disk I don't want written?
- "commit" has always been a bit ambiguous when applied to a combination of -snapshot and a qcow2 delta image.
Finally, QEMU clearly does support read-only images, so it's always struck me as odd that the only way to invoke this support is using "chmod" outside QEMU. (Actually I use "chattr +i" as well. That's how paranoid I am about difficult to recreate images).
-- Jamie
Quoted 7 lines · Jamie Lokier
read-only disk images don't make much sense.
And yet "chmod 444 image; qemu ..." works.
If you're booting from a disk you don't need to write to, obviously. Generally it'll need to be mounted read-only in the guest.
It will eventually fail. Open the ext3 log, update atime, or something. The guest expects the disk to be writeable.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 16 lines · Avi Kivity
qemu used to be quite happy opening read-only cdrom images, and I was quite happy feeding kvm-autotest a library of read-only iso images. However since
commit
0e1d8f4c549e51fd19793a154862979fdc199477
Author: Christoph Hellwig <[email protected]>
Date: Mon Jun 15 13:53:26 2009 +0200raw-posix: always store open flags
Both the Linux floppy and the FreeBSD CDROM host device need to
store
the open flags so that they can re-open the device later. Store
the
open flags unconditionally to remove the ifdef mess and simply the calling conventions for the later patches in the series.
Quoted 5 lines
Signed-off-by Christoph Hellwig <[email protected]>this state of happiness no longer exists.
Can you look at what caused this?
How about these:
- open_flags = O_BINARY;
+ s->open_flags |= O_BINARY;
- open_flags = O_BINARY;
+ s->open_flags |= O_BINARY;
Quoted 10 lines · Jamie Lokier
Quoted 7 lines
Indeed.
I have a patch that addsbdrv_set_read_onlythat setbs->read_only= 1 so thatbdrv_open2can check if the flag is set and act accordingly. The problem is that in xen we read whether the device should be opened read only in the VM config file, I don't think the user can specify to open a drive read-only in qemu.What's missing is a "ro" sub-option to "-drive".
It only is useful if we can expose that read-only attribute to the guest. You can't do that consistently with all block devices so the result would be that you'll fail write operations causing a guest to crash.
This is not friendly to a user who expects that ro would Just Work.
Regards,
Anthony Liguori
Quoted 4 lines
-- Jamie
Quoted 8 lines · Anthony Liguori
Quoted 7 lines · Jamie Lokier
Quoted 7 lines
Indeed.
I have a patch that addsbdrv_set_read_onlythat setbs->read_only= 1 so thatbdrv_open2can check if the flag is set and act accordingly. The problem is that in xen we read whether the device should be opened read only in the VM config file, I don't think the user can specify to open a drive read-only in qemu.
Quoted 9 lines
Quoted 2 lines
What's missing is a "ro" sub-option to "-drive".
It only is useful if we can expose that read-only attribute to the guest. You can't do that consistently with all block devices so the result would be that you'll fail write operations causing a guest to crash.
This is not friendly to a user who expects that ro would Just Work.
Well, it could Just Work for cdrom.
Quoted 10 lines · Stefano Stabellini
Quoted 8 lines · Anthony Liguori
Quoted 7 lines · Jamie Lokier
Quoted 7 lines
Indeed.
I have a patch that addsbdrv_set_read_onlythat setbs->read_only= 1 so thatbdrv_open2can check if the flag is set and act accordingly. The problem is that in xen we read whether the device should be opened read only in the VM config file, I don't think the user can specify to open a drive read-only in qemu.
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
What's missing is a "ro" sub-option to "-drive".
It only is useful if we can expose that read-only attribute to the guest. You can't do that consistently with all block devices so the result would be that you'll fail write operations causing a guest to crash.
You should get disk write errors, rather than a simple crash. Any decent operating system will spew a lot of printks, which is a clue.
Quoted 1 line
Quoted 1 line
This is not friendly to a user who expects that ro would Just Work.
I don't agree that it's not friendly, because I think it's quite obvious what behaviour to expect. Users who don't know what a read-only disk would do can use virt-manager and that can warn them when they try to tick the option, or equally likely hide the option so they can never find it :-)
We already have a user interface for it: chmod. That's less friendly, but it's the same result.
Users who expect things to just work will be even more surprised that "-hda image" where image is read-only does not give any error from QEMU, but their guest crashes. Or that "-hda image" works as usual, and their guest crashes, and eventually they discover it's because their disk image is not writable, and it's always worked before because they were using -snapshot or something like that, and QEMU didn't warn them it would be a problem...
Quoted 1 line
Well, it could Just Work for cdrom.
It would Just Work for several media types (cdrom, floppy), and for hard disks on certain interfaces (virtio, SCSI, USB).
Yes, virtio, SCSI and USB have read-only storage flags.
It is also appropriate for disks that you intent to always mount read-only in the guest anyway, even if the interface doesn't have a flag, just to protect the image from aberrant guest behaviour.
-- Jamie
Quoted 11 lines · Avi Kivity
Quoted 7 lines · Jamie Lokier
read-only disk images don't make much sense.
And yet "chmod 444 image; qemu ..." works.
If you're booting from a disk you don't need to write to, obviously. Generally it'll need to be mounted read-only in the guest.It will eventually fail. Open the ext3 log, update atime, or something. The guest expects the disk to be writeable.
No. Obviously if you _want_ to run a guest with the disk mounted writable, you'll use snapshot=on instead because that's what it's for.
Otherwise, a read-only disk should works fine using virtio/SCSI/USB, as the guest will mount it read-only, as those interfaces all have a read-only media flag which Linux guests (at least) look at.
Which is the desired behaviour.
-- Jamie
Quoted 8 lines · Jamie Lokier
Quoted 4 lines
Quoted 4 lines
It only is useful if we can expose that read-only attribute to the guest. You can't do that consistently with all block devices so the result would be that you'll fail write operations causing a guest to crash.
You should get disk write errors, rather than a simple crash. Any decent operating system will spew a lot of printks, which is a clue.
I don't consider this useful behaviour and see no motivation to support it.
Quoted 8 lines
Users who expect things to just work will be even more surprised that "-hda image" where image is read-only does not give any error from QEMU, but their guest crashes. Or that "-hda image" works as usual, and their guest crashes, and eventually they discover it's because their disk image is not writable, and it's always worked before because they were using -snapshot or something like that, and QEMU didn't warn them it would be a problem...
I agree, for non-cdroms/floppies, non-backing store files we should require write access.
Quoted 4 lines
It is also appropriate for disks that you intent to always mount read-only in the guest anyway, even if the interface doesn't have a flag, just to protect the image from aberrant guest behaviour.
Maybe -drive ...,snapshot. The disk will be writable, just not persistent.
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
Quoted 16 lines · Jamie Lokier
Quoted 5 lines · Avi Kivity
Quoted 3 lines · Jamie Lokier
read-only disk images don't make much sense.
Quoted 8 lines
Quoted 5 lines
And yet "chmod 444 image; qemu ..." works.
If you're booting from a disk you don't need to write to, obviously. Generally it'll need to be mounted read-only in the guest.It will eventually fail. Open the ext3 log, update atime, or something. The guest expects the disk to be writeable.
Quoted 10 lines
No. Obviously if you _want_ to run a guest with the disk mounted writable, you'll use snapshot=on instead because that's what it's for.
Otherwise, a read-only disk should works fine using virtio/SCSI/USB, as the guest will mount it read-only, as those interfaces all have a read-only media flag which Linux guests (at least) look at.
Which is the desired behaviour.
I didn't consider a read-only media flag. I retract my remarks, -drive ...,readonly then makes sense for those interfaces.
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
Quoted 21 lines · Blue Swirl
Quoted 20 lines · Avi Kivity
qemu used to be quite happy opening read-only cdrom images, and I was quite happy feeding kvm-autotest a library of read-only iso images. However since
commit
0e1d8f4c549e51fd19793a154862979fdc199477
Author: Christoph Hellwig <[email protected]>
Date: Mon Jun 15 13:53:26 2009 +0200raw-posix: always store open flags
Both the Linux floppy and the FreeBSD CDROM host device need to
store
the open flags so that they can re-open the device later. Store
the
open flags unconditionally to remove the ifdef mess and simply the calling conventions for the later patches in the series.Signed-off-by Christoph Hellwig <[email protected]>this state of happiness no longer exists.
Quoted 8 lines
Quoted 1 line
Can you look at what caused this?
How about these:
-open_flags=O_BINARY;
+s->open_flags|=O_BINARY;
-open_flags=O_BINARY;
+s->open_flags|=O_BINARY;
Fix attached, could you test it?
From 2e218ca57516323a045b2ace594e0c88e449a4cd Mon Sep 17 00:00:00 2001
From: Blue Swirl <[email protected]>
Date: Tue, 16 Jun 2009 18:33:22 +0000
Subject: [PATCH] Fix opening of read only raw images
--- block/raw-posix.c | 31 +++++++++++++++---------------- 1 files changed, 15 insertions(+), 16 deletions(-)
block/raw-posix.c +15 -16
@@ -123,7 +123,7 @@ static int cdrom_reopen(BlockDriverState *bs);#endif static int raw_open_common (BlockDriverState *bs,const char *filename, -int flags) +int bdrv_flags,int open_flags) {BDRVRawState *s = bs->opaque;int fd, ret;
@@ -132,8 +132,8 @@ static int raw_open_common(BlockDriverState *bs, const char *filename, s->lseek_err_cnt =0 ; - s->open_flags |=O_BINARY ; -if ((flags &BDRV_O_ACCESS ) ==O_RDWR ) { + s->open_flags = open_flags |O_BINARY ; +if ((bdrv_flags &BDRV_O_ACCESS ) ==O_RDWR ) { s->open_flags |=O_RDWR ; }else { s->open_flags |=O_RDONLY ;
@@ -142,9 +142,9 @@ static int raw_open_common(BlockDriverState *bs, const char *filename,/* Use O_DSYNC for write-through caching, no flags for write-back caching, * and O_DIRECT for no caching. */ -if ((flags &BDRV_O_NOCACHE )) +if ((bdrv_flags &BDRV_O_NOCACHE )) s->open_flags |=O_DIRECT ; -else if (!(flags &BDRV_O_CACHE_WB )) +else if (!(bdrv_flags &BDRV_O_CACHE_WB )) s->open_flags |=O_DSYNC ; s->fd =-1 ;
@@ -157,7 +157,7 @@ static int raw_open_common(BlockDriverState *bs, const char *filename, } s->fd = fd; s->aligned_buf =NULL ; -if ((flags &BDRV_O_NOCACHE )) { +if ((bdrv_flags &BDRV_O_NOCACHE )) { s->aligned_buf =qemu_blockalign (bs,ALIGNED_BUFFER_SIZE );if (s->aligned_buf ==NULL ) { ret = -errno;
@@ -171,12 +171,13 @@ static int raw_open_common(BlockDriverState *bs, const char *filename,static int raw_open (BlockDriverState *bs,const char *filename,int flags) {BDRVRawState *s = bs->opaque; +int open_flags =0 ; s->type =FTYPE_FILE ;if (flags &BDRV_O_CREAT ) - s->open_flags |=O_CREAT |O_TRUNC ; + open_flags =O_CREAT |O_TRUNC ; -return raw_open_common (bs, filename, flags); +return raw_open_common (bs, filename, flags, open_flags); }/* XXX: use host sector size if necessary with:
@@ -1007,7 +1008,7 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags) }#endif -return raw_open_common (bs, filename, flags); +return raw_open_common (bs, filename, flags,0 ); }#if defined(__linux__)
@@ -1185,10 +1186,9 @@ static int floppy_open(BlockDriverState *bs, const char *filename, int flags)posix_aio_init (); s->type =FTYPE_FD ; -/* open will not fail even if no floppy is inserted */ - s->open_flags |=O_NONBLOCK ; - ret =raw_open_common (bs, filename, flags); +/* open will not fail even if no floppy is inserted, so add O_NONBLOCK */ + ret =raw_open_common (bs, filename, flags,O_NONBLOCK );if (ret)return ret;
@@ -1278,11 +1278,10 @@ static int cdrom_open(BlockDriverState *bs, const char *filename, int flags) {BDRVRawState *s = bs->opaque; -/* open will not fail even if no CD is inserted */ - s->open_flags |=O_NONBLOCK ; s->type =FTYPE_CD ; -return raw_open_common (bs, filename, flags); +/* open will not fail even if no CD is inserted, so add O_NONBLOCK */ +return raw_open_common (bs, filename, flags,O_NONBLOCK ); }static int cdrom_probe_device (const char *filename)
@@ -1372,7 +1371,7 @@ static int cdrom_open(BlockDriverState *bs, const char *filename, int flags) s->type =FTYPE_CD ; - ret =raw_open_common (bs, filename, flags); + ret =raw_open_common (bs, filename, flags,0 );if (ret)return ret;
Signature · 1 line
1.5.6.5
Quoted 11 lines · Avi Kivity
Quoted 7 lines · Jamie Lokier
Users who expect things to just work will be even more surprised that "-hda image" where image is read-only does not give any error from QEMU, but their guest crashes. Or that "-hda image" works as usual, and their guest crashes, and eventually they discover it's because their disk image is not writable, and it's always worked before because they were using -snapshot or something like that, and QEMU didn't warn them it would be a problem...
I agree, for non-cdroms/floppies, non-backing store files we should require write access.
Did you miss that read-only disks exist, as seen through SCSI/USB/virtio, and that guests will mount them read-only automatically?
There are real physical storage devices like that. Just think of your favourite USB flash drive with a write-protection switch. It's just a SCSI disk with the read-only flag set, to the guest. Modern guests know about them.
-- Jamie
Quoted 10 lines · Jamie Lokier
Quoted 9 lines · Avi Kivity
Quoted 7 lines · Jamie Lokier
Users who expect things to just work will be even more surprised that "-hda image" where image is read-only does not give any error from QEMU, but their guest crashes. Or that "-hda image" works as usual, and their guest crashes, and eventually they discover it's because their disk image is not writable, and it's always worked before because they were using -snapshot or something like that, and QEMU didn't warn them it would be a problem...
Quoted 5 lines
Quoted 2 lines
I agree, for non-cdroms/floppies, non-backing store files we should require write access.
Did you miss that read-only disks exist, as seen through SCSI/USB/virtio, and that guests will mount them read-only automatically?
I see that you didn't; our mails passed in the mist.
Ok. :-)
-- Jamie
Quoted 6 lines · Anthony Liguori
Quoted 1 line · Jamie Lokier
What's missing is a "ro" sub-option to "-drive".
It only is useful if we can expose that read-only attribute to the guest. You can't do that consistently with all block devices so the result would be that you'll fail write operations causing a guest to crash.
Well, I think all except ide-disk can signal r/o medium to the guest.
Quoted 1 line
This is not friendly to a user who expects that ro would Just Work.
chmod a-w $diskimage
And you'll run into the same issue today.
cheers,
Gerd
Yes, explicitly passing the open flags is probably cleaner then re-using the struct field. This passes my newly added test for the open behaviour.
From 2e218ca57516323a045b2ace594e0c88e449a4cd Mon Sep 17 00:00:00 2001
From: Blue Swirl <[email protected]>
Date: Tue, 16 Jun 2009 18:33:22 +0000
Subject: [PATCH] Fix opening of read only raw images
--- block/raw-posix.c | 31 +++++++++++++++---------------- 1 files changed, 15 insertions(+), 16 deletions(-)
block/raw-posix.c +15 -16
@@ -123,7 +123,7 @@ static int cdrom_reopen(BlockDriverState *bs);#endif static int raw_open_common (BlockDriverState *bs,const char *filename, -int flags) +int bdrv_flags,int open_flags) {BDRVRawState *s = bs->opaque;int fd, ret;
@@ -132,8 +132,8 @@ static int raw_open_common(BlockDriverState *bs, const char *filename, s->lseek_err_cnt =0 ; - s->open_flags |=O_BINARY ; -if ((flags &BDRV_O_ACCESS ) ==O_RDWR ) { + s->open_flags = open_flags |O_BINARY ; +if ((bdrv_flags &BDRV_O_ACCESS ) ==O_RDWR ) { s->open_flags |=O_RDWR ; }else { s->open_flags |=O_RDONLY ;
@@ -142,9 +142,9 @@ static int raw_open_common(BlockDriverState *bs, const char *filename,/* Use O_DSYNC for write-through caching, no flags for write-back caching, * and O_DIRECT for no caching. */ -if ((flags &BDRV_O_NOCACHE )) +if ((bdrv_flags &BDRV_O_NOCACHE )) s->open_flags |=O_DIRECT ; -else if (!(flags &BDRV_O_CACHE_WB )) +else if (!(bdrv_flags &BDRV_O_CACHE_WB )) s->open_flags |=O_DSYNC ; s->fd =-1 ;
@@ -157,7 +157,7 @@ static int raw_open_common(BlockDriverState *bs, const char *filename, } s->fd = fd; s->aligned_buf =NULL ; -if ((flags &BDRV_O_NOCACHE )) { +if ((bdrv_flags &BDRV_O_NOCACHE )) { s->aligned_buf =qemu_blockalign (bs,ALIGNED_BUFFER_SIZE );if (s->aligned_buf ==NULL ) { ret = -errno;
@@ -171,12 +171,13 @@ static int raw_open_common(BlockDriverState *bs, const char *filename,static int raw_open (BlockDriverState *bs,const char *filename,int flags) {BDRVRawState *s = bs->opaque; +int open_flags =0 ; s->type =FTYPE_FILE ;if (flags &BDRV_O_CREAT ) - s->open_flags |=O_CREAT |O_TRUNC ; + open_flags =O_CREAT |O_TRUNC ; -return raw_open_common (bs, filename, flags); +return raw_open_common (bs, filename, flags, open_flags); }/* XXX: use host sector size if necessary with:
@@ -1007,7 +1008,7 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags) }#endif -return raw_open_common (bs, filename, flags); +return raw_open_common (bs, filename, flags,0 ); }#if defined(__linux__)
@@ -1185,10 +1186,9 @@ static int floppy_open(BlockDriverState *bs, const char *filename, int flags)posix_aio_init (); s->type =FTYPE_FD ; -/* open will not fail even if no floppy is inserted */ - s->open_flags |=O_NONBLOCK ; - ret =raw_open_common (bs, filename, flags); +/* open will not fail even if no floppy is inserted, so add O_NONBLOCK */ + ret =raw_open_common (bs, filename, flags,O_NONBLOCK );if (ret)return ret;
@@ -1278,11 +1278,10 @@ static int cdrom_open(BlockDriverState *bs, const char *filename, int flags) {BDRVRawState *s = bs->opaque; -/* open will not fail even if no CD is inserted */ - s->open_flags |=O_NONBLOCK ; s->type =FTYPE_CD ; -return raw_open_common (bs, filename, flags); +/* open will not fail even if no CD is inserted, so add O_NONBLOCK */ +return raw_open_common (bs, filename, flags,O_NONBLOCK ); }static int cdrom_probe_device (const char *filename)
@@ -1372,7 +1371,7 @@ static int cdrom_open(BlockDriverState *bs, const char *filename, int flags) s->type =FTYPE_CD ; - ret =raw_open_common (bs, filename, flags); + ret =raw_open_common (bs, filename, flags,0 );if (ret)return ret;
Signature · 1 line
1.5.6.5
Quoted 4 lines · Gerd Hoffmann
Quoted 1 line
This is not friendly to a user who expects that ro would Just Work.
chmod a-w $diskimage
And you'll run into the same issue today.
That should error on IDE and warn on scsi (if ,readonly not supplied) unless -snapshot.
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
Quoted 9 lines · Jamie Lokier
Quoted 2 lines · Avi Kivity
qemu used to be quite happy opening read-only cdrom images, and I was quite happy feeding kvm-autotest a library of read-only iso images.
1. While we're here, an _option_ to open an image read-only even when you have write permission would be useful, for those occasions when you want to boot from some valuable image and be certain you aren't modifying it - without having to chmod back and forth in Qemu-wrapper scripts, or copy the image first.
FWIW we went round the houses on this one for libguestfs and settled on using '-drive ...,snapshot=on' instead. The guest sees the drive as writable, and any writes are discarded when libguestfs/qemu quits.
Rich.
Signature · 4 lines
Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
Quoted 11 lines · Richard W.M. Jones
Quoted 9 lines · Jamie Lokier
Quoted 2 lines · Avi Kivity
qemu used to be quite happy opening read-only cdrom images, and I was quite happy feeding kvm-autotest a library of read-only iso images.
1. While we're here, an _option_ to open an image read-only even when you have write permission would be useful, for those occasions when you want to boot from some valuable image and be certain you aren't modifying it - without having to chmod back and forth in Qemu-wrapper scripts, or copy the image first.
Quoted 3 lines
FWIW we went round the houses on this one for libguestfs and settled on using '-drive ...,snapshot=on' instead. The guest sees the drive as writable, and any writes are discarded when libguestfs/qemu quits.
It's fine for CD-ROMs of course.
For disks, there's that slight problem of running out of RAM or disk space for the /tmp snapshot files. Better not to write anything.
It'd be nice to enforce it, instead of depending on good behaviour from the guest.
-- Jamie
Quoted 2 lines · Jamie Lokier
It'd be nice to enforce it, instead of depending on good behaviour from the guest.
Right - but in libguestfs everything is controlled by the host so we can rely on good behaviour in our case.
Rich.
Signature · 4 lines
Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
Quoted 6 lines · Richard W.M. Jones
Quoted 2 lines · Jamie Lokier
It'd be nice to enforce it, instead of depending on good behaviour from the guest.
Right - but in libguestfs everything is controlled by the host so we can rely on good behaviour in our case.
In that case, why do you need the ",snapshot=on"?
-- Jamie
Quoted 9 lines · Jamie Lokier
Quoted 6 lines · Richard W.M. Jones
Quoted 2 lines · Jamie Lokier
It'd be nice to enforce it, instead of depending on good behaviour from the guest.
Right - but in libguestfs everything is controlled by the host so we can rely on good behaviour in our case.
In that case, why do you need the ",snapshot=on"?
Did I say that? I meant that we use that only for read-only access to hard drives, not for CD-ROMs. Here's the actual code:
Rich.
Signature · 4 lines
Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 75 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora