summaryrefslogtreecommitdiffstats
path: root/hw/ide
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
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')
-rw-r--r--hw/ide/ahci.c15
-rw-r--r--hw/ide/ahci.h2
-rw-r--r--hw/ide/core.c22
3 files changed, 34 insertions, 5 deletions
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 8978643fff..063730e8df 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -1419,3 +1419,18 @@ static void sysbus_ahci_register_types(void)
}
type_init(sysbus_ahci_register_types)
+
+void ahci_ide_create_devs(PCIDevice *dev, DriveInfo **hd)
+{
+ AHCIPCIState *d = ICH_AHCI(dev);
+ AHCIState *ahci = &d->ahci;
+ int i;
+
+ for (i = 0; i < ahci->ports; i++) {
+ if (hd[i] == NULL) {
+ continue;
+ }
+ ide_create_drive(&ahci->dev[i].port, 0, hd[i]);
+ }
+
+}
diff --git a/hw/ide/ahci.h b/hw/ide/ahci.h
index 1543df7b7d..e223258820 100644
--- a/hw/ide/ahci.h
+++ b/hw/ide/ahci.h
@@ -332,4 +332,6 @@ void ahci_uninit(AHCIState *s);
void ahci_reset(AHCIState *s);
+void ahci_ide_create_devs(PCIDevice *dev, DriveInfo **hd);
+
#endif /* HW_IDE_AHCI_H */
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);
}
}