Received: from eggs.gnu.org ([2001:4830:134:3::10]:38945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYrjt-0003b5-F5 for qemu-devel@nongnu.org; Fri, 20 Mar 2015 03:53:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YYrjq-0007j6-6z for qemu-devel@nongnu.org; Fri, 20 Mar 2015 03:53:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33815) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYrjp-0007j2-VE for qemu-devel@nongnu.org; Fri, 20 Mar 2015 03:53:02 -0400 From: Markus Armbruster References: <5ad1c53c8b0dad6347d66af08e44c2faadff8612.1426779661.git.berto@igalia.com> Date: Fri, 20 Mar 2015 08:52:17 +0100 In-Reply-To: <5ad1c53c8b0dad6347d66af08e44c2faadff8612.1426779661.git.berto@igalia.com> (Alberto Garcia's message of "Thu, 19 Mar 2015 17:43:41 +0200") Message-ID: <87h9tghzri.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 2/3] block: use bdrv_get_device_or_node_name() in error messages List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alberto Garcia Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi Alberto Garcia writes: > There are several error messages that identify a BlockDriverState by > its device name. However those errors can be produced in nodes that > don't have a device name associated. > > In those cases we should use bdrv_get_device_or_node_name() to fall > back to the node name and produce a more meaningful message. > > Signed-off-by: Alberto Garcia > --- > block.c | 13 +++++++------ > block/qcow.c | 4 ++-- > block/qcow2.c | 2 +- > block/qed.c | 2 +- > block/vdi.c | 2 +- > block/vhdx.c | 2 +- > block/vmdk.c | 4 ++-- > block/vpc.c | 2 +- > block/vvfat.c | 3 ++- > 9 files changed, 18 insertions(+), 16 deletions(-) > > diff --git a/block.c b/block.c > index af284e3..655d9aa 100644 > --- a/block.c > +++ b/block.c > @@ -1225,7 +1225,7 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd) > } else if (backing_hd) { > error_setg(&bs->backing_blocker, > "device is used as backing hd of '%s'", > - bdrv_get_device_name(bs)); > + bdrv_get_device_or_node_name(bs)); > } > > bs->backing_hd = backing_hd; Before: * if @bs belongs to a BB with name N, print "backing hd of 'N'" * else print "backing hd of ''" (not nice, but works) After: * if @bs belongs to a BB with name N, print "backing hd of 'N'" (no change) * else if @bs has a node name NN, print "backing hd of 'NN'" (improvement) * else print a null pointer, which crashes on some systems (bug) If you want your bdrv_get_device_or_node_name() serve as drop-in replacement for bdrv_get_device_name(), it must not return null. In my opinion, such a drop-in replacement can only be a stop gap. We need to review every error message and figure out how to update it for node names. We should've done it back when we added node names. Your misuse of bdrv_get_device_or_node_name() shows misuse is likely. As long as that's the case, it needs a function comment. [...]