Received: from [140.186.70.92] (port=58467 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ON3rC-00063y-Hv for qemu-devel@nongnu.org; Fri, 11 Jun 2010 09:01:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ON3r3-0002Zm-K5 for qemu-devel@nongnu.org; Fri, 11 Jun 2010 09:01:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51601) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ON3r2-0002Z6-Vl for qemu-devel@nongnu.org; Fri, 11 Jun 2010 09:01:01 -0400 From: Markus Armbruster Subject: Re: [Qemu-devel] [PATCH] Name the default PCI bus "pci.0" on all architectures References: <1274287377-19424-1-git-send-email-berrange@redhat.com> <201005282039.53749.paul@codesourcery.com> <201006021613.56797.paul@codesourcery.com> Date: Fri, 11 Jun 2010 15:00:46 +0200 In-Reply-To: <201006021613.56797.paul@codesourcery.com> (Paul Brook's message of "Wed, 2 Jun 2010 16:13:56 +0100") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paul Brook Cc: qemu-devel@nongnu.org Paul Brook writes: >> Paul Brook writes: >> >> The system emulators for each arch are using inconsistent >> >> naming for the default PCI bus "pci" vs "pci.0". Since it >> >> is conceivable we'll have multiple PCI buses in the future >> >> standardize on "pci.0" for all architectures. This ensures >> >> mgmt apps can rely on a name when assigning PCI devices an >> >> address on the bus using eg '-device e1000,bus=pci.0,addr=3' >> > >> > No. Bus names are local to the parent device. None of the host bridges >> > support multiple bridges, so the ".0" suffix makes no sense. The parent >> > device has no idea whether it owns the "default" pci bus or not. >> > If you have multiple PCI busses then you can identify them by the device >> > path. >> >> From qbus_create_inplace(): >> >> if (name) { >> /* use supplied name */ >> bus->name = qemu_strdup(name); >> } else if (parent && parent->id) { >> /* parent device has id -> use it for bus name */ >> len = strlen(parent->id) + 16; >> buf = qemu_malloc(len); >> snprintf(buf, len, "%s.%d", parent->id, parent->num_child_bus); >> bus->name = buf; >> } else { >> /* no id -> use lowercase bus type for bus name */ >> len = strlen(info->name) + 16; >> buf = qemu_malloc(len); >> len = snprintf(buf, len, "%s.%d", info->name, >> parent ? parent->num_child_bus : 0); >> for (i = 0; i < len; i++) >> buf[i] = qemu_tolower(buf[i]); >> bus->name = buf; >> } >> >> If appending ".0" really makes no sense when the device has just one >> bus, then we shouldn't append it in cases 2 & 3. > > IMO the code you quote is completely bogus. All devices should specify names > for their child busses, failure to do so is a bug. > > These bus names are local to the parent device. Trying to use them as global > identifiers is just plain wrong. A given device [type] should always have the > same set of properties/child busses regardless of where it occurs in the > device tree. I agree. Case in point: For a bug fix I'm working on, I need to find the drives connected to an IDE controller. Should be easy enough: go from controller qdev to its qbus, iterate over the qdevs on that bus. I need to call qdev_get_child_bus() for the first step, obviously. But what to pass as name argument? -EMAGIC. Note that I *only* object to case 2 (derive bus name from parent device's ID). Case 3 (derive bus name from bus type) is fine with me. > Using a single counter for all busses is also wrong. The order of bus creation > is a device implementation detail, under no circumstances should it be part of > the user visible API. Consider a device that has both a PCI and I2C bus. It > makes no sense to call there pci.0 and i2c.1. Yes, that's a bit ugly.