[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 26/39] pcnet: convert to memory API
From: |
Michael S. Tsirkin |
Subject: |
Re: [Qemu-devel] [PATCH v4 26/39] pcnet: convert to memory API |
Date: |
Tue, 9 Aug 2011 15:48:57 +0300 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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
- [Qemu-devel] [PATCH v4 17/39] es1370: convert to memory API, (continued)
- [Qemu-devel] [PATCH v4 17/39] es1370: convert to memory API, Avi Kivity, 2011/08/08
- [Qemu-devel] [PATCH v4 11/39] pci: pass I/O address space to new PCI bus, Avi Kivity, 2011/08/08
- [Qemu-devel] [PATCH v4 22/39] intel-hda: convert to memory API, Avi Kivity, 2011/08/08
- [Qemu-devel] [PATCH v4 16/39] eepro100: convert to memory API, Avi Kivity, 2011/08/08
- [Qemu-devel] [PATCH v4 26/39] pcnet: convert to memory API, Avi Kivity, 2011/08/08
[Qemu-devel] [PATCH v4 05/39] cirrus: simplify mmio BAR access functions, Avi Kivity, 2011/08/08
[Qemu-devel] [PATCH v4 12/39] pci: allow I/O BARs to be registered with pci_register_bar_region(), Avi Kivity, 2011/08/08
[Qemu-devel] [PATCH v4 02/39] pci: add API to get a BAR's mapped address, Avi Kivity, 2011/08/08
[Qemu-devel] [PATCH v4 35/39] pci: convert pci rom to memory API, Avi Kivity, 2011/08/08
[Qemu-devel] [PATCH v4 21/39] ahci: convert to memory API, Avi Kivity, 2011/08/08
[Qemu-devel] [PATCH v4 27/39] i6300esb: convert to memory API, Avi Kivity, 2011/08/08
[Qemu-devel] [PATCH v4 10/39] Integrate I/O memory regions into qemu, Avi Kivity, 2011/08/08
[Qemu-devel] [PATCH v4 29/39] sun4u: convert to memory API, Avi Kivity, 2011/08/08
[Qemu-devel] [PATCH v4 34/39] pci: remove pci_register_bar_simple(), Avi Kivity, 2011/08/08