Comments
Patch
@@ -147,7 +147,9 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
drives_table[drive_idx].unit);
break;
case IF_VIRTIO:
+ drives_table[drive_idx].qdev_pick_this_one_please = 1;
dev = pci_create("virtio-blk-pci", devaddr);
+ drives_table[drive_idx].qdev_pick_this_one_please = 0;
break;
default:
dev = NULL;
@@ -191,6 +191,14 @@ BlockDriverState *qdev_init_bdrv(DeviceState *dev, BlockInterfaceType type)
int unit = next_block_unit[type]++;
int index;
+ for (index = 0; index < MAX_DRIVES; index++) {
+ if (!drives_table[index].used)
+ continue;
+ if (!drives_table[index].qdev_pick_this_one_please)
+ continue;
+ return drives_table[index].bdrv;
+ }
+
index = drive_get_index(type, 0, unit);
if (index == -1) {
return NULL;
@@ -173,6 +173,7 @@ typedef struct DriveInfo {
int bus;
int unit;
int used;
+ int qdev_pick_this_one_please; /* band-aid for virtio-blk hotplug */
int drive_opt_idx;
BlockInterfaceErrorAction onerror;
char serial[BLOCK_SERIAL_STRLEN + 1];