From patchwork Tue May 28 11:00:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 246830 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CA4062C030A for ; Tue, 28 May 2013 21:01:44 +1000 (EST) Received: from localhost ([::1]:55751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhHew-0002RR-SW for incoming@patchwork.ozlabs.org; Tue, 28 May 2013 07:01:42 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhHeb-0002Gk-Rs for qemu-devel@nongnu.org; Tue, 28 May 2013 07:01:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UhHeU-00028y-RE for qemu-devel@nongnu.org; Tue, 28 May 2013 07:01:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45264) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhHeU-00028q-JL; Tue, 28 May 2013 07:01:14 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4SB1CXJ025574 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 28 May 2013 07:01:12 -0400 Received: from t430s.nay.redhat.com (vpn1-113-167.nay.redhat.com [10.66.113.167]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r4SB14mM024993; Tue, 28 May 2013 07:01:06 -0400 From: Amos Kong To: qemu-devel@nongnu.org Date: Tue, 28 May 2013 19:00:59 +0800 Message-Id: <1369738859-16557-1-git-send-email-akong@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, aliguori@us.ibm.com, kevin@koconnor.net, seabios@seabios.org, qemu-stable@nongnu.org Subject: [Qemu-devel] [PATCH v2] qdev: don't add typename to fw_dev_path when get_fw_dev_path isn't implemented X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Recent virtio refactoring in QEMU made virtio-bus become the parent bus of scsi-bus, and virtio-bus doesn't have get_fw_dev_path implementation, so redundant typename will be added to fw_dev_path. It causes that bootindex parameter of scsi device doesn't work. This patch changes qdev_get_fw_dev_path_helper() to add nothing if implemented get_fw_dev_path() returns NULL. Signed-off-by: Amos Kong --- v2: only add nothing to fw_dev_path when get_fw_dev_path() is implemented and return NULL. then it will not effect other devices don't have get_fw_dev_path() implementation. --- hw/core/qdev.c | 5 +++++ hw/virtio/virtio-bus.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 6985ad8..2a08368 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -509,11 +509,16 @@ static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int size) if (dev && dev->parent_bus) { char *d; + BusClass *parent_bc = BUS_GET_CLASS(dev->parent_bus); + l = qdev_get_fw_dev_path_helper(dev->parent_bus->parent, p, size); d = bus_get_fw_dev_path(dev->parent_bus, dev); + if (d) { l += snprintf(p + l, size - l, "%s", d); g_free(d); + } else if (parent_bc->get_fw_dev_path) { + return l; } else { l += snprintf(p + l, size - l, "%s", object_get_typename(OBJECT(dev))); } diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c index ea2e11a..6849a01 100644 --- a/hw/virtio/virtio-bus.c +++ b/hw/virtio/virtio-bus.c @@ -161,10 +161,16 @@ static char *virtio_bus_get_dev_path(DeviceState *dev) return qdev_get_dev_path(proxy); } +static char *virtio_bus_get_fw_dev_path(DeviceState *dev) +{ + return NULL; +} + static void virtio_bus_class_init(ObjectClass *klass, void *data) { BusClass *bus_class = BUS_CLASS(klass); bus_class->get_dev_path = virtio_bus_get_dev_path; + bus_class->get_fw_dev_path = virtio_bus_get_fw_dev_path; } static const TypeInfo virtio_bus_info = {