Skip to contentSkip to conversation

qemu -cdrom /dev/cdrom opens the cdrom for RW and fails w/ RO devices (linux)

Qemu-devel Artur Skawina 1 participant 1 message Aug 9, 2006

lore
Share & tools
lore
#0 lore raw

recently (probably since the AIO code went in) qemu opens the cdrom device like this:

Quoted 1 line

open("/dev/cdrom", O_RDWR|O_LARGEFILE) = -1 EROFS (Read-only file system)

which obviously fails and qemu quits w/ an error message about being unable to access the cdrom.
Patch below makes a RO -cdrom device work (but doesn't necessarily address the real bug - should qemu really be opening cdrom devices for rw?)

artur

block.c +1 -1
diff -urNp qemu.org/block.c qemu/block.c
@@ -332,7 +332,7 @@ int bdrv_open2(BlockDriverState *bs, con
     else
         open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT);
     ret = drv->bdrv_open(bs, filename, open_flags);
-    if (ret == -EACCES && !(flags & BDRV_O_FILE)) {
+    if ((ret == -EACCES || ret == -EROFS) && !(flags & BDRV_O_FILE)) {
         ret = drv->bdrv_open(bs, filename, BDRV_O_RDONLY);
         bs->read_only = 1;
     }