From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 01/13] allow qdev busses allocations be inplace
Date: Tue, 22 Sep 2009 11:29:15 +0200 [thread overview]
Message-ID: <1253611767-6483-2-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1253611767-6483-1-git-send-email-kraxel@redhat.com>
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 <kraxel@redhat.com>
---
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
next prev parent reply other threads:[~2009-09-22 9:29 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-22 9:29 [Qemu-devel] [PATCH 00/13] qdev: bus management updates Gerd Hoffmann
2009-09-22 9:29 ` Gerd Hoffmann [this message]
2009-09-22 9:29 ` [Qemu-devel] [PATCH 02/13] switch scsi bus to inplace allocation Gerd Hoffmann
2009-09-22 9:29 ` [Qemu-devel] [PATCH 03/13] switch usb " Gerd Hoffmann
2009-09-22 9:29 ` [Qemu-devel] [PATCH 04/13] switch ide " Gerd Hoffmann
2009-09-22 9:29 ` [Qemu-devel] [PATCH 05/13] inplace allocation for pci, split irq init Gerd Hoffmann
2009-09-22 9:29 ` [Qemu-devel] [PATCH 06/13] convert pci bridge to qdev Gerd Hoffmann
2009-09-23 16:02 ` Michael S. Tsirkin
2009-09-24 18:29 ` Markus Armbruster
2009-09-24 18:51 ` Michael S. Tsirkin
2009-09-25 7:19 ` Gerd Hoffmann
2009-09-22 9:29 ` [Qemu-devel] [PATCH 07/13] piix_pci: kill PIIX3IrqState Gerd Hoffmann
2009-09-24 18:42 ` Markus Armbruster
2009-09-25 7:24 ` Gerd Hoffmann
2009-09-22 9:29 ` [Qemu-devel] [PATCH 08/13] qdev: device free fixups Gerd Hoffmann
2009-09-24 18:55 ` Markus Armbruster
2009-09-22 9:29 ` [Qemu-devel] [PATCH 09/13] Add exit callback to DeviceInfo Gerd Hoffmann
2009-09-22 10:06 ` Christoph Egger
2009-09-22 10:19 ` Gerd Hoffmann
2009-09-24 19:02 ` Markus Armbruster
2009-09-25 7:33 ` Gerd Hoffmann
2009-09-22 9:29 ` [Qemu-devel] [PATCH 10/13] Implement scsi device destruction Gerd Hoffmann
2009-09-24 19:15 ` Markus Armbruster
2009-09-25 7:45 ` Gerd Hoffmann
2009-09-25 13:10 ` Markus Armbruster
2009-09-25 14:54 ` Gerd Hoffmann
2009-09-25 15:59 ` Artyom Tarasenko
2009-09-25 16:31 ` Markus Armbruster
2009-09-22 9:29 ` [Qemu-devel] [PATCH 11/13] pci: use qdev for " Gerd Hoffmann
2009-09-22 9:29 ` [Qemu-devel] [PATCH 12/13] pci: move unregister from PCIDevice to PCIDeviceInfo Gerd Hoffmann
2009-09-23 15:58 ` Michael S. Tsirkin
2009-09-25 7:49 ` Gerd Hoffmann
2009-09-29 15:50 ` Michael S. Tsirkin
2009-09-29 18:16 ` Gerd Hoffmann
2009-09-22 9:29 ` [Qemu-devel] [PATCH 13/13] usb: hook unplug into qdev, cleanups + fixes Gerd Hoffmann
2009-09-24 19:18 ` [Qemu-devel] [PATCH 00/13] qdev: bus management updates Markus Armbruster
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=1253611767-6483-2-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.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).