aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-04-12 14:01:01 +0200
committerKevin Wolf <kwolf@redhat.com>2012-05-10 10:32:11 +0200
commit5f3777945d22248d805fb7c134e206c2d943b77b (patch)
treea150d2fad9a831d7497b152cc6f88691bc4081d6
parente86fe18ac945a121a548347c48f2397d7a2e5be5 (diff)
block: push bdrv_change_backing_file error checking up from drivers
This check applies to all drivers, but QED lacks it. Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--block.c5
-rw-r--r--block/qcow2.c5
2 files changed, 5 insertions, 5 deletions
diff --git a/block.c b/block.c
index a307fe177f..068e41d9d9 100644
--- a/block.c
+++ b/block.c
@@ -1460,6 +1460,11 @@ int bdrv_change_backing_file(BlockDriverState *bs,
{
BlockDriver *drv = bs->drv;
+ /* Backing file format doesn't make sense without a backing file */
+ if (backing_fmt && !backing_file) {
+ return -EINVAL;
+ }
+
if (drv->bdrv_change_backing_file != NULL) {
return drv->bdrv_change_backing_file(bs, backing_file, backing_fmt);
} else {
diff --git a/block/qcow2.c b/block/qcow2.c
index ee4678f6ed..3bae2d837e 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1011,11 +1011,6 @@ fail:
static int qcow2_change_backing_file(BlockDriverState *bs,
const char *backing_file, const char *backing_fmt)
{
- /* Backing file format doesn't make sense without a backing file */
- if (backing_fmt && !backing_file) {
- return -EINVAL;
- }
-
pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_file ?: "");
pstrcpy(bs->backing_format, sizeof(bs->backing_format), backing_fmt ?: "");