mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-31 22:11:53 -06:00
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>
This commit is contained in:
parent
e34ef04641
commit
0ebd24e0a2
2 changed files with 34 additions and 6 deletions
9
block.c
9
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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue