]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commitdiff
block: push bdrv_change_backing_file error checking up from drivers
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 12 Apr 2012 12:01:01 +0000 (14:01 +0200)
committerKevin Wolf <kwolf@redhat.com>
Thu, 10 May 2012 08:32:11 +0000 (10:32 +0200)
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>
block.c
block/qcow2.c

diff --git a/block.c b/block.c
index a307fe177fe004713fbc0c66e6e8b6afd41b6bbc..068e41d9d9617800f5206b4fd1c88c164377e5b5 100644 (file)
--- 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 {
index ee4678f6edf75d31250d9fafee9cf675d1ce156b..3bae2d837e754427afe8e1ceef795c41bec52b97 100644 (file)
@@ -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 ?: "");