summaryrefslogtreecommitdiffstats
path: root/hw/ide/core.c
diff options
context:
space:
mode:
authorPeter Maydell2014-10-06 11:59:55 +0200
committerPeter Maydell2014-10-06 11:59:56 +0200
commit507ef2f9fab3e67ac6fefda4e20db7fc5f2bc186 (patch)
tree71c2dc7fcfeb4f0b0dfba1287e191998b1375c79 /hw/ide/core.c
parentMerge remote-tracking branch 'remotes/kraxel/tags/pull-input-20141002-1' into... (diff)
parentblockdev-test: Test device_del after drive_del (diff)
downloadqemu-507ef2f9fab3e67ac6fefda4e20db7fc5f2bc186.tar.gz
qemu-507ef2f9fab3e67ac6fefda4e20db7fc5f2bc186.tar.xz
qemu-507ef2f9fab3e67ac6fefda4e20db7fc5f2bc186.zip
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
# gpg: Signature made Sat 04 Oct 2014 21:24:46 BST using RSA key ID 81AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" * remotes/stefanha/tags/block-pull-request: (23 commits) blockdev-test: Test device_del after drive_del blockdev-test: Factor out some common code into helpers blockdev-test: Simplify by using g_assert_cmpstr() blockdev-test: Clean up bogus drive_add argument blockdev-test: Use single rather than double quotes in QMP drive_del-test: Merge of qdev-monitor-test, blockdev-test iotests: qemu-img info output for corrupt image qapi: Add corrupt field to ImageInfoSpecificQCow2 iotests: Use _img_info util: Emancipate id_wellformed() from QemuOpts q35/ahci: Pick up -cdrom and -hda options qtest/bios-tables: Correct Q35 command line ide: Update ide_drive_get to be HBA agnostic pc/vl: Add units-per-default-bus property blockdev: Allow overriding if_max_dev property blockdev: Orphaned drive search qemu-iotests: Fix supported cache modes for 052 make check-block: Use default cache modes Modify qemu_opt_rename to realize renaming all items in opts vmdk: Fix integer overflow in offset calculation ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/ide/core.c')
-rw-r--r--hw/ide/core.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 190700ac74..ae85428864 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2558,16 +2558,28 @@ const VMStateDescription vmstate_ide_bus = {
}
};
-void ide_drive_get(DriveInfo **hd, int max_bus)
+void ide_drive_get(DriveInfo **hd, int n)
{
int i;
+ int highest_bus = drive_get_max_bus(IF_IDE) + 1;
+ int max_devs = drive_get_max_devs(IF_IDE);
+ int n_buses = max_devs ? (n / max_devs) : n;
- if (drive_get_max_bus(IF_IDE) >= max_bus) {
- fprintf(stderr, "qemu: too many IDE bus: %d\n", max_bus);
+ /*
+ * Note: The number of actual buses available is not known.
+ * We compute this based on the size of the DriveInfo* array, n.
+ * If it is less than max_devs * <num_real_buses>,
+ * We will stop looking for drives prematurely instead of overfilling
+ * the array.
+ */
+
+ if (highest_bus > n_buses) {
+ error_report("Too many IDE buses defined (%d > %d)",
+ highest_bus, n_buses);
exit(1);
}
- for(i = 0; i < max_bus * MAX_IDE_DEVS; i++) {
- hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS);
+ for (i = 0; i < n; i++) {
+ hd[i] = drive_get_by_index(IF_IDE, i);
}
}