* [Qemu-devel] [PATCH] read-only: allow read-only CDROM with any interface
@ 2010-03-21 15:33 Naphtali Sprei
2010-03-21 17:29 ` Richard Henderson
2010-03-23 10:17 ` [Qemu-devel] [PATCH v2] " Naphtali Sprei
0 siblings, 2 replies; 3+ messages in thread
From: Naphtali Sprei @ 2010-03-21 15:33 UTC (permalink / raw)
To: qemu-devel
Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
---
vl.c | 13 +++++--------
1 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/vl.c b/vl.c
index 2e38b77..d3863d7 100644
--- a/vl.c
+++ b/vl.c
@@ -1255,19 +1255,16 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
bdrv_flags &= ~BDRV_O_NATIVE_AIO;
}
- if (ro == 1) {
+ if (media == MEDIA_CDROM) {
+ ro = 1;
+ }
+ if (ro == 1 &&
+ media != MEDIA_CDROM) { /* CDROM is fine for any interface, don't check */
if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY) {
fprintf(stderr, "qemu: readonly flag not supported for drive with this interface\n");
return NULL;
}
}
- /*
- * cdrom is read-only. Set it now, after above interface checking
- * since readonly attribute not explicitly required, so no error.
- */
- if (media == MEDIA_CDROM) {
- ro = 1;
- }
bdrv_flags |= ro ? 0 : BDRV_O_RDWR;
if (bdrv_open2(dinfo->bdrv, file, bdrv_flags, drv) < 0) {
--
1.6.3.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] read-only: allow read-only CDROM with any interface
2010-03-21 15:33 [Qemu-devel] [PATCH] read-only: allow read-only CDROM with any interface Naphtali Sprei
@ 2010-03-21 17:29 ` Richard Henderson
2010-03-23 10:17 ` [Qemu-devel] [PATCH v2] " Naphtali Sprei
1 sibling, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2010-03-21 17:29 UTC (permalink / raw)
To: Naphtali Sprei; +Cc: qemu-devel
On 03/21/2010 08:33 AM, Naphtali Sprei wrote:
> - if (ro == 1) {
> + if (media == MEDIA_CDROM) {
> + ro = 1;
> + }
> + if (ro == 1&&
> + media != MEDIA_CDROM) { /* CDROM is fine for any interface, don't check */
> if (type != IF_SCSI&& type != IF_VIRTIO&& type != IF_FLOPPY) {
Ug. How about formatting this as
if (media == MEDIA_CDROM) {
/* CDROM is fine for any interface, don't check. */
ro = 1;
} else if (ro == 1) {
if (type != IF_SCSI ...)
}
duplicating the MEDIA_CDROM test makes the logic harder to follow.
r~
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH v2] read-only: allow read-only CDROM with any interface
2010-03-21 15:33 [Qemu-devel] [PATCH] read-only: allow read-only CDROM with any interface Naphtali Sprei
2010-03-21 17:29 ` Richard Henderson
@ 2010-03-23 10:17 ` Naphtali Sprei
1 sibling, 0 replies; 3+ messages in thread
From: Naphtali Sprei @ 2010-03-23 10:17 UTC (permalink / raw)
To: qemu-devel
v1 -> v2
cosmetic change of if block arrangement
Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
---
vl.c | 13 +++++--------
1 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/vl.c b/vl.c
index d69250c..11c68f2 100644
--- a/vl.c
+++ b/vl.c
@@ -1222,19 +1222,16 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
bdrv_flags &= ~BDRV_O_NATIVE_AIO;
}
- if (ro == 1) {
+ if (media == MEDIA_CDROM) {
+ /* CDROM is fine for any interface, don't check. */
+ ro = 1;
+ } else if (ro == 1) {
if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY) {
fprintf(stderr, "qemu: readonly flag not supported for drive with this interface\n");
return NULL;
}
}
- /*
- * cdrom is read-only. Set it now, after above interface checking
- * since readonly attribute not explicitly required, so no error.
- */
- if (media == MEDIA_CDROM) {
- ro = 1;
- }
+
bdrv_flags |= ro ? 0 : BDRV_O_RDWR;
if (bdrv_open2(dinfo->bdrv, file, bdrv_flags, drv) < 0) {
--
1.6.3.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-23 10:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-21 15:33 [Qemu-devel] [PATCH] read-only: allow read-only CDROM with any interface Naphtali Sprei
2010-03-21 17:29 ` Richard Henderson
2010-03-23 10:17 ` [Qemu-devel] [PATCH v2] " Naphtali Sprei
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.