diff --git a/vl.c b/vl.c index 06cb40df5cbdf7072c7622652a04f4cb5c6ef48c..76ef8ca4f22ab27c91f5be5cc6be77bede946096 100644 --- a/vl.c +++ b/vl.c @@ -2233,6 +2233,13 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque, } (void)bdrv_set_read_only(dinfo->bdrv, 1); } + /* + * cdrom is read-only. Set it now, after above interface checking + * since readonly attribute not explicitly required, so no error. + */ + if (media == MEDIA_CDROM) { + (void)bdrv_set_read_only(dinfo->bdrv, 1); + } if (bdrv_open2(dinfo->bdrv, file, bdrv_flags, drv) < 0) { fprintf(stderr, "qemu: could not open disk image %s: %s\n",