diff mbox series

[PULL,41/64] blockdev: Use CAF in external_snapshot_prepare()

Message ID 20200907110936.261684-42-kwolf@redhat.com
State New
Headers show
Series [PULL,01/64] block: Raise an error when backing file parameter is an empty string | expand

Commit Message

Kevin Wolf Sept. 7, 2020, 11:09 a.m. UTC
From: Max Reitz <mreitz@redhat.com>

This allows us to differentiate between filters and nodes with COW
backing files: Filters cannot be used as overlays at all (for this
function).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
---
 blockdev.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/blockdev.c b/blockdev.c
index 862aa1b9aa..57ee41b73e 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1562,7 +1562,12 @@  static void external_snapshot_prepare(BlkActionState *common,
         goto out;
     }
 
-    if (state->new_bs->backing != NULL) {
+    if (state->new_bs->drv->is_filter) {
+        error_setg(errp, "Filters cannot be used as overlays");
+        goto out;
+    }
+
+    if (bdrv_cow_child(state->new_bs)) {
         error_setg(errp, "The overlay already has a backing image");
         goto out;
     }