diff options
author | Kevin Wolf | 2013-05-06 15:58:04 +0200 |
---|---|---|
committer | Kevin Wolf | 2013-05-08 15:28:49 +0200 |
commit | 0ee20e665840d8a887c145b368ee121cb86a028e (patch) | |
tree | 6908ec6f1357c52a71c71896699e7e03ce8d0496 /hw/ide/qdev.c | |
parent | Update version for qemu-1.5.0-rc0 (diff) | |
download | qemu-0ee20e665840d8a887c145b368ee121cb86a028e.tar.gz qemu-0ee20e665840d8a887c145b368ee121cb86a028e.tar.xz qemu-0ee20e665840d8a887c145b368ee121cb86a028e.zip |
ahci: Don't allow creating slave drives
An IDE bus provided by AHCI can only take a single IDE drive. If you add
a drive as slave, qemu used to accept the command line but the device
wouldn't be actually usable. Catch the situation instead and error out.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/ide/qdev.c')
-rw-r--r-- | hw/ide/qdev.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 8a9a891769..6a272b046d 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -47,10 +47,11 @@ static const TypeInfo ide_bus_info = { .class_init = ide_bus_class_init, }; -void ide_bus_new(IDEBus *idebus, DeviceState *dev, int bus_id) +void ide_bus_new(IDEBus *idebus, DeviceState *dev, int bus_id, int max_units) { qbus_create_inplace(&idebus->qbus, TYPE_IDE_BUS, dev, NULL); idebus->bus_id = bus_id; + idebus->max_units = max_units; } static char *idebus_get_fw_dev_path(DeviceState *dev) @@ -76,6 +77,13 @@ static int ide_qdev_init(DeviceState *qdev) if (dev->unit == -1) { dev->unit = bus->master ? 1 : 0; } + + if (dev->unit >= bus->max_units) { + error_report("Can't create IDE unit %d, bus supports only %d units", + dev->unit, bus->max_units); + goto err; + } + switch (dev->unit) { case 0: if (bus->master) { |