summaryrefslogtreecommitdiffstats
path: root/block.c
diff options
context:
space:
mode:
authorKevin Wolf2014-06-04 15:09:35 +0200
committerKevin Wolf2014-06-26 13:51:01 +0200
commit8ee79e707a005c9274df7ce34265bb7d008b8cef (patch)
treef8402fad14af55bef4457d8a5888db05d1d11fec /block.c
parentblock: Remove second bdrv_open() recursion (diff)
downloadqemu-8ee79e707a005c9274df7ce34265bb7d008b8cef.tar.gz
qemu-8ee79e707a005c9274df7ce34265bb7d008b8cef.tar.xz
qemu-8ee79e707a005c9274df7ce34265bb7d008b8cef.zip
block: Catch backing files assigned to non-COW drivers
Since we parse backing.* options to add a backing file from the command line when the driver didn't assign one, it has been possible to have a backing file for e.g. raw images (it just was never accessed). This is obvious nonsense and should be rejected. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/block.c b/block.c
index 0978e8cd59..2c3c7608ee 100644
--- a/block.c
+++ b/block.c
@@ -1192,6 +1192,13 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
bdrv_get_full_backing_filename(bs, backing_filename, PATH_MAX);
}
+ if (!bs->drv || !bs->drv->supports_backing) {
+ ret = -EINVAL;
+ error_setg(errp, "Driver doesn't support backing files");
+ QDECREF(options);
+ goto free_exit;
+ }
+
backing_hd = bdrv_new("", errp);
if (bs->backing_format[0] != '\0') {