Received: from eggs.gnu.org ([208.118.235.92]:33740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SaQGY-0000MF-RB for qemu-devel@nongnu.org; Fri, 01 Jun 2012 07:43:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SaQGW-0000iE-Rz for qemu-devel@nongnu.org; Fri, 01 Jun 2012 07:43:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53671) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SaQGW-0000i4-Ip for qemu-devel@nongnu.org; Fri, 01 Jun 2012 07:43:36 -0400 From: Markus Armbruster References: <4FC6A71A.90303@codemonkey.ws> <4FC87960.2090206@codemonkey.ws> <4FC88C28.8070100@codemonkey.ws> Date: Fri, 01 Jun 2012 13:43:30 +0200 In-Reply-To: <4FC88C28.8070100@codemonkey.ws> (Anthony Liguori's message of "Fri, 01 Jun 2012 17:32:24 +0800") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] Can we improve virtio data structures with QOM? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Stefan Hajnoczi , Andreas =?utf-8?Q?F=C3=A4rber?= , qemu-devel@nongnu.org, Evgeny Voevodin , Paolo Bonzini Anthony Liguori writes: > On 06/01/2012 05:25 PM, Markus Armbruster wrote: >> Anthony Liguori writes: >> >>> On 06/01/2012 12:48 AM, Markus Armbruster wrote: >>>> Anthony Liguori writes: >>>> >>>> [On how to model virtio devices in QOM:] >>>>> Basically, it should look like: >>>>> >>>>> VirtioPCIDevice is-a PCIDevice >>>>> >>>>> VirtioPCIDevice has-a link >>>> >>>> Could you explain why this is link<> and not child<>? >>> >>> So you can do: >>> >>> qemu -device virtio-pci,id=foo,vdev=bar -device virtio-blk,id=bar,bus=foo >> >> This lets folks specify both directions of the virtio-pci<-> virtio-blk >> connection independently. What if $dev->bus->vdev != $dev, i.e. the >> backlink doesn't point back? > > Then the user did something silly. > > If you're really asking, should we expect a user to use a command line > like this? Absolutely not! > > A user should use something like -drive file=foo.img,if=virtio No, a user should use what solves his problem nicely. Most of the time, the problem is simple. I quite agree we should provide simple ways to solve the known simple problems. Occasionally, you run into a non-simple problem, and then you'll really appreciate a discoverable bridge from the simple way to the general way. You'll also appreciate when the general way still satisfies basic usability criteria. A mandatory parameter that must have the one right value, or else things break, doesn't satisfy. "Experts/tools only" is no excuse for shoddy interfaces. -drive isn't such a good example for "simple"; it's a bloody mess, in my opinion. > Heck, I still think we should do -vda foo.img. > >> Easiest way to avoid that is to deny access to the backlink, and set it >> automatically instead. Wouldn't be surprised if such bi-directional >> links turned out to be a pretty common pattern. > > Most likely they will. But I don't think users should be setting any > links in the first place. Real tools aren't built around ideas on what users shouldn't be doing with them. >> In qdev, we've always called the property naming the parent "bus", >> because it's always been a qbus. Doesn't make sense here: the property >> refers to a device, not a bus. Should we call it something else? > > Actually, in qdev it's called parent_bus. Still got that bogus "bus" in there :) >>> The alternative would be: >>> >>> qemu -device virtio-pci,id=foo,child_type=virtio-blk >>> >>> But that feels ugly to me. If you want to have a variable type of >>> device, a link is the right tool. >> >> Okay, that's a general rule (I was hoping you'd state one). Do we have >> a place for such rules, or do we expect people to learn them by osmosis? > > I actually just did a tutorial session out here walking through how to > write device emulation from scratch. I would thinking of making a QOM > Style Guide based on that. That should be really useful. > I'm pretty short on free time for the next > week but I'll try to queue it up. If anyone wants to take a first > pass, I'd happily review it and contribute. > >>> BTW, I make no mention of BusState here. That's intentional. There's >>> no need to involve buses IMHO. >> >> I never liked qbus anyway. > > qbus never liked any of us too FWIW. It was a real jerk that way. Heh.