block: Avoid printing NULL string in error messages
Even for nodes that have a BlockBackend attached, bdrv_get_parent_name()
can return NULL if the BB is anonymous (e.g. it belongs to a block job
or a device that was created with a drive=<node-name> option).
Remove the information from the error message. The user probably knows
already why the node is still in use.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
diff --git a/blockdev.c b/blockdev.c
index 405145a..17c2671 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1803,8 +1803,7 @@
}
if (bdrv_has_blk(state->new_bs)) {
- error_setg(errp, "The snapshot is already in use by %s",
- bdrv_get_parent_name(state->new_bs));
+ error_setg(errp, "The snapshot is already in use");
return;
}
@@ -2532,8 +2531,7 @@
}
if (bdrv_has_blk(bs)) {
- error_setg(errp, "Node '%s' is already in use by '%s'", node_name,
- bdrv_get_parent_name(bs));
+ error_setg(errp, "Node '%s' is already in use", node_name);
return;
}
@@ -3941,8 +3939,7 @@
return;
}
if (bdrv_has_blk(bs)) {
- error_setg(errp, "Node %s is in use by %s",
- node_name, bdrv_get_parent_name(bs));
+ error_setg(errp, "Node %s is in use", node_name);
return;
}
aio_context = bdrv_get_aio_context(bs);