]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block: check for existing device IDs in external_snapshot_prepare()
authorAlberto Garcia <berto@igalia.com>
Mon, 26 Oct 2015 12:27:13 +0000 (14:27 +0200)
committerKevin Wolf <kwolf@redhat.com>
Wed, 11 Nov 2015 15:25:47 +0000 (16:25 +0100)
The 'snapshot-node-name' parameter of blockdev-snapshot-sync allows
setting the node name of the image that is going to be created.

Before creating the image, external_snapshot_prepare() checks that the
name is not already being used. The check is however incomplete since
it only considers existing node names, but node names must not clash
with device IDs either because they share the same namespace.

If the user attempts to create a snapshot using the name of an
existing device for the 'snapshot-node-name' parameter the operation
will eventually fail, but only after the new image has been created.

This patch replaces bdrv_find_node() with bdrv_lookup_bs() to extend
the check to existing device IDs, and thus detect possible name
clashes before the new image is created.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
blockdev.c

index 34f6e5bbb0e7a8239bd70bf0d5aea98b139ec449..0c6c2a7845329515cd83ed8f9280fab1986ef256 100644 (file)
@@ -1579,8 +1579,9 @@ static void external_snapshot_prepare(BlkTransactionState *common,
         return;
     }
 
-    if (has_snapshot_node_name && bdrv_find_node(snapshot_node_name)) {
-        error_setg(errp, "New snapshot node name already existing");
+    if (has_snapshot_node_name &&
+        bdrv_lookup_bs(snapshot_node_name, snapshot_node_name, NULL)) {
+        error_setg(errp, "New snapshot node name already in use");
         return;
     }