aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2014-10-01 14:19:25 -0400
committerStefan Hajnoczi <stefanha@redhat.com>2014-10-03 10:30:33 +0100
commit21dff8cf38d311a917ab33f19d5cea7696f0c354 (patch)
treed396c06d9c1fe5bbbf010b8996382cdc9aa899a3
parenta66c9dc734fb30de1e18e9dc217f2d37e16c492a (diff)
downloadqemu-21dff8cf38d311a917ab33f19d5cea7696f0c354.zip
qemu-21dff8cf38d311a917ab33f19d5cea7696f0c354.tar.gz
qemu-21dff8cf38d311a917ab33f19d5cea7696f0c354.tar.bz2
blockdev: Allow overriding if_max_dev property
The if_max_devs table as in the past been an immutable default that controls the mapping of index => (bus,unit) for all boards and all HBAs for each interface type. Since adding this mapping information to the HBA device itself is currently unwieldly from the perspective of retrieving this information at option parsing time (e.g, within drive_new), we consider the alternative of marking the if_max_devs table mutable so that later configuration and initialization can adjust the mapping at will, but only up until a drive is added, at which point the mapping is finalized. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-id: 1412187569-23452-3-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-rw-r--r--blockdev.c26
-rw-r--r--include/sysemu/blockdev.h2
2 files changed, 27 insertions, 1 deletions
diff --git a/blockdev.c b/blockdev.c
index 48da1a7..1780d77 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -60,7 +60,7 @@ static const char *const if_name[IF_COUNT] = {
[IF_XEN] = "xen",
};
-static const int if_max_devs[IF_COUNT] = {
+static int if_max_devs[IF_COUNT] = {
/*
* Do not change these numbers! They govern how drive option
* index maps to unit and bus. That mapping is ABI.
@@ -79,6 +79,30 @@ static const int if_max_devs[IF_COUNT] = {
[IF_SCSI] = 7,
};
+/**
+ * Boards may call this to offer board-by-board overrides
+ * of the default, global values.
+ */
+void override_max_devs(BlockInterfaceType type, int max_devs)
+{
+ DriveInfo *dinfo;
+
+ if (max_devs <= 0) {
+ return;
+ }
+
+ QTAILQ_FOREACH(dinfo, &drives, next) {
+ if (dinfo->type == type) {
+ fprintf(stderr, "Cannot override units-per-bus property of"
+ " the %s interface, because a drive of that type has"
+ " already been added.\n", if_name[type]);
+ g_assert_not_reached();
+ }
+ }
+
+ if_max_devs[type] = max_devs;
+}
+
/*
* We automatically delete the drive when a device using it gets
* unplugged. Questionable feature, but we can't just drop it.
diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
index 3040286..a4033d4 100644
--- a/include/sysemu/blockdev.h
+++ b/include/sysemu/blockdev.h
@@ -46,6 +46,8 @@ struct DriveInfo {
QTAILQ_ENTRY(DriveInfo) next;
};
+void override_max_devs(BlockInterfaceType type, int max_devs);
+
DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit);
bool drive_check_orphaned(void);
DriveInfo *drive_get_by_index(BlockInterfaceType type, int index);