qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: Blue Swirl <blauwirbel@gmail.com>, Bob Breuer <breuerr@mc.net>,
	qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: Re: [Qemu-devel] [PATCH v4 26/39] pcnet: convert to memory API
Date: Tue, 9 Aug 2011 15:48:57 +0300	[thread overview]
Message-ID: <20110809124856.GI524@redhat.com> (raw)
In-Reply-To: <4E412BB3.9070703@redhat.com>

On Tue, Aug 09, 2011 at 03:44:35PM +0300, Avi Kivity wrote:
> On 08/09/2011 03:42 PM, Michael S. Tsirkin wrote:
> >On Tue, Aug 09, 2011 at 09:52:17AM +0300, Avi Kivity wrote:
> >>  On 08/09/2011 09:55 AM, Bob Breuer wrote:
> >>  >>    static void lance_cleanup(VLANClientState *nc)
> >>  >>   @@ -117,13 +116,11 @@ static int lance_init(SysBusDevice *dev)
> >>  >>        SysBusPCNetState *d = FROM_SYSBUS(SysBusPCNetState, dev);
> >>  >>        PCNetState *s =&d->state;
> >>  >>
> >>  >>   -    s->mmio_index =
> >>  >>   -        cpu_register_io_memory(lance_mem_read, lance_mem_write, d,
> >>  >>   -                               DEVICE_NATIVE_ENDIAN);
> >>  >>   +    memory_region_init_io(&s->mmio,&lance_mem_ops, s, "lance-mmio", 4);
> >>  >
> >>  >You've switched up d and s here, so anything that tries to talk to the
> >>  >ethernet, such as a sparc32 guest, will now cause Qemu to segfault.
> >>  >
> >>  >
> >>
> >>  Good catch; will post a fix.
> >>
> >>  Maybe keeping the opaque wasn't such a good idea.
> >
> >Yes, we typically can get from the mmio to the device state
> >using container_of.
> >
> >
> 
> But in some cases, we can't, and the it's a pain having to wrap
> MemoryRegion in another structure containing an opaque.

I guess, even though that wrapping structure would
use a proper type, not an opaque.

> Maybe a good compromise is to:
> 
>   - keep MemoryRegion::opaque
>   - pass a MemoryRegion *mr to callbacks instead of opaque
>   - use container_of() when possible
>   - use mr->opaque otherwise

Right. This even saves a memory dereference when opaque is
unused.

> -- 
> error compiling committee.c: too many arguments to function

  reply	other threads:[~2011-08-09 14:11 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-08 13:08 [Qemu-devel] [PATCH v4 00/39] Memory API, batch 2: PCI devices Avi Kivity
2011-08-08 13:08 ` [Qemu-devel] [PATCH v4 01/39] memory: rename PORTIO_END to PORTIO_END_OF_LIST Avi Kivity
2011-08-08 15:12   ` Anthony Liguori
2011-08-08 13:08 ` [Qemu-devel] [PATCH v4 02/39] pci: add API to get a BAR's mapped address Avi Kivity
2011-08-08 13:08 ` [Qemu-devel] [PATCH v4 03/39] vmsvga: don't remember pci BAR address in callback any more Avi Kivity
2011-08-08 13:08 ` [Qemu-devel] [PATCH v4 04/39] vga: convert vga and its derivatives to the memory API Avi Kivity
2011-08-08 13:08 ` [Qemu-devel] [PATCH v4 05/39] cirrus: simplify mmio BAR access functions Avi Kivity
2011-08-08 13:08 ` [Qemu-devel] [PATCH v4 06/39] cirrus: simplify bitblt " Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 07/39] cirrus: simplify vga window mmio " Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 08/39] vga: " Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 09/39] cirrus: simplify linear framebuffer " Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 10/39] Integrate I/O memory regions into qemu Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 11/39] pci: pass I/O address space to new PCI bus Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 12/39] pci: allow I/O BARs to be registered with pci_register_bar_region() Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 13/39] rtl8139: convert to memory API Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 14/39] ac97: " Avi Kivity
2011-08-09 10:09   ` malc
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 15/39] e1000: " Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 16/39] eepro100: " Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 17/39] es1370: " Avi Kivity
2011-08-09 10:10   ` malc
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 18/39] ide: " Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 19/39] ivshmem: " Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 20/39] virtio-pci: " Avi Kivity
2011-08-08 15:21   ` Anthony Liguori
2011-08-08 15:25     ` [Qemu-devel] [PATCH v4.1 " Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 21/39] ahci: " Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 22/39] intel-hda: " Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 23/39] lsi53c895a: " Avi Kivity
2011-08-10 19:28   ` Gerhard Wiesinger
2011-08-11  6:11     ` Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 24/39] ppc: " Avi Kivity
2011-09-08 16:34   ` Alexander Graf
2011-09-08 16:47   ` Alexander Graf
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 25/39] ne2000: " Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 26/39] pcnet: " Avi Kivity
2011-08-09  6:55   ` Bob Breuer
2011-08-09  6:52     ` Avi Kivity
2011-08-09 12:42       ` Michael S. Tsirkin
2011-08-09 12:44         ` Avi Kivity
2011-08-09 12:48           ` Michael S. Tsirkin [this message]
2011-08-09 12:52             ` Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 27/39] i6300esb: " Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 28/39] isa-mmio: " Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 29/39] sun4u: " Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 30/39] ehci: " Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 31/39] uhci: " Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 32/39] xen-platform: " Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 33/39] msix: " Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 34/39] pci: remove pci_register_bar_simple() Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 35/39] pci: convert pci rom to memory API Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 36/39] pci: remove pci_register_bar() Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 37/39] pci: fold BAR mapping function into its caller Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 38/39] pci: rename pci_register_bar_region() to pci_register_bar() Avi Kivity
2011-08-08 13:09 ` [Qemu-devel] [PATCH v4 39/39] pci: remove support for pre memory API BARs Avi Kivity
2011-08-08 15:16 ` [Qemu-devel] [PATCH v4 00/39] Memory API, batch 2: PCI devices Michael S. Tsirkin
2011-08-08 16:30 ` Anthony Liguori

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=20110809124856.GI524@redhat.com \
    --to=mst@redhat.com \
    --cc=avi@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=breuerr@mc.net \
    --cc=kvm@vger.kernel.org \
    --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).