[libvirt] [PATCH 0/3 RESEND] qemu: Hotplug SCSI controllers/hostdevs

(Resending, as this has perhaps been lost during the release of 1.1.3. I've rebased this patch series onto today's git repository.) Today, hotplug of a SCSI hostdev relies on the presence of an existing SCSI controller, which can be defined in the initial domain XML. Hotplug of a SCSI controller relies on the presence of a PCI bus, which does not work in all environments. These patches correct this behavior, in order to allow hotplug (and unplug) work without incident. Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com> Eric Farman (3): qemu: Rename controller hotplug functions to not be PCI-specific qemu: Separate calls based on controller bus type qemu: Auto-generate controller for hotplugged hostdev src/qemu/qemu_driver.c | 4 +-- src/qemu/qemu_hotplug.c | 62 ++++++++++++++++++++++++++++++++--------------- src/qemu/qemu_hotplug.h | 12 ++++----- 3 files changed, 50 insertions(+), 28 deletions(-) -- 1.7.9.5

For attach/detach of controller devices, we rename the functions to remove 'PCI' from their title. The actual separation of PCI-specific operations will be handled in the next patch. Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com> --- src/qemu/qemu_driver.c | 4 ++-- src/qemu/qemu_hotplug.c | 12 ++++++------ src/qemu/qemu_hotplug.h | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c71aecc..60bcd1a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6300,7 +6300,7 @@ qemuDomainAttachDeviceControllerLive(virQEMUDriverPtr driver, switch (cont->type) { case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: - ret = qemuDomainAttachPciControllerDevice(driver, vm, cont); + ret = qemuDomainAttachControllerDevice(driver, vm, cont); break; default: virReportError(VIR_ERR_OPERATION_UNSUPPORTED, @@ -6392,7 +6392,7 @@ qemuDomainDetachDeviceControllerLive(virQEMUDriverPtr driver, switch (cont->type) { case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: - ret = qemuDomainDetachPciControllerDevice(driver, vm, dev); + ret = qemuDomainDetachControllerDevice(driver, vm, dev); break; default : virReportError(VIR_ERR_OPERATION_UNSUPPORTED, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 818c726..bc0f57a 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -348,9 +348,9 @@ error: } -int qemuDomainAttachPciControllerDevice(virQEMUDriverPtr driver, - virDomainObjPtr vm, - virDomainControllerDefPtr controller) +int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainControllerDefPtr controller) { int ret = -1; const char* type = virDomainControllerTypeToString(controller->type); @@ -438,8 +438,8 @@ qemuDomainFindOrCreateSCSIDiskController(virQEMUDriverPtr driver, cont->model = -1; VIR_INFO("No SCSI controller present, hotplugging one"); - if (qemuDomainAttachPciControllerDevice(driver, - vm, cont) < 0) { + if (qemuDomainAttachControllerDevice(driver, + vm, cont) < 0) { VIR_FREE(cont); return NULL; } @@ -3004,7 +3004,7 @@ static bool qemuDomainControllerIsBusy(virDomainObjPtr vm, } } -int qemuDomainDetachPciControllerDevice(virQEMUDriverPtr driver, +int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev) { diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index 355d809..75789d6 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -36,9 +36,9 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver, int qemuDomainCheckEjectableMedia(virQEMUDriverPtr driver, virDomainObjPtr vm, enum qemuDomainAsyncJob asyncJob); -int qemuDomainAttachPciControllerDevice(virQEMUDriverPtr driver, - virDomainObjPtr vm, - virDomainControllerDefPtr controller); +int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainControllerDefPtr controller); int qemuDomainAttachDeviceDiskLive(virConnectPtr conn, virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -78,9 +78,9 @@ int qemuDomainChangeNetLinkState(virQEMUDriverPtr driver, int qemuDomainDetachDeviceDiskLive(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev); -int qemuDomainDetachPciControllerDevice(virQEMUDriverPtr driver, - virDomainObjPtr vm, - virDomainDeviceDefPtr dev); +int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainDeviceDefPtr dev); int qemuDomainDetachNetDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev); -- 1.7.9.5

On 10/08/2013 02:45 PM, Eric Farman wrote:
For attach/detach of controller devices, we rename the functions to remove 'PCI' from their title. The actual separation of PCI-specific operations will be handled in the next patch.
Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com> --- src/qemu/qemu_driver.c | 4 ++-- src/qemu/qemu_hotplug.c | 12 ++++++------ src/qemu/qemu_hotplug.h | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 818c726..bc0f57a 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3004,7 +3004,7 @@ static bool qemuDomainControllerIsBusy(virDomainObjPtr vm, } }
-int qemuDomainDetachPciControllerDevice(virQEMUDriverPtr driver, +int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev) {
Indentation is off here. ACK Jan

For systems without a PCI bus, attaching a SCSI controller fails: [root@xxxxxxxx ~]# cat controller.xml <controller type='scsi' model='virtio-scsi' index='0' /> [root@xxxxxxxx ~]# virsh attach-device guest01 controller.xml error: Failed to attach device from controller.xml error: XML error: No PCI buses available A similar problem occurs with the detach of a controller: [root@xxxxxxxx ~]# virsh detach-device guest01 controller.xml error: Failed to detach device from controller.xml error: operation failed: controller scsi:0 not found The qemuDomainXXtachPciControllerDevice routines made assumptions that any caller had a PCI bus. These routines now selectively calls PCI functions where necessary, and assigns the device information type to one appropriate for the bus in use. Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com> --- src/qemu/qemu_hotplug.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index bc0f57a..70a1b3d 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -365,9 +365,23 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, return -1; } + if (!controller->info.type) { + if (STREQLEN(vm->def->os.machine, "s390-ccw", 8) && + virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) + controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW; + else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) + controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390; + } + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) { - if (qemuDomainPCIAddressEnsureAddr(priv->pciaddrs, &controller->info) < 0) - goto cleanup; + if (!controller->info.type || + controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + if (qemuDomainPCIAddressEnsureAddr(priv->pciaddrs, &controller->info) < 0) + goto cleanup; + } else if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { + if (qemuDomainCCWAddressAssign(&controller->info, priv->ccwaddrs, true) < 0) + goto cleanup; + } releaseaddr = true; if (qemuAssignDeviceControllerAlias(controller) < 0) goto cleanup; @@ -399,7 +413,8 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, qemuDomainObjExitMonitor(driver, vm); if (ret == 0) { - controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; + if (!controller->info.type) + controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; virDomainControllerInsertPreAlloced(vm->def, controller); } @@ -3024,18 +3039,20 @@ int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver, detach = vm->def->controllers[idx]; - if (!virDomainDeviceAddressIsValid(&detach->info, - VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("device cannot be detached without a PCI address")); - goto cleanup; - } + if (detach->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + if (!virDomainDeviceAddressIsValid(&detach->info, + VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("device cannot be detached without a PCI address")); + goto cleanup; + } - if (qemuIsMultiFunctionDevice(vm->def, &detach->info)) { - virReportError(VIR_ERR_OPERATION_FAILED, - _("cannot hot unplug multifunction PCI device: %s"), - dev->data.disk->dst); - goto cleanup; + if (qemuIsMultiFunctionDevice(vm->def, &detach->info)) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("cannot hot unplug multifunction PCI device: %s"), + dev->data.disk->dst); + goto cleanup; + } } if (qemuDomainControllerIsBusy(vm, detach)) { -- 1.7.9.5

On 10/08/2013 02:45 PM, Eric Farman wrote:
For systems without a PCI bus, attaching a SCSI controller fails:
[root@xxxxxxxx ~]# cat controller.xml <controller type='scsi' model='virtio-scsi' index='0' /> [root@xxxxxxxx ~]# virsh attach-device guest01 controller.xml error: Failed to attach device from controller.xml error: XML error: No PCI buses available
A similar problem occurs with the detach of a controller:
[root@xxxxxxxx ~]# virsh detach-device guest01 controller.xml error: Failed to detach device from controller.xml error: operation failed: controller scsi:0 not found
The qemuDomainXXtachPciControllerDevice routines made assumptions that any caller had a PCI bus. These routines now selectively calls PCI functions where necessary, and assigns the device information type to one appropriate for the bus in use.
Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com> --- src/qemu/qemu_hotplug.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index bc0f57a..70a1b3d 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -365,9 +365,23 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, return -1; }
+ if (!controller->info.type) { + if (STREQLEN(vm->def->os.machine, "s390-ccw", 8) &&
STRPREFIX(vm->def->os.machine, "s390-ccw") should do the same
+ virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) + controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW; + else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) + controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390; + } + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) { - if (qemuDomainPCIAddressEnsureAddr(priv->pciaddrs, &controller->info) < 0) - goto cleanup; + if (!controller->info.type ||
I'd prefer a comparison against VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE instead.
+ controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + if (qemuDomainPCIAddressEnsureAddr(priv->pciaddrs, &controller->info) < 0) + goto cleanup; + } else if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { + if (qemuDomainCCWAddressAssign(&controller->info, priv->ccwaddrs, true) < 0) + goto cleanup; + } releaseaddr = true; if (qemuAssignDeviceControllerAlias(controller) < 0) goto cleanup; @@ -399,7 +413,8 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, qemuDomainObjExitMonitor(driver, vm);
if (ret == 0) { - controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; + if (!controller->info.type)
Here too.
+ controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; virDomainControllerInsertPreAlloced(vm->def, controller); }
@@ -3024,18 +3039,20 @@ int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver,
detach = vm->def->controllers[idx];
- if (!virDomainDeviceAddressIsValid(&detach->info, - VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("device cannot be detached without a PCI address")); - goto cleanup; - } + if (detach->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + if (!virDomainDeviceAddressIsValid(&detach->info, + VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("device cannot be detached without a PCI address")); + goto cleanup; + }
Shouldn't we check if there is either a VIRTIO_S390, VIRTIO_CCW or a PCI address?
- if (qemuIsMultiFunctionDevice(vm->def, &detach->info)) { - virReportError(VIR_ERR_OPERATION_FAILED, - _("cannot hot unplug multifunction PCI device: %s"), - dev->data.disk->dst); - goto cleanup; + if (qemuIsMultiFunctionDevice(vm->def, &detach->info)) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("cannot hot unplug multifunction PCI device: %s"), + dev->data.disk->dst); + goto cleanup; + } }
if (qemuDomainControllerIsBusy(vm, detach)) {
Jan

On 11/12/2013 02:30 AM, Ján Tomko wrote:
On 10/08/2013 02:45 PM, Eric Farman wrote:
For systems without a PCI bus, attaching a SCSI controller fails:
[root@xxxxxxxx ~]# cat controller.xml <controller type='scsi' model='virtio-scsi' index='0' /> [root@xxxxxxxx ~]# virsh attach-device guest01 controller.xml error: Failed to attach device from controller.xml error: XML error: No PCI buses available
A similar problem occurs with the detach of a controller:
[root@xxxxxxxx ~]# virsh detach-device guest01 controller.xml error: Failed to detach device from controller.xml error: operation failed: controller scsi:0 not found
The qemuDomainXXtachPciControllerDevice routines made assumptions that any caller had a PCI bus. These routines now selectively calls PCI functions where necessary, and assigns the device information type to one appropriate for the bus in use.
Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com> --- src/qemu/qemu_hotplug.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index bc0f57a..70a1b3d 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -365,9 +365,23 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, return -1; }
+ if (!controller->info.type) { + if (STREQLEN(vm->def->os.machine, "s390-ccw", 8) && STRPREFIX(vm->def->os.machine, "s390-ccw") should do the same Ok
+ virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) + controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW; + else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) + controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390; + } + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) { - if (qemuDomainPCIAddressEnsureAddr(priv->pciaddrs, &controller->info) < 0) - goto cleanup; + if (!controller->info.type || I'd prefer a comparison against VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE instead. Ok
+ controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + if (qemuDomainPCIAddressEnsureAddr(priv->pciaddrs, &controller->info) < 0) + goto cleanup; + } else if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { + if (qemuDomainCCWAddressAssign(&controller->info, priv->ccwaddrs, true) < 0) + goto cleanup; + } releaseaddr = true; if (qemuAssignDeviceControllerAlias(controller) < 0) goto cleanup; @@ -399,7 +413,8 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, qemuDomainObjExitMonitor(driver, vm);
if (ret == 0) { - controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; + if (!controller->info.type) Here too.
+ controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; virDomainControllerInsertPreAlloced(vm->def, controller); }
@@ -3024,18 +3039,20 @@ int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver,
detach = vm->def->controllers[idx];
- if (!virDomainDeviceAddressIsValid(&detach->info, - VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("device cannot be detached without a PCI address")); - goto cleanup; - } + if (detach->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + if (!virDomainDeviceAddressIsValid(&detach->info, + VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("device cannot be detached without a PCI address")); + goto cleanup; + } Shouldn't we check if there is either a VIRTIO_S390, VIRTIO_CCW or a PCI address? Ah, yes. This is true for VIRTIO_CCW, but not VIRTIO_S390. We don't create one on the attach side, and besides the virDomainDeviceAddressIsValid routine always returns true for that type.
I'll send a v2 patch shortly.
- if (qemuIsMultiFunctionDevice(vm->def, &detach->info)) { - virReportError(VIR_ERR_OPERATION_FAILED, - _("cannot hot unplug multifunction PCI device: %s"), - dev->data.disk->dst); - goto cleanup; + if (qemuIsMultiFunctionDevice(vm->def, &detach->info)) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("cannot hot unplug multifunction PCI device: %s"), + dev->data.disk->dst); + goto cleanup; + } }
if (qemuDomainControllerIsBusy(vm, detach)) {
Jan
Eric

Resending the series. Fixed the indentation change that I missed in patch one, but otherwise patch one and three are unchanged. Changes in patch two: - Check for VIR_..._TYPE_NONE on controller->info.type - Check device address for TYPE_CCW controllers during detach Eric Farman (3): qemu: Rename controller hotplug functions to not be PCI-specific qemu: Separate calls based on controller bus type qemu: Auto-generate controller for hotplugged hostdev src/qemu/qemu_driver.c | 4 +-- src/qemu/qemu_hotplug.c | 73 +++++++++++++++++++++++++++++++++-------------- src/qemu/qemu_hotplug.h | 12 ++++---- 3 files changed, 59 insertions(+), 30 deletions(-) -- 1.7.9.5

For attach/detach of controller devices, we rename the functions to remove 'PCI' from their title. The actual separation of PCI-specific operations will be handled in the next patch. Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com> --- src/qemu/qemu_driver.c | 4 ++-- src/qemu/qemu_hotplug.c | 16 ++++++++-------- src/qemu/qemu_hotplug.h | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ef1359c..bb503cf 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6325,7 +6325,7 @@ qemuDomainAttachDeviceControllerLive(virQEMUDriverPtr driver, switch (cont->type) { case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: - ret = qemuDomainAttachPciControllerDevice(driver, vm, cont); + ret = qemuDomainAttachControllerDevice(driver, vm, cont); break; default: virReportError(VIR_ERR_OPERATION_UNSUPPORTED, @@ -6417,7 +6417,7 @@ qemuDomainDetachDeviceControllerLive(virQEMUDriverPtr driver, switch (cont->type) { case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: - ret = qemuDomainDetachPciControllerDevice(driver, vm, dev); + ret = qemuDomainDetachControllerDevice(driver, vm, dev); break; default : virReportError(VIR_ERR_OPERATION_UNSUPPORTED, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 6eb483c..29c6aea 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -348,9 +348,9 @@ error: } -int qemuDomainAttachPciControllerDevice(virQEMUDriverPtr driver, - virDomainObjPtr vm, - virDomainControllerDefPtr controller) +int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainControllerDefPtr controller) { int ret = -1; const char* type = virDomainControllerTypeToString(controller->type); @@ -438,8 +438,8 @@ qemuDomainFindOrCreateSCSIDiskController(virQEMUDriverPtr driver, cont->model = -1; VIR_INFO("No SCSI controller present, hotplugging one"); - if (qemuDomainAttachPciControllerDevice(driver, - vm, cont) < 0) { + if (qemuDomainAttachControllerDevice(driver, + vm, cont) < 0) { VIR_FREE(cont); return NULL; } @@ -3011,9 +3011,9 @@ static bool qemuDomainControllerIsBusy(virDomainObjPtr vm, } } -int qemuDomainDetachPciControllerDevice(virQEMUDriverPtr driver, - virDomainObjPtr vm, - virDomainDeviceDefPtr dev) +int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainDeviceDefPtr dev) { int idx, ret = -1; virDomainControllerDefPtr detach = NULL; diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index 355d809..75789d6 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -36,9 +36,9 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver, int qemuDomainCheckEjectableMedia(virQEMUDriverPtr driver, virDomainObjPtr vm, enum qemuDomainAsyncJob asyncJob); -int qemuDomainAttachPciControllerDevice(virQEMUDriverPtr driver, - virDomainObjPtr vm, - virDomainControllerDefPtr controller); +int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainControllerDefPtr controller); int qemuDomainAttachDeviceDiskLive(virConnectPtr conn, virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -78,9 +78,9 @@ int qemuDomainChangeNetLinkState(virQEMUDriverPtr driver, int qemuDomainDetachDeviceDiskLive(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev); -int qemuDomainDetachPciControllerDevice(virQEMUDriverPtr driver, - virDomainObjPtr vm, - virDomainDeviceDefPtr dev); +int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainDeviceDefPtr dev); int qemuDomainDetachNetDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev); -- 1.7.9.5

For systems without a PCI bus, attaching a SCSI controller fails: [root@xxxxxxxx ~]# cat controller.xml <controller type='scsi' model='virtio-scsi' index='0' /> [root@xxxxxxxx ~]# virsh attach-device guest01 controller.xml error: Failed to attach device from controller.xml error: XML error: No PCI buses available A similar problem occurs with the detach of a controller: [root@xxxxxxxx ~]# virsh detach-device guest01 controller.xml error: Failed to detach device from controller.xml error: operation failed: controller scsi:0 not found The qemuDomainXXtachPciControllerDevice routines made assumptions that any caller had a PCI bus. These routines now selectively calls PCI functions where necessary, and assigns the device information type to one appropriate for the bus in use. Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com> --- src/qemu/qemu_hotplug.c | 52 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 29c6aea..f18e233 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -365,9 +365,23 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, return -1; } + if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { + if (STRPREFIX(vm->def->os.machine, "s390-ccw") && + virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) + controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW; + else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) + controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390; + } + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) { - if (qemuDomainPCIAddressEnsureAddr(priv->pciaddrs, &controller->info) < 0) - goto cleanup; + if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE || + controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + if (qemuDomainPCIAddressEnsureAddr(priv->pciaddrs, &controller->info) < 0) + goto cleanup; + } else if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { + if (qemuDomainCCWAddressAssign(&controller->info, priv->ccwaddrs, true) < 0) + goto cleanup; + } releaseaddr = true; if (qemuAssignDeviceControllerAlias(controller) < 0) goto cleanup; @@ -399,7 +413,8 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, qemuDomainObjExitMonitor(driver, vm); if (ret == 0) { - controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; + if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) + controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; virDomainControllerInsertPreAlloced(vm->def, controller); } @@ -3031,18 +3046,27 @@ int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver, detach = vm->def->controllers[idx]; - if (!virDomainDeviceAddressIsValid(&detach->info, - VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("device cannot be detached without a PCI address")); - goto cleanup; - } + if (detach->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + if (!virDomainDeviceAddressIsValid(&detach->info, + VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("device cannot be detached without a PCI address")); + goto cleanup; + } - if (qemuIsMultiFunctionDevice(vm->def, &detach->info)) { - virReportError(VIR_ERR_OPERATION_FAILED, - _("cannot hot unplug multifunction PCI device: %s"), - dev->data.disk->dst); - goto cleanup; + if (qemuIsMultiFunctionDevice(vm->def, &detach->info)) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("cannot hot unplug multifunction PCI device: %s"), + dev->data.disk->dst); + goto cleanup; + } + } else if (detach->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { + if (!virDomainDeviceAddressIsValid(&detach->info, + VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("device cannot be detached without a CCW address")); + goto cleanup; + } } if (qemuDomainControllerIsBusy(vm, detach)) { -- 1.7.9.5

On 11/12/2013 05:59 PM, Eric Farman wrote:
For systems without a PCI bus, attaching a SCSI controller fails:
[root@xxxxxxxx ~]# cat controller.xml <controller type='scsi' model='virtio-scsi' index='0' /> [root@xxxxxxxx ~]# virsh attach-device guest01 controller.xml error: Failed to attach device from controller.xml error: XML error: No PCI buses available
A similar problem occurs with the detach of a controller:
[root@xxxxxxxx ~]# virsh detach-device guest01 controller.xml error: Failed to detach device from controller.xml error: operation failed: controller scsi:0 not found
The qemuDomainXXtachPciControllerDevice routines made assumptions that any caller had a PCI bus. These routines now selectively calls PCI functions where necessary, and assigns the device information type to one appropriate for the bus in use.
Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com> --- src/qemu/qemu_hotplug.c | 52 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 14 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 29c6aea..f18e233 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -365,9 +365,23 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, return -1; }
+ if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { + if (STRPREFIX(vm->def->os.machine, "s390-ccw") && + virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) + controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW; + else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) + controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390; + } +
These would be better inside the if below (if QEMU_CAPS_DEVICE is not set, we don't probe for the VIRTIO_CCW and VIRTIO_S390 caps anyway).
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) { - if (qemuDomainPCIAddressEnsureAddr(priv->pciaddrs, &controller->info) < 0) - goto cleanup; + if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE || + controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + if (qemuDomainPCIAddressEnsureAddr(priv->pciaddrs, &controller->info) < 0) + goto cleanup; + } else if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { + if (qemuDomainCCWAddressAssign(&controller->info, priv->ccwaddrs, true) < 0) + goto cleanup; + }
releaseaddr = true; if (qemuAssignDeviceControllerAlias(controller) < 0) goto cleanup;
@@ -3031,18 +3046,27 @@ int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver,
detach = vm->def->controllers[idx];
- if (!virDomainDeviceAddressIsValid(&detach->info, - VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("device cannot be detached without a PCI address")); - goto cleanup; - } + if (detach->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + if (!virDomainDeviceAddressIsValid(&detach->info, + VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("device cannot be detached without a PCI address")); + goto cleanup; + }
- if (qemuIsMultiFunctionDevice(vm->def, &detach->info)) { - virReportError(VIR_ERR_OPERATION_FAILED, - _("cannot hot unplug multifunction PCI device: %s"), - dev->data.disk->dst); - goto cleanup; + if (qemuIsMultiFunctionDevice(vm->def, &detach->info)) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("cannot hot unplug multifunction PCI device: %s"), + dev->data.disk->dst); + goto cleanup; + } + } else if (detach->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { + if (!virDomainDeviceAddressIsValid(&detach->info, + VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("device cannot be detached without a CCW address")); + goto cleanup; + } }
if (qemuDomainControllerIsBusy(vm, detach)) {
This doesn't catch the case of ADDRESS_TYPE_NONE. How about: if (detach->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && detach->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW && detach->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) { virReportError(VIR_ERR_OPERATION_FAILED, _("device with '%s' address cannot be detached"), virDomainDeviceAddressTypeToString(detach->info.type)); goto cleanup; } if (!virDomainDeviceAddressIsValid(&detach->info, detach->info.type)) { virReportError(VIR_ERR_OPERATION_FAILED, _("device with invalid '%s' address cannot be detached"), virDomainDeviceAddressTypeToString(detach->info.type)); goto cleanup; } if (detach->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && qemuIsMultiFunctionDevice(vm->def, &detach->info)) { virReportError(VIR_ERR_OPERATION_FAILED, _("cannot hot unplug multifunction PCI device: %s"), dev->data.disk->dst); goto cleanup; } Jan

On 11/20/2013 04:16 AM, Ján Tomko wrote:
On 11/12/2013 05:59 PM, Eric Farman wrote:
For systems without a PCI bus, attaching a SCSI controller fails:
[root@xxxxxxxx ~]# cat controller.xml <controller type='scsi' model='virtio-scsi' index='0' /> [root@xxxxxxxx ~]# virsh attach-device guest01 controller.xml error: Failed to attach device from controller.xml error: XML error: No PCI buses available
A similar problem occurs with the detach of a controller:
[root@xxxxxxxx ~]# virsh detach-device guest01 controller.xml error: Failed to detach device from controller.xml error: operation failed: controller scsi:0 not found
The qemuDomainXXtachPciControllerDevice routines made assumptions that any caller had a PCI bus. These routines now selectively calls PCI functions where necessary, and assigns the device information type to one appropriate for the bus in use.
Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com> --- src/qemu/qemu_hotplug.c | 52 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 14 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 29c6aea..f18e233 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -365,9 +365,23 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, return -1; }
+ if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { + if (STRPREFIX(vm->def->os.machine, "s390-ccw") && + virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) + controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW; + else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) + controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390; + } + These would be better inside the if below (if QEMU_CAPS_DEVICE is not set, we don't probe for the VIRTIO_CCW and VIRTIO_S390 caps anyway).
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) { - if (qemuDomainPCIAddressEnsureAddr(priv->pciaddrs, &controller->info) < 0) - goto cleanup; + if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE || + controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + if (qemuDomainPCIAddressEnsureAddr(priv->pciaddrs, &controller->info) < 0) + goto cleanup; + } else if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { + if (qemuDomainCCWAddressAssign(&controller->info, priv->ccwaddrs, true) < 0) + goto cleanup; + }
releaseaddr = true; if (qemuAssignDeviceControllerAlias(controller) < 0) goto cleanup; @@ -3031,18 +3046,27 @@ int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver,
detach = vm->def->controllers[idx];
- if (!virDomainDeviceAddressIsValid(&detach->info, - VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("device cannot be detached without a PCI address")); - goto cleanup; - } + if (detach->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + if (!virDomainDeviceAddressIsValid(&detach->info, + VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("device cannot be detached without a PCI address")); + goto cleanup; + }
- if (qemuIsMultiFunctionDevice(vm->def, &detach->info)) { - virReportError(VIR_ERR_OPERATION_FAILED, - _("cannot hot unplug multifunction PCI device: %s"), - dev->data.disk->dst); - goto cleanup; + if (qemuIsMultiFunctionDevice(vm->def, &detach->info)) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("cannot hot unplug multifunction PCI device: %s"), + dev->data.disk->dst); + goto cleanup; + } + } else if (detach->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { + if (!virDomainDeviceAddressIsValid(&detach->info, + VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("device cannot be detached without a CCW address")); + goto cleanup; + } }
if (qemuDomainControllerIsBusy(vm, detach)) {
This doesn't catch the case of ADDRESS_TYPE_NONE. Ah, great point. I'll make these changes, and send a v3 of the series to the list later today. How about:
if (detach->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && detach->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW && detach->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) { virReportError(VIR_ERR_OPERATION_FAILED, _("device with '%s' address cannot be detached"), virDomainDeviceAddressTypeToString(detach->info.type)); goto cleanup; }
if (!virDomainDeviceAddressIsValid(&detach->info, detach->info.type)) { virReportError(VIR_ERR_OPERATION_FAILED, _("device with invalid '%s' address cannot be detached"), virDomainDeviceAddressTypeToString(detach->info.type)); goto cleanup; }
if (detach->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && qemuIsMultiFunctionDevice(vm->def, &detach->info)) { virReportError(VIR_ERR_OPERATION_FAILED, _("cannot hot unplug multifunction PCI device: %s"), dev->data.disk->dst); goto cleanup; }
Jan
Eric

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 <hostdev mode='subsystem' type='scsi'> <source> <adapter name='scsi_host0'/> <address bus='0' target='3' unit='1088438288'/> </source> </hostdev> [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 <farman@linux.vnet.ibm.com> --- src/qemu/qemu_hotplug.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index f18e233..2b62ef1 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1491,6 +1491,7 @@ qemuDomainAttachHostScsiDevice(virQEMUDriverPtr driver, { int ret = -1; qemuDomainObjPrivatePtr priv = vm->privateData; + virDomainControllerDefPtr cont = NULL; char *devstr = NULL; char *drvstr = NULL; @@ -1502,6 +1503,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, -- 1.7.9.5

On 11/12/2013 11:59 AM, Eric Farman wrote:
Resending the series. Fixed the indentation change that I missed in patch one, but otherwise patch one and three are unchanged.
Changes in patch two: - Check for VIR_..._TYPE_NONE on controller->info.type - Check device address for TYPE_CCW controllers during detach
Eric Farman (3): qemu: Rename controller hotplug functions to not be PCI-specific qemu: Separate calls based on controller bus type qemu: Auto-generate controller for hotplugged hostdev
src/qemu/qemu_driver.c | 4 +-- src/qemu/qemu_hotplug.c | 73 +++++++++++++++++++++++++++++++++-------------- src/qemu/qemu_hotplug.h | 12 ++++---- 3 files changed, 59 insertions(+), 30 deletions(-)
Any further comments to these little patches?

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 <hostdev mode='subsystem' type='scsi'> <source> <adapter name='scsi_host0'/> <address bus='0' target='3' unit='1088438288'/> </source> </hostdev> [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 <farman@linux.vnet.ibm.com> --- src/qemu/qemu_hotplug.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 70a1b3d..3af13b8 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1485,6 +1485,7 @@ qemuDomainAttachHostScsiDevice(virQEMUDriverPtr driver, { int ret = -1; qemuDomainObjPrivatePtr priv = vm->privateData; + virDomainControllerDefPtr cont = NULL; char *devstr = NULL; char *drvstr = NULL; @@ -1496,6 +1497,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, -- 1.7.9.5

On 10/08/2013 02:45 PM, Eric Farman wrote:
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 <hostdev mode='subsystem' type='scsi'> <source> <adapter name='scsi_host0'/> <address bus='0' target='3' unit='1088438288'/> </source> </hostdev> [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 <farman@linux.vnet.ibm.com> --- src/qemu/qemu_hotplug.c | 5 +++++ 1 file changed, 5 insertions(+)
ACK Jan

On 10/08/2013 02:45 PM, Eric Farman wrote:
(Resending, as this has perhaps been lost during the release of 1.1.3. I've rebased this patch series onto today's git repository.)
Today, hotplug of a SCSI hostdev relies on the presence of an existing SCSI controller, which can be defined in the initial domain XML. Hotplug of a SCSI controller relies on the presence of a PCI bus, which does not work in all environments.
These patches correct this behavior, in order to allow hotplug (and unplug) work without incident.
Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Eric Farman (3): qemu: Rename controller hotplug functions to not be PCI-specific qemu: Separate calls based on controller bus type qemu: Auto-generate controller for hotplugged hostdev
src/qemu/qemu_driver.c | 4 +-- src/qemu/qemu_hotplug.c | 62 ++++++++++++++++++++++++++++++++--------------- src/qemu/qemu_hotplug.h | 12 ++++----- 3 files changed, 50 insertions(+), 28 deletions(-)
Now that we have 1.1.4 out of the way: ping? -- Mit freundlichen Grüßen/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina Köderitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
participants (4)
-
Eric Farman
-
Eric Farman
-
Ján Tomko
-
Viktor Mihajlovski DE