blockdev.c - bug
Dear qemu developers,
I've noticed about 3 days ago a bug, apparently introduced by the last massive modifications in blockdev.c, that prevents the use of a cdrom ISO without write permission, like in "qemu-system-i386 -cdrom /some.iso ...", giving the message "could not open disk image /bpd/bpd.iso: Could not open file: Permission denied".
I didn't make a git bisect to identify the offending commit, but, as the problem seemed too simple, I've searched through the source code for references to "cdrom", "fopen", "media" and the like, trying to find any clue. My search was fruitful and I've been succesful in producing and testing the following patch.
I don't know if it is the best solution, as I don't really know the qemu source very well, but it works for me.
Thank you, very much.
Edivaldo de Araújo Pereira
Patch:
-------------------------------------------------------------------------------------------------------
blockdev.c 2013-10-14 20:54:42.342329073 -0300 renamed from blockdev.c 2013-10-14 13:59:59.000000000 -0300 +0 -0
@@ -709,7 +709,7 @@ DriveInfo *drive_init(QemuOpts *all_opts
}
/* copy-on-read is disabled with a warning for read-only devices */
- read_only = qemu_opt_get_bool(legacy_opts, "read-only", false);
+ read_only = ( qemu_opt_get_bool(legacy_opts, "read-only", false) || media == MEDIA_CDROM );copy_on_read = qemu_opt_get_bool(legacy_opts, "copy-on-read", false);
if (read_only && copy_on_read) {
-------------------------------------------------------------------------------------------------------
Quoted 7 lines · Edivaldo de Araujo Pereira
Dear qemu developers,
I've noticed about 3 days ago a bug, apparently introduced by the last massive modifications in
blockdev.c, that prevents the use of a cdrom ISO without write permission, like in "qemu-system-i386 -cdrom /some.iso ...", giving the message "could not open disk image /bpd/bpd.iso: Could not open file: Permission denied".I didn't make a git bisect to identify the offending commit, but, as the problem seemed too simple, I've searched through the source code for references to "cdrom", "fopen", "media" and the like, trying to find any clue. My search was fruitful and I've been succesful in producing and testing the following patch.
Thanks for reporting this.
Quoted 13 lines
I don't know if it is the best solution, as I don't really know the qemu source very well, but it works for me.
Thank you, very much.
Edivaldo de Araújo Pereira
Patch:
-------------------------------------------------------------------------------------------------------
diff -rupNa/blockdev.cb/blockdev.c
blockdev.c 2013-10-14 20:54:42.342329073 -0300 DriveInfo *drive_init(QemuOpts *all_opts · line 712
Quoted 5 lines
blockdev.c 2013-10-14 20:54:42.342329073 -0300 renamed from blockdev.c 2013-10-14 13:59:59.000000000 -0300 +1
-1@@ -709,7 +709,7 @@ DriveInfo *drive_init(QemuOpts *all_opts } /* copy-on-read is disabled with a warning for read-only devices */ - read_only = qemu_opt_get_bool(legacy_opts, "read-only", false); + read_only = ( qemu_opt_get_bool(legacy_opts, "read-only", false) || media == MEDIA_CDROM );
Media check is right above this stanza, we can set the value for it there.
blockdev.c 2013-10-14 20:54:42.342329073 -0300 DriveInfo *drive_init(QemuOpts *all_opts
Quoted 5 lines
blockdev.c 2013-10-14 20:54:42.342329073 -0300 renamed from blockdev.c 2013-10-14 13:59:59.000000000 -0300 +0
-1copy_on_read = qemu_opt_get_bool(legacy_opts, "copy-on-read", false); if (read_only && copy_on_read) { -------------------------------------------------------------------------------------------------------
Please use git send-email to format (and send) your email. See
http://qemu-project.org/Contribute/SubmitAPatch for instructions on sending patches.
However as this is a short fix, I'll roll out a patch and Cc you.
Thanks.
Fam