提交 1d94b3e7 编写于 作者: O Osier Yang

qemu: Manage shared device entry for scsi host device

This adds the shared device entry when starting domain (more
exactly, when preparing host devices), and remove the entry
when destroying domain (when reattaching host devices).
上级 aeda1ff1
......@@ -879,6 +879,19 @@ qemuPrepareHostdevSCSIDevices(virQEMUDriverPtr driver,
virSCSIDeviceListPtr list;
virSCSIDevicePtr tmp;
/* Loop 1: Add the shared scsi host device to shared device
* table.
*/
for (i = 0; i < nhostdevs; i++) {
virDomainDeviceDef dev;
dev.type = VIR_DOMAIN_DEVICE_HOSTDEV;
dev.data.hostdev = hostdevs[i];
if (qemuAddSharedDevice(driver, &dev, name) < 0)
return -1;
}
/* To prevent situation where SCSI device is assigned to two domains
* we need to keep a list of currently assigned SCSI devices.
* This is done in several loops which cannot be joined into one big
......@@ -887,7 +900,7 @@ qemuPrepareHostdevSCSIDevices(virQEMUDriverPtr driver,
if (!(list = virSCSIDeviceListNew()))
goto cleanup;
/* Loop 1: build temporary list */
/* Loop 2: build temporary list */
for (i = 0 ; i < nhostdevs ; i++) {
virDomainHostdevDefPtr hostdev = hostdevs[i];
virSCSIDevicePtr scsi;
......@@ -915,7 +928,7 @@ qemuPrepareHostdevSCSIDevices(virQEMUDriverPtr driver,
}
}
/* Loop 2: Mark devices in temporary list as used by @name
/* Loop 3: Mark devices in temporary list as used by @name
* and add them to driver list. However, if something goes
* wrong, perform rollback.
*/
......@@ -947,7 +960,7 @@ qemuPrepareHostdevSCSIDevices(virQEMUDriverPtr driver,
virObjectUnlock(driver->activeScsiHostdevs);
/* Loop 3: Temporary list was successfully merged with
/* Loop 4: Temporary list was successfully merged with
* driver list, so steal all items to avoid freeing them
* when freeing temporary list.
*/
......@@ -1185,6 +1198,12 @@ qemuDomainReAttachHostScsiDevices(virQEMUDriverPtr driver,
virDomainHostdevDefPtr hostdev = hostdevs[i];
virSCSIDevicePtr scsi, tmp;
const char *used_by = NULL;
virDomainDeviceDef dev;
dev.type = VIR_DOMAIN_DEVICE_HOSTDEV;
dev.data.hostdev = hostdev;
ignore_value(qemuRemoveSharedDevice(driver, &dev, name));
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册