From patchwork Sun May 23 10:59:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 53306 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5D031B7D47 for ; Sun, 23 May 2010 21:01:31 +1000 (EST) Received: from localhost ([127.0.0.1]:51006 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OG8vv-0004J8-A0 for incoming@patchwork.ozlabs.org; Sun, 23 May 2010 07:01:27 -0400 Received: from [140.186.70.92] (port=48576 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OG8uF-0004EJ-Av for qemu-devel@nongnu.org; Sun, 23 May 2010 06:59:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OG8u9-0004P1-RA for qemu-devel@nongnu.org; Sun, 23 May 2010 06:59:41 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:34352) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OG8u9-0004OS-5L for qemu-devel@nongnu.org; Sun, 23 May 2010 06:59:37 -0400 Received: from smtp01.web.de ( [172.20.0.243]) by fmmailgate01.web.de (Postfix) with ESMTP id 16FD115B16D18; Sun, 23 May 2010 12:59:36 +0200 (CEST) Received: from [88.65.39.229] (helo=localhost.localdomain) by smtp01.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #4) id 1OG8u6-0003cZ-01; Sun, 23 May 2010 12:59:34 +0200 From: Jan Kiszka To: qemu-devel@nongnu.org, Anthony Liguori Date: Sun, 23 May 2010 12:59:15 +0200 Message-Id: <6a034099416bccaf10e56861896ae98239c19aa6.1274612367.git.jan.kiszka@web.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: References: In-Reply-To: References: X-Sender: jan.kiszka@web.de X-Provags-ID: V01U2FsdGVkX1+z5rWYMoVxKsLGB7vUzDeRllztt1QvRqSshk71 iPpCfiGR5TmNUdJ3anJh/8gkg9AqENQ87Z8hGMvem3H4nFaOJ7 S13l1K/m0= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 Cc: Juan Quintela , Jan Kiszka , Markus Armbruster , Luiz Capitulino , Blue Swirl , Avi Kivity Subject: [Qemu-devel] [PATCH v3 02/17] qdev: Fix scanning across single-bus devices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jan Kiszka As long as we allow /dev.1 as shortcut for /dev1/bus1, we also have to make sure that /dev1/dev2 works for /dev1/bus1/dev2/bus2 - as long as there is only one child bus per device. Signed-off-by: Jan Kiszka --- docs/qdev-device-use.txt | 4 ++++ hw/qdev.c | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletions(-) diff --git a/docs/qdev-device-use.txt b/docs/qdev-device-use.txt index f252c8e..9ac1fa1 100644 --- a/docs/qdev-device-use.txt +++ b/docs/qdev-device-use.txt @@ -20,6 +20,10 @@ bus named pci.0. To put a FOO device into its slot 4, use -device FOO,bus=/i440FX-pcihost/pci.0,addr=4. The abbreviated form bus=pci.0 also works as long as the bus name is unique. +Furthermore, if a device only hosts a single bus, the bus name can be +omitted in the path. Example: /i440FX-pcihost/PIIX3 abbreviates +/i440FX-pcihost/pci.0/PIIX3/isa.0 as none of the buses has siblings. + Note: the USB device address can't be controlled at this time. === Block Devices === diff --git a/hw/qdev.c b/hw/qdev.c index aa2ce01..2e50531 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -557,7 +557,7 @@ static DeviceState *qbus_find_dev(BusState *bus, char *elem) static BusState *qbus_find(const char *path) { - DeviceState *dev; + DeviceState *dev, *next_dev; BusState *bus; char elem[128]; int pos, len; @@ -603,6 +603,7 @@ static BusState *qbus_find(const char *path) return NULL; } +search_dev_bus: assert(path[pos] == '/' || !path[pos]); while (path[pos] == '/') { pos++; @@ -633,6 +634,15 @@ static BusState *qbus_find(const char *path) pos += len; bus = qbus_find_bus(dev, elem); if (!bus) { + if (dev->num_child_bus == 1) { + /* Last element might have been a short-cut to a device on + * the single child bus of the parent device. */ + next_dev = qbus_find_dev(QTAILQ_FIRST(&dev->child_bus), elem); + if (next_dev) { + dev = next_dev; + goto search_dev_bus; + } + } qerror_report(QERR_BUS_NOT_FOUND, elem); if (!monitor_cur_is_qmp()) { qbus_list_bus(dev);