From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn6tM-0006wb-Iu for qemu-devel@nongnu.org; Thu, 22 Sep 2016 12:30:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn6tF-0005Yi-Sz for qemu-devel@nongnu.org; Thu, 22 Sep 2016 12:30:31 -0400 From: Kevin Wolf Date: Thu, 22 Sep 2016 18:29:32 +0200 Message-Id: <1474561774-19256-32-git-send-email-kwolf@redhat.com> In-Reply-To: <1474561774-19256-1-git-send-email-kwolf@redhat.com> References: <1474561774-19256-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 31/33] block: Avoid printing NULL string in error messages List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org 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= 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 Reviewed-by: Eric Blake --- blockdev.c | 9 +++------ tests/qemu-iotests/085.out | 6 +++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/blockdev.c b/blockdev.c index 405145a..17c2671 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1803,8 +1803,7 @@ static void external_snapshot_prepare(BlkActionState *common, } 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 @@ void qmp_x_blockdev_insert_medium(bool has_device, const char *device, } 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 @@ void qmp_x_blockdev_del(bool has_id, const char *id, 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); diff --git a/tests/qemu-iotests/085.out b/tests/qemu-iotests/085.out index 01c78d6..08e4bb7 100644 --- a/tests/qemu-iotests/085.out +++ b/tests/qemu-iotests/085.out @@ -68,9 +68,9 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/ === Invalid command - snapshot node used as active layer === -{"error": {"class": "GenericError", "desc": "The snapshot is already in use by virtio0"}} -{"error": {"class": "GenericError", "desc": "The snapshot is already in use by virtio0"}} -{"error": {"class": "GenericError", "desc": "The snapshot is already in use by virtio1"}} +{"error": {"class": "GenericError", "desc": "The snapshot is already in use"}} +{"error": {"class": "GenericError", "desc": "The snapshot is already in use"}} +{"error": {"class": "GenericError", "desc": "The snapshot is already in use"}} === Invalid command - snapshot node used as backing hd === -- 1.8.3.1