On 08/24/12 21:14, Erlon Cruz wrote: > From: Fabiano FidĂȘncio <fabi...@fidencio.org> > > 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 > > 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