From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Markus Armbruster <armbru@redhat.com>
Subject: [Qemu-devel] [RFC PATCH v2 11/13] qdev: introduce automatic creation of buses
Date: Mon, 6 Jun 2011 18:04:20 +0200 [thread overview]
Message-ID: <1307376262-1255-12-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1307376262-1255-1-git-send-email-pbonzini@redhat.com>
When a logical unit is hung directly below an HBA, we want to introduce
the "missing levels" to avoid duplicating generic target code across
all devices. To do this, I introduce a callback in qdev that is given
the bus specified by the user, and returns the actual bus to use.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
---
hw/qdev.c | 13 +++++++++++++
hw/qdev.h | 3 +++
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index 9519f5d..847bcda 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -204,6 +204,17 @@ int qdev_device_help(QemuOpts *opts)
return 1;
}
+static BusState *qbus_realize_topology(BusState *bus, DeviceInfo *info,
+ QemuOpts *opts)
+{
+ BusState *old = NULL;
+ while (old != bus && bus->info->realize_topology) {
+ old = bus;
+ bus = bus->info->realize_topology(bus, info, opts);
+ }
+ return bus;
+}
+
DeviceState *qdev_device_add(QemuOpts *opts)
{
const char *driver, *path, *id;
@@ -245,6 +256,8 @@ DeviceState *qdev_device_add(QemuOpts *opts)
return NULL;
}
}
+
+ bus = qbus_realize_topology(bus, info, opts);
if (qdev_hotplug && !bus->allow_hotplug) {
qerror_report(QERR_BUS_NO_HOTPLUG, bus->name);
return NULL;
diff --git a/hw/qdev.h b/hw/qdev.h
index 8a13ec9..ae18406 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -56,6 +56,8 @@ typedef char *(*bus_get_dev_path)(DeviceState *dev);
*/
typedef char *(*bus_get_fw_dev_path)(DeviceState *dev);
typedef int (qbus_resetfn)(BusState *bus);
+typedef BusState *(*bus_realize_topology)(BusState *bus, DeviceInfo *dev,
+ QemuOpts *opts);
struct BusInfo {
const char *name;
@@ -63,6 +65,7 @@ struct BusInfo {
bus_dev_printfn print_dev;
bus_get_dev_path get_dev_path;
bus_get_fw_dev_path get_fw_dev_path;
+ bus_realize_topology realize_topology;
qbus_resetfn *reset;
Property *props;
};
--
1.7.4.4
next prev parent reply other threads:[~2011-06-06 16:05 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-06 16:04 [Qemu-devel] [RFC PATCH v2 00/13] support hierarchical LUNs Paolo Bonzini
2011-06-06 16:04 ` [Qemu-devel] [RFC PATCH v2 01/13] scsi: cleanup reset and destroy callbacks Paolo Bonzini
2011-06-06 16:04 ` [Qemu-devel] [RFC PATCH v2 02/13] scsi: support parsing of SAM logical unit numbers Paolo Bonzini
2011-06-06 16:04 ` [Qemu-devel] [RFC PATCH v2 03/13] scsi: add initiator field to SCSIRequest Paolo Bonzini
2011-06-06 16:04 ` [Qemu-devel] [RFC PATCH v2 04/13] scsi: let a SCSIDevice have children devices Paolo Bonzini
2011-06-06 16:04 ` [Qemu-devel] [RFC PATCH v2 05/13] scsi: let the bus pick a LUN for the child device Paolo Bonzini
2011-06-06 16:04 ` [Qemu-devel] [RFC PATCH v2 06/13] scsi-generic: fix passthrough of devices with LUN != 0 Paolo Bonzini
2011-06-06 16:04 ` [Qemu-devel] [RFC PATCH v2 07/13] scsi: add walking of hierarchical LUNs Paolo Bonzini
2011-06-06 16:04 ` [Qemu-devel] [RFC PATCH v2 08/13] scsi: introduce the scsi-path device Paolo Bonzini
2011-06-06 16:04 ` [Qemu-devel] [RFC PATCH v2 09/13] scsi: introduce the scsi-target device Paolo Bonzini
2011-06-07 8:09 ` Stefan Hajnoczi
2011-06-06 16:04 ` [Qemu-devel] [RFC PATCH v2 10/13] scsi: include bus and device levels Paolo Bonzini
2011-06-06 16:04 ` Paolo Bonzini [this message]
2011-06-06 16:04 ` [Qemu-devel] [RFC PATCH v2 12/13] scsi: create scsi-path and scsi-target devices automatically Paolo Bonzini
2011-06-06 16:04 ` [Qemu-devel] [RFC PATCH v2 13/13] scsi: delete handling of REPORT LUNS and unknown LUNs outside scsi-target Paolo Bonzini
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=1307376262-1255-12-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=armbru@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).