Current code of monitor command: 'change', used to open file for read-write
uncoditionally. Change to open it as read-only for CDROM, and read-write for all others.
Signed-off-by: Naphtali Sprei <[email protected]>
Signed-off-by: Anthony Liguori <[email protected]>
{
BlockDriverState *bs;
BlockDriver *drv = NULL;
+ int bdrv_flags;
bs = bdrv_find(device);
if (!bs) {
if (eject_device(mon, bs, 0) < 0) {
return -1;
}
- if (bdrv_open(bs, filename, BDRV_O_RDWR, drv) < 0) {
+ bdrv_flags = bdrv_get_type_hint(bs) == BDRV_TYPE_CDROM ? 0 : BDRV_O_RDWR;
+ if (bdrv_open(bs, filename, bdrv_flags, drv) < 0) {
qerror_report(QERR_OPEN_FILE_FAILED, filename);
return -1;
}