Revision 751c6a17 hw/pci-hotplug.c
b/hw/pci-hotplug.c | ||
---|---|---|
52 | 52 |
{ |
53 | 53 |
int dom, pci_bus; |
54 | 54 |
unsigned slot; |
55 |
int drive_idx, type, bus;
|
|
55 |
int type, bus; |
|
56 | 56 |
int success = 0; |
57 | 57 |
PCIDevice *dev; |
58 |
DriveInfo *dinfo; |
|
58 | 59 |
|
59 | 60 |
if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) { |
60 | 61 |
return; |
... | ... | |
66 | 67 |
return; |
67 | 68 |
} |
68 | 69 |
|
69 |
drive_idx = add_init_drive(opts);
|
|
70 |
if (drive_idx < 0)
|
|
70 |
dinfo = add_init_drive(opts);
|
|
71 |
if (!dinfo)
|
|
71 | 72 |
return; |
72 |
if (drives_table[drive_idx].devaddr) {
|
|
73 |
if (dinfo->devaddr) {
|
|
73 | 74 |
monitor_printf(mon, "Parameter addr not supported\n"); |
74 | 75 |
return; |
75 | 76 |
} |
76 |
type = drives_table[drive_idx].type;
|
|
77 |
type = dinfo->type;
|
|
77 | 78 |
bus = drive_get_max_bus (type); |
78 | 79 |
|
79 | 80 |
switch (type) { |
80 | 81 |
case IF_SCSI: |
81 | 82 |
success = 1; |
82 |
lsi_scsi_attach(&dev->qdev, drives_table[drive_idx].bdrv,
|
|
83 |
drives_table[drive_idx].unit);
|
|
83 |
lsi_scsi_attach(&dev->qdev, dinfo->bdrv,
|
|
84 |
dinfo->unit);
|
|
84 | 85 |
break; |
85 | 86 |
default: |
86 | 87 |
monitor_printf(mon, "Can't hot-add drive to type %d\n", type); |
... | ... | |
88 | 89 |
|
89 | 90 |
if (success) |
90 | 91 |
monitor_printf(mon, "OK bus %d, unit %d\n", |
91 |
drives_table[drive_idx].bus,
|
|
92 |
drives_table[drive_idx].unit);
|
|
92 |
dinfo->bus,
|
|
93 |
dinfo->unit);
|
|
93 | 94 |
return; |
94 | 95 |
} |
95 | 96 |
|
... | ... | |
98 | 99 |
const char *opts) |
99 | 100 |
{ |
100 | 101 |
PCIDevice *dev; |
101 |
int type = -1, drive_idx = -1; |
|
102 |
DriveInfo *dinfo; |
|
103 |
int type = -1; |
|
102 | 104 |
char buf[128]; |
103 | 105 |
|
104 | 106 |
if (get_param_value(buf, sizeof(buf), "if", opts)) { |
... | ... | |
116 | 118 |
} |
117 | 119 |
|
118 | 120 |
if (get_param_value(buf, sizeof(buf), "file", opts)) { |
119 |
drive_idx = add_init_drive(opts);
|
|
120 |
if (drive_idx < 0)
|
|
121 |
dinfo = add_init_drive(opts);
|
|
122 |
if (!dinfo)
|
|
121 | 123 |
return NULL; |
122 |
if (drives_table[drive_idx].devaddr) {
|
|
124 |
if (dinfo->devaddr) {
|
|
123 | 125 |
monitor_printf(mon, "Parameter addr not supported\n"); |
124 | 126 |
return NULL; |
125 | 127 |
} |
Also available in: Unified diff