From: Eric Farman Date: Thu, 21 Nov 2013 03:36:27 +0000 (-0500) Subject: qemu: Auto-generate controller for hotplugged hostdev X-Git-Tag: v1.2.0-rc1~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=881eb78064c1dcda8d8fc4b7758b583b87298c1d;p=thirdparty%2Flibvirt.git qemu: Auto-generate controller for hotplugged hostdev If a SCSI hostdev is included in an initial domain XML, without a corresponding controller statement, one is created silently when the guest is booted. When hotplugging a SCSI hostdev, a presumption is that the controller is already present in the domain either from the original XML, or via an earlier hotplug. [root@xxxxxxxx ~]# cat disk.xml
[root@xxxxxxxx ~]# virsh attach-device guest01 disk.xml error: Failed to attach device from disk.xml error: internal error: unable to execute QEMU command 'device_add': Bus 'scsi0.0' not found Since the infrastructure is in place, we can also create a controller silently for use by the hotplugged hostdev device. Signed-off-by: Eric Farman --- diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index f11d755844..649c884445 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1509,6 +1509,7 @@ qemuDomainAttachHostScsiDevice(virQEMUDriverPtr driver, { int ret = -1; qemuDomainObjPrivatePtr priv = vm->privateData; + virDomainControllerDefPtr cont = NULL; char *devstr = NULL; char *drvstr = NULL; bool teardowncgroup = false; @@ -1521,6 +1522,10 @@ qemuDomainAttachHostScsiDevice(virQEMUDriverPtr driver, return -1; } + cont = qemuDomainFindOrCreateSCSIDiskController(driver, vm, hostdev->info->addr.drive.controller); + if (!cont) + return -1; + if (qemuPrepareHostdevSCSIDevices(driver, vm->def->name, &hostdev, 1)) { virReportError(VIR_ERR_INTERNAL_ERROR,