qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: Erlon Cruz <erlon.cruz@br.flextronics.com>
Cc: "Erlon R. Cruz" <erlon.cruz@fit-tecnologia.org.br>,
	"Fabiano Fidêncio" <fabiano@fidencio.org>,
	"Fabiano Fidêncio" <fabiano.fidencio@fit-tecnologia.org.br>,
	"Rafael F. Santos" <fonsecasantos.rafael@gmail.com>,
	qemu-devel@nongnu.org, alevy@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/4] qxl: create a qxl common struct!
Date: Mon, 27 Aug 2012 07:51:30 +0200	[thread overview]
Message-ID: <503B0AE2.4080307@redhat.com> (raw)
In-Reply-To: <1345835677-23371-2-git-send-email-erlon.cruz@br.flextronics.com>

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

  reply	other threads:[~2012-08-27  5:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-24 19:14 [Qemu-devel] Implementing qxl-virtio on QEMU Erlon Cruz
2012-08-24 19:14 ` [Qemu-devel] [PATCH 1/4] qxl: create a qxl common struct! Erlon Cruz
2012-08-27  5:51   ` Gerd Hoffmann [this message]
2012-08-24 19:14 ` [Qemu-devel] [PATCH 2/4] qxl: split qxl functions in common and pci files Erlon Cruz
2012-08-27  6:05   ` Gerd Hoffmann
2012-08-24 19:14 ` [Qemu-devel] [PATCH 3/4] qxl: implement VirtIO QXL (dummy) device support Erlon Cruz
2012-08-24 19:14 ` [Qemu-devel] [PATCH 4/4] qxl: introducing virtio-qxl Erlon Cruz
2012-08-27  6:08   ` Gerd Hoffmann
2012-08-27  6:08 ` [Qemu-devel] Implementing qxl-virtio on QEMU Gerd Hoffmann
2012-09-11 10:28   ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=503B0AE2.4080307@redhat.com \
    --to=kraxel@redhat.com \
    --cc=alevy@redhat.com \
    --cc=erlon.cruz@br.flextronics.com \
    --cc=erlon.cruz@fit-tecnologia.org.br \
    --cc=fabiano.fidencio@fit-tecnologia.org.br \
    --cc=fabiano@fidencio.org \
    --cc=fonsecasantos.rafael@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).