On 08/04/2011 08:06 AM, Avi Kivity wrote:
fixes memory leak on repeated BAR map/unmap

Reviewed-by: Richard Henderson<r...@twiddle.net>
Signed-off-by: Avi Kivity<a...@redhat.com>
---
  hw/sun4u.c |   55 +++++++++++++++++++++++++------------------------------
  1 files changed, 25 insertions(+), 30 deletions(-)

diff --git a/hw/sun4u.c b/hw/sun4u.c
index d7dcaf0..74a06a8 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -91,6 +91,12 @@ struct hwdef {
      uint64_t console_serial_base;
  };

+typedef struct EbusState {
+    PCIDevice pci_dev;
+    MemoryRegion bar0;
+    MemoryRegion bar1;
+} EbusState;
+
  int DMA_get_channel_mode (int nchan)
  {
      return 0;
@@ -518,21 +524,6 @@ void cpu_tick_set_limit(CPUTimer *timer, uint64_t limit)
      }
  }

-static void ebus_mmio_mapfunc(PCIDevice *pci_dev, int region_num,
-                              pcibus_t addr, pcibus_t size, int type)
-{
-    EBUS_DPRINTF("Mapping region %d registers at %" FMT_PCIBUS "\n",
-                 region_num, addr);
-    switch (region_num) {
-    case 0:
-        isa_mmio_init(addr, 0x1000000);
-        break;
-    case 1:
-        isa_mmio_init(addr, 0x800000);
-        break;
-    }
-}
-
  static void dummy_isa_irq_handler(void *opaque, int n, int level)
  {
  }
@@ -549,27 +540,31 @@ pci_ebus_init(PCIBus *bus, int devfn)
  }

  static int
-pci_ebus_init1(PCIDevice *s)
+pci_ebus_init1(PCIDevice *pci_dev)
  {
-    isa_bus_new(&s->qdev);
+    EbusState *s = container_of(pci_dev, EbusState, pci_dev);

DO_UPCAST() is the qdev macro for this.

Regards,

Anthony Liguori
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to