[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/23] blockdev: Allow overriding if_max_dev property
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 09/23] blockdev: Allow overriding if_max_dev property |
Date: |
Sat, 4 Oct 2014 21:24:35 +0100 |
From: John Snow <address@hidden>
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 <address@hidden>
Reviewed-by: Markus Armbruster <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
blockdev.c | 26 +++++++++++++++++++++++++-
include/sysemu/blockdev.h | 2 ++
2 files changed, 27 insertions(+), 1 deletion(-)
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);
--
1.9.3
- [Qemu-devel] [PULL 00/23] Block patches, Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 01/23] snapshot: fix referencing wrong variable in while loop in do_delvm, Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 02/23] ssh: Don't crash if either host or path is not specified., Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 04/23] vmdk: Fix integer overflow in offset calculation, Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 03/23] block: Drop superfluous conditionals around qemu_opts_del(), Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 05/23] Modify qemu_opt_rename to realize renaming all items in opts, Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 06/23] make check-block: Use default cache modes, Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 07/23] qemu-iotests: Fix supported cache modes for 052, Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 08/23] blockdev: Orphaned drive search, Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 09/23] blockdev: Allow overriding if_max_dev property,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 11/23] ide: Update ide_drive_get to be HBA agnostic, Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 12/23] qtest/bios-tables: Correct Q35 command line, Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 10/23] pc/vl: Add units-per-default-bus property, Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 13/23] q35/ahci: Pick up -cdrom and -hda options, Stefan Hajnoczi, 2014/10/04
[Qemu-devel] [PULL 14/23] util: Emancipate id_wellformed() from QemuOpts, Stefan Hajnoczi, 2014/10/04
[Qemu-devel] [PULL 15/23] iotests: Use _img_info, Stefan Hajnoczi, 2014/10/04