summaryrefslogtreecommitdiffstats
path: root/block.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2013-09-19 15:12:18 +0200
committerKevin Wolf <kwolf@redhat.com>2013-10-11 16:50:02 +0200
commit0ebd24e0a203cf2852c310b59fbe050190dc6c8c (patch)
tree96b08ce87f22d94abe4d885e46a6662cbd0908f8 /block.c
parente34ef046412431acf5b4e30762390b4048187bb8 (diff)
downloadhqemu-0ebd24e0a203cf2852c310b59fbe050190dc6c8c.zip
hqemu-0ebd24e0a203cf2852c310b59fbe050190dc6c8c.tar.gz
blockdev: Don't disable COR automatically with blockdev-add
If a read-only device is configured with copy-on-read=on, the old code only prints a warning and automatically disables copy on read. Make it a real error for blockdev-add. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/block.c b/block.c
index 84c0eac..fd05a80 100644
--- 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) {
OpenPOWER on IntegriCloud