aboutsummaryrefslogtreecommitdiff
path: root/hw/pci-hotplug.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2009-07-22 16:42:57 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-07-27 14:08:23 -0500
commit751c6a17042b5d011013d6963c0505d671cf708e (patch)
tree61a769ed1a1c16ebdfc1397ce9d775222dfa8e57 /hw/pci-hotplug.c
parent8a14daa5a1ae22fcfc317f4727a88d6c15c39aae (diff)
kill drives_table
First step cleaning up the drives handling. This one does nothing but removing drives_table[], still it became seriously big. drive_get_index() is gone and is replaced by drives_get() which hands out DriveInfo pointers instead of a table index. This needs adaption in *tons* of places all over. The drives are now maintained as linked list. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/pci-hotplug.c')
-rw-r--r--hw/pci-hotplug.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c
index d0f2911d65..43675e2659 100644
--- a/hw/pci-hotplug.c
+++ b/hw/pci-hotplug.c
@@ -52,9 +52,10 @@ void drive_hot_add(Monitor *mon, const char *pci_addr, const char *opts)
{
int dom, pci_bus;
unsigned slot;
- int drive_idx, type, bus;
+ int type, bus;
int success = 0;
PCIDevice *dev;
+ DriveInfo *dinfo;
if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) {
return;
@@ -66,21 +67,21 @@ void drive_hot_add(Monitor *mon, const char *pci_addr, const char *opts)
return;
}
- drive_idx = add_init_drive(opts);
- if (drive_idx < 0)
+ dinfo = add_init_drive(opts);
+ if (!dinfo)
return;
- if (drives_table[drive_idx].devaddr) {
+ if (dinfo->devaddr) {
monitor_printf(mon, "Parameter addr not supported\n");
return;
}
- type = drives_table[drive_idx].type;
+ type = dinfo->type;
bus = drive_get_max_bus (type);
switch (type) {
case IF_SCSI:
success = 1;
- lsi_scsi_attach(&dev->qdev, drives_table[drive_idx].bdrv,
- drives_table[drive_idx].unit);
+ lsi_scsi_attach(&dev->qdev, dinfo->bdrv,
+ dinfo->unit);
break;
default:
monitor_printf(mon, "Can't hot-add drive to type %d\n", type);
@@ -88,8 +89,8 @@ void drive_hot_add(Monitor *mon, const char *pci_addr, const char *opts)
if (success)
monitor_printf(mon, "OK bus %d, unit %d\n",
- drives_table[drive_idx].bus,
- drives_table[drive_idx].unit);
+ dinfo->bus,
+ dinfo->unit);
return;
}
@@ -98,7 +99,8 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
const char *opts)
{
PCIDevice *dev;
- int type = -1, drive_idx = -1;
+ DriveInfo *dinfo;
+ int type = -1;
char buf[128];
if (get_param_value(buf, sizeof(buf), "if", opts)) {
@@ -116,10 +118,10 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
}
if (get_param_value(buf, sizeof(buf), "file", opts)) {
- drive_idx = add_init_drive(opts);
- if (drive_idx < 0)
+ dinfo = add_init_drive(opts);
+ if (!dinfo)
return NULL;
- if (drives_table[drive_idx].devaddr) {
+ if (dinfo->devaddr) {
monitor_printf(mon, "Parameter addr not supported\n");
return NULL;
}