]> Git Repo - qemu.git/commitdiff
block: read-only: open cdrom as read-only when using monitor's change command
authorNaphtali Sprei <[email protected]>
Sun, 25 Apr 2010 16:30:37 +0000 (19:30 +0300)
committerAnthony Liguori <[email protected]>
Mon, 3 May 2010 17:39:53 +0000 (12:39 -0500)
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]>
monitor.c

index bb87479f58aea0062356fcd680278396af6b0624..46d0b47af7ade9a9c2a2786971103380c5069e2e 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -1087,6 +1087,7 @@ static int do_change_block(Monitor *mon, const char *device,
 {
     BlockDriverState *bs;
     BlockDriver *drv = NULL;
+    int bdrv_flags;
 
     bs = bdrv_find(device);
     if (!bs) {
@@ -1103,7 +1104,8 @@ static int do_change_block(Monitor *mon, const char *device,
     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;
     }
This page took 0.028458 seconds and 4 git commands to generate.