]> git.proxmox.com Git - qemu.git/blobdiff - block.c
integrator: fix Linux boot failure by emulating dbg region
[qemu.git] / block.c
diff --git a/block.c b/block.c
index 84c0eac671a36bd413bc70d1a9411b6a3620b391..fd05a8008a5842c808aca0126b5fa14392cfbea9 100644 (file)
--- a/block.c
+++ b/block.c
@@ -778,8 +778,13 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
     }
 
     assert(bs->copy_on_read == 0); /* bdrv_new() and bdrv_close() make it so */
-    if (!bs->read_only && (flags & BDRV_O_COPY_ON_READ)) {
-        bdrv_enable_copy_on_read(bs);
+    if (flags & BDRV_O_COPY_ON_READ) {
+        if (!bs->read_only) {
+            bdrv_enable_copy_on_read(bs);
+        } else {
+            error_setg(errp, "Can't use copy-on-read on read-only device");
+            return -EINVAL;
+        }
     }
 
     if (filename != NULL) {