@@ -239,7 +239,7 @@ static void pc_init1(MachineState *machine,
pc_nic_init(isa_bus, pci_bus);
- ide_drive_get(hd, MAX_IDE_BUS);
+ ide_drive_get(hd, IF_IDE, MAX_IDE_BUS);
if (pci_enabled) {
PCIDevice *dev;
if (xen_enabled()) {
@@ -2481,16 +2481,19 @@ const VMStateDescription vmstate_ide_bus = {
}
};
-void ide_drive_get(DriveInfo **hd, int max_bus)
+void ide_drive_get(DriveInfo **hd, BlockInterfaceType type, int max_bus)
{
int i;
- if (drive_get_max_bus(IF_IDE) >= max_bus) {
+ if (drive_get_max_bus(type) >= max_bus) {
fprintf(stderr, "qemu: too many IDE bus: %d\n", max_bus);
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 < max_bus * if_get_max_devs(type); i++) {
+ fprintf(stderr, "hd[%u] := drive_get_by_index(%d, %u);\n",
+ i, type, i);
+ hd[i] = drive_get_by_index(type, i);
+ fprintf(stderr, "hd[%u] := %p\n", i, (void *)hd[i]);
}
}
@@ -4,6 +4,7 @@
#include "hw/isa/isa.h"
#include "hw/pci/pci.h"
#include "exec/memory.h"
+#include "sysemu/blockdev.h"
#define MAX_IDE_DEVS 2
@@ -28,6 +29,6 @@ int ide_get_geometry(BusState *bus, int unit,
int ide_get_bios_chs_trans(BusState *bus, int unit);
/* ide/core.c */
-void ide_drive_get(DriveInfo **hd, int max_bus);
+void ide_drive_get(DriveInfo **hd, BlockInterfaceType type, int max_bus);
#endif /* HW_IDE_H */
Signed-off-by: John Snow <jsnow@redhat.com> --- hw/i386/pc_piix.c | 2 +- hw/ide/core.c | 11 +++++++---- include/hw/ide.h | 3 ++- 3 files changed, 10 insertions(+), 6 deletions(-)