From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40009) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T5sEk-0007YB-E4 for qemu-devel@nongnu.org; Mon, 27 Aug 2012 01:51:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T5sEg-0007Fn-Dn for qemu-devel@nongnu.org; Mon, 27 Aug 2012 01:51:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32397) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T5sEg-0007FR-5q for qemu-devel@nongnu.org; Mon, 27 Aug 2012 01:51:42 -0400 Message-ID: <503B0AE2.4080307@redhat.com> Date: Mon, 27 Aug 2012 07:51:30 +0200 From: Gerd Hoffmann MIME-Version: 1.0 References: <1345835677-23371-1-git-send-email-erlon.cruz@br.flextronics.com> <1345835677-23371-2-git-send-email-erlon.cruz@br.flextronics.com> In-Reply-To: <1345835677-23371-2-git-send-email-erlon.cruz@br.flextronics.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/4] qxl: create a qxl common struct! List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Erlon Cruz Cc: "Erlon R. Cruz" , =?UTF-8?B?RmFiaWFubyBGaWTDqm5jaW8=?= , =?UTF-8?B?RmFiaWFubyBGaWTDqm5jaW8=?= , "Rafael F. Santos" , qemu-devel@nongnu.org, alevy@redhat.com On 08/24/12 21:14, Erlon Cruz wrote: > From: Fabiano Fid=C3=AAncio >=20 > This commit is creating a QXLDevice struct, entirely based on > PCIQXLDevice struct, but separating parts that will be shared between > PCIQXLDevice and VirtIOQXLDevice. All functions were changed to support > the new QXLDevice struct. > diff --git a/hw/qxl.h b/hw/qxl.h > index 172baf6..f25e341 100644 > --- a/hw/qxl.h > +++ b/hw/qxl.h > @@ -25,19 +25,44 @@ enum qxl_mode { > #define QXL_NUM_DIRTY_RECTS 64 > =20 > typedef struct PCIQXLDevice { > - PCIDevice pci; > - SimpleSpiceDisplay ssd; > - int id; > - uint32_t debug; > - uint32_t guestdebug; > - uint32_t cmdlog; > + PCIDevice pci; > + int generation; > + uint32_t revision; > + uint32_t guestdebug; > + uint32_t cmdlog; Please avoid whitespace changes like this which make it harder to see the actual changes. > +typedef struct QXLDevice { > + PCIQXLDevice pci; This is wrong, QXLDevice should only carry the shared parts. Data structures should be this way: struct QXLDevice { /* any shared fields go here */ }; struct PCIQXLDevice { PCIDevice pci; /* must be first because of qdev */ QXLDevice qxl; /* common stuff */ /* pci-specifiec fields (pci bars etc) go here */ }; struct VirtioQXLDevice { VirtIODevice vdev; QXLDevice qxl; /* virtio-specific fields go here */ }; If some function got a struct QXLDevice passed in and you need access to PCIQXLDevice or VirtioQXLDevice you can use the container_of macro. See hw/usb/hcd-ohci.c for an example, ohci emulation exists in pci and sysbus variants and thus is structed in a simliar way. cheers, Gerd