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
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;
}
}
- /* 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.
*/
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.
*/
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)