>From 572ff4912ed021c7b4bb2076d8d72e497f0c434b Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 15 Oct 2009 09:55:11 +0200 Subject: [PATCH] fix virtio blk hotplugging. Signed-off-by: Gerd Hoffmann --- hw/pci-hotplug.c | 2 ++ hw/qdev.c | 8 ++++++++ sysemu.h | 1 + 3 files changed, 11 insertions(+), 0 deletions(-) diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index 8bedea2..658564e 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -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; diff --git a/hw/qdev.c b/hw/qdev.c index faecc76..9dd896b 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -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; diff --git a/sysemu.h b/sysemu.h index ce25109..6dc2b4f 100644 --- a/sysemu.h +++ b/sysemu.h @@ -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]; -- 1.6.2.5