From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tki27-0002pM-5w for qemu-devel@nongnu.org; Mon, 17 Dec 2012 16:15:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tki23-0006GO-7w for qemu-devel@nongnu.org; Mon, 17 Dec 2012 16:15:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59918) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tki22-0006GD-V6 for qemu-devel@nongnu.org; Mon, 17 Dec 2012 16:15:27 -0500 Date: Mon, 17 Dec 2012 23:18:32 +0200 From: "Michael S. Tsirkin" Message-ID: <20121217211831.GA11153@redhat.com> References: <20121217154521.GA28674@redhat.com> <50CF5CA2.7060800@suse.de> <50CF629A.4090005@redhat.com> <50CF6384.9040809@suse.de> <20121217204811.GB30842@redhat.com> <50CF8AE7.1090803@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <50CF8AE7.1090803@suse.de> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] virtio: make bindings typesafe List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?iso-8859-1?Q?F=E4rber?= Cc: Anthony Liguori , Jan Kiszka , qemu-devel@nongnu.org, Alexander Graf , Christian Borntraeger , Paolo Bonzini , fred.konrad@greensocs.com On Mon, Dec 17, 2012 at 10:13:11PM +0100, Andreas F=E4rber wrote: > Am 17.12.2012 21:48, schrieb Michael S. Tsirkin: > > On Mon, Dec 17, 2012 at 07:25:08PM +0100, Andreas F=E4rber wrote: > >> Am 17.12.2012 19:21, schrieb Paolo Bonzini: > >>> Il 17/12/2012 18:55, Andreas F=E4rber ha scritto: > >>>> Am 17.12.2012 16:45, schrieb Michael S. Tsirkin: > >>>>> diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c > >>>>> index 3ea4140..63ae888 100644 > >>>>> --- a/hw/virtio-pci.c > >>>>> +++ b/hw/virtio-pci.c > >>>>> @@ -98,34 +98,34 @@ bool virtio_is_big_endian(void); > >>>>> =20 > >>>>> /* virtio device */ > >>>>> =20 > >>>>> -static void virtio_pci_notify(void *opaque, uint16_t vector) > >>>>> +static void virtio_pci_notify(DeviceState *d, uint16_t vector) > >>>>> { > >>>>> - VirtIOPCIProxy *proxy =3D opaque; > >>>>> + VirtIOPCIProxy *proxy =3D container_of(d, VirtIOPCIProxy, pc= i_dev.qdev); > >>>> > >>>> Nack. This is going the wrong direction QOM-wise and you among all > >>>> others know that from PCI host bridges! > >>> > >>> Well, that's just a difference of VIRTIO_PCI_PROXY(d) vs. container= _of. > >> > >> VIRTIO_PCI_PROXY(d) would be acceptable, sure. But as-is this patch = just > >> pushes unnecessary work on Fred, me, you or anyone else who works wi= th QOM. > >=20 > > What's VIRTIO_PCI_PROXY? Note this is data path we do not want extra > > code. >=20 > My complaint is the direct access of pci_dev, qdev, etc. parent fields > in many places as the main change of this patch. Those mean more places > to touch in a future patch. >=20 > Use of any new-style macro hiding these - wherever the particular one > suggested may be defined or whether it needs to be added - is better. >=20 > If performance of dynamic_cast is an issue - something I'd leave you to > discuss with Anthony - you can just do a C cast directly. Just don't > spread this qdev paradigm further please. >=20 > Regards, > Andreas OK so just #define VIRTIO_PCI_PROXY(d) container_of(d, VirtIOPCIProxy, pci_dev.qdev) is OK with you? > --=20 > SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany > GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrn= berg