diff options
Diffstat (limited to 'hw/pci-hotplug.c')
-rw-r--r-- | hw/pci-hotplug.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index ba13d2bce..41ce0041b 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -34,6 +34,7 @@ #include "virtio-blk.h" #include "qemu-config.h" #include "qemu-objects.h" +#include "device-assignment.h" #if defined(TARGET_I386) static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon, @@ -225,6 +226,24 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, return dev; } +#ifdef CONFIG_KVM_DEVICE_ASSIGNMENT +static PCIDevice *qemu_pci_hot_assign_device(Monitor *mon, + const char *devaddr, + const char *opts_str) +{ + QemuOpts *opts; + DeviceState *dev; + + opts = add_assigned_device(opts_str); + if (opts == NULL) { + monitor_printf(mon, "Error adding device; check syntax\n"); + return NULL; + } + dev = qdev_device_add(opts); + return DO_UPCAST(PCIDevice, qdev, dev); +} +#endif /* CONFIG_KVM_DEVICE_ASSIGNMENT */ + void pci_device_hot_add_print(Monitor *mon, const QObject *data) { QDict *qdict; @@ -277,6 +296,10 @@ void pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data) dev = qemu_pci_hot_add_nic(mon, pci_addr, opts); else if (strcmp(type, "storage") == 0) dev = qemu_pci_hot_add_storage(mon, pci_addr, opts); +#ifdef CONFIG_KVM_DEVICE_ASSIGNMENT + else if (strcmp(type, "host") == 0) + dev = qemu_pci_hot_assign_device(mon, pci_addr, opts); +#endif /* CONFIG_KVM_DEVICE_ASSIGNMENT */ else monitor_printf(mon, "invalid type: %s\n", type); |