From patchwork Thu Aug 4 12:03:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 655771 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3s4pX45BDhz9sRB for ; Thu, 4 Aug 2016 22:04:35 +1000 (AEST) Received: from localhost ([::1]:39426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVHO0-0000QF-Mn for incoming@patchwork.ozlabs.org; Thu, 04 Aug 2016 08:04:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVHNO-0008MB-C4 for qemu-devel@nongnu.org; Thu, 04 Aug 2016 08:03:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVHNM-0002SM-Ek for qemu-devel@nongnu.org; Thu, 04 Aug 2016 08:03:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34468) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVHNH-0002Qg-Fc; Thu, 04 Aug 2016 08:03:43 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 534A267327; Thu, 4 Aug 2016 12:03:42 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-100.ams2.redhat.com [10.36.116.100]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u74C3eix014614; Thu, 4 Aug 2016 08:03:41 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 4 Aug 2016 14:03:32 +0200 Message-Id: <1470312212-3005-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 04 Aug 2016 12:03:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.7] block/qdev: Let 'drive' property fall back to node name X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" If a qdev block device is created with an anonymous BlockBackend (i.e. a node name rather than a BB name was given for the drive property), qdev used to return an empty string when the property was read. This patch fixes it to return the node name instead. Signed-off-by: Kevin Wolf --- hw/core/qdev-properties-system.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index 2ba2504..25b24aa 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -126,7 +126,13 @@ static void release_drive(Object *obj, const char *name, void *opaque) static char *print_drive(void *ptr) { - return g_strdup(blk_name(ptr)); + const char *name; + + name = blk_name(ptr); + if (!*name) { + name = bdrv_get_node_name(blk_bs(ptr)); + } + return g_strdup(name); } static void get_drive(Object *obj, Visitor *v, const char *name, void *opaque,