qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/4] qxl: create a qxl common struct!


From: Gerd Hoffmann
Subject: Re: [Qemu-devel] [PATCH 1/4] qxl: create a qxl common struct!
Date: Mon, 27 Aug 2012 07:51:30 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.6esrpre) Gecko/20120714 Thunderbird/10.0.6

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]