[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 02/24] allow qdev busses allocations be inplace
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 02/24] allow qdev busses allocations be inplace |
Date: |
Fri, 25 Sep 2009 21:42:27 +0200 |
A bus usually is instanciated by the parent device. The accociated bus
state can usually be embeeded into the parent device state struct, there
is no need for separate allocation and pointer indirection.
This patch adds a non-allocating qbus_create variant. We keep track of
whenever qdev allocated the struct or not. Will be needed later in this
patch series when we'll fix bus unplugging.
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/qdev.c | 15 ++++++++++++---
hw/qdev.h | 3 +++
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index 43b1beb..43372c1 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -502,13 +502,12 @@ static BusState *qbus_find(const char *path)
}
}
-BusState *qbus_create(BusInfo *info, DeviceState *parent, const char *name)
+void qbus_create_inplace(BusState *bus, BusInfo *info,
+ DeviceState *parent, const char *name)
{
- BusState *bus;
char *buf;
int i,len;
- bus = qemu_mallocz(info->size);
bus->info = info;
bus->parent = parent;
@@ -537,6 +536,16 @@ BusState *qbus_create(BusInfo *info, DeviceState *parent,
const char *name)
QLIST_INSERT_HEAD(&parent->child_bus, bus, sibling);
parent->num_child_bus++;
}
+
+}
+
+BusState *qbus_create(BusInfo *info, DeviceState *parent, const char *name)
+{
+ BusState *bus;
+
+ bus = qemu_mallocz(info->size);
+ bus->qdev_allocated = 1;
+ qbus_create_inplace(bus, info, parent, name);
return bus;
}
diff --git a/hw/qdev.h b/hw/qdev.h
index 623ded5..ccc45b9 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -47,6 +47,7 @@ struct BusState {
DeviceState *parent;
BusInfo *info;
const char *name;
+ int qdev_allocated;
QLIST_HEAD(, DeviceState) children;
QLIST_ENTRY(BusState) sibling;
};
@@ -144,6 +145,8 @@ BusState *qdev_get_parent_bus(DeviceState *dev);
/*** BUS API. ***/
+void qbus_create_inplace(BusState *bus, BusInfo *info,
+ DeviceState *parent, const char *name);
BusState *qbus_create(BusInfo *info, DeviceState *parent, const char *name);
#define FROM_QBUS(type, dev) DO_UPCAST(type, qbus, dev)
--
1.6.2.5
- [Qemu-devel] [PATCH 00/24] qdev: bus management updates., Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 01/24] unbreak usb pass-through on linux., Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 05/24] switch ide bus to inplace allocation., Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 04/24] switch usb bus to inplace allocation., Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 03/24] switch scsi bus to inplace allocation., Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 06/24] inplace allocation for pci, split irq init., Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 02/24] allow qdev busses allocations be inplace,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 08/24] piix_pci: kill PIIX3IrqState, Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 10/24] Add exit callback to DeviceInfo., Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 12/24] pci: use qdev for device destruction., Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 07/24] convert pci bridge to qdev, Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 13/24] pci: move unregister from PCIDevice to PCIDeviceInfo, Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 11/24] Implement scsi device destruction, Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 09/24] qdev: device free fixups., Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 14/24] usb: hook unplug into qdev, cleanups + fixes., Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 17/24] usb: hotplug windup, Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 23/24] allow if=none for drive_add, Gerd Hoffmann, 2009/09/25