From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=35845 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PAReu-0008Dl-To for qemu-devel@nongnu.org; Mon, 25 Oct 2010 14:20:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PARec-00062s-OK for qemu-devel@nongnu.org; Mon, 25 Oct 2010 14:20:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11039) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PARec-00062l-Ev for qemu-devel@nongnu.org; Mon, 25 Oct 2010 14:20:18 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9PIKHw2028035 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 25 Oct 2010 14:20:17 -0400 Date: Mon, 25 Oct 2010 20:20:16 +0200 From: Gleb Natapov Subject: Re: [Qemu-devel] [PATCH] initialize unit id of IDE bus Message-ID: <20101025182016.GC877@redhat.com> References: <20101024162315.GG2343@redhat.com> <20101025154236.GH2343@redhat.com> <20101025164913.GA31633@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org On Mon, Oct 25, 2010 at 08:06:13PM +0200, Markus Armbruster wrote: > Gleb Natapov writes: > > > On Mon, Oct 25, 2010 at 06:22:12PM +0200, Markus Armbruster wrote: > >> Gleb Natapov writes: > >> > >> > On Mon, Oct 25, 2010 at 04:29:35PM +0200, Markus Armbruster wrote: > >> >> Gleb Natapov writes: > >> >> > >> >> > Without this patch both buses on PIIX3_IDE device have the same unit id. > >> >> > >> >> Are you sure that's wrong? > >> >> > >> > So how do I know which bus is it on PIIX3_IDE? > >> [...] > >> > >> Let me try to explain the IDE pointer thicket. > >> > >> piix3-ide provides two IDE buses. pci_piix_ide_initfn() stores them in > >> PCIIDEState member IDEBus bus[2]. Technically redundant, because qdev > >> stores child buses in dev.qdev.child_bus. > >> > >> IDEBus points back: qbus.parent. > >> > >> Up to two IDE devices can sit on each IDE bus. The first one uses > >> IDEBus members master and ifs[0], the second one uses slave and ifs[1]. > >> > >> ifs[i].bus points back to the IDE bus. > >> > >> {master,slave}.qdev.parent_bus point back to the IDE bus. > >> > >> Say you got an IDEDevice and want to know which to which of the two > >> buses it's connected. Let's call it d. > >> > >> d->qdev.parent_bus is the BusState. > >> > >> Upcast to IDEBus: b = DO_UPCAST(IDEBus, qbus, d->qdev.parent_bus). > >> > >> b->qbus.parent is the IDE controller. > >> > >> Upcast to PCIIDEState: c = DO_UPCAST(PCIIDEState, dev, n->qbus.parent); > >> > >> If c->bus[0] == b, it's on the first bus. > >> > >> Else it must be on the second bus, i.e. c->bus[1] == b. > >> > >> Hope I didn't screw this up too badly. > > Will check tomorrow if this works, but why not have simple property on > > IDEBus that says which one is it? > > Because nobody has needed it so far? > > Does the bus care whether it's first or second? > User that wants to address particular disk cares. > > BTW what -device magic should I use to > > create secondary disk on second IDE bus? > > Try -device ide-drive,bus=ide.1,unit=1,drive=... Where ide.1 comes from? Why do I need to write ide.1 not just 1. Can I instantiate ide-device on USB bus by doing -device ide-drive,bus=usb? -- Gleb.