Patchwork [v2] read-only: allow read-only CDROM with any interface

login
register
mail settings
Submitter Naphtali Sprei
Date March 23, 2010, 10:17 a.m.
Message ID <1269339436-23166-1-git-send-email-nsprei@redhat.com>
Download mbox | patch
Permalink /patch/48329/
State New
Headers show

Comments

Naphtali Sprei - March 23, 2010, 10:17 a.m.
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(-)

Patch

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) {