extract general code from qemuDomainReAttachHostScsiDevices

Extract general code from qemuDomainReAttachHostScsiDevices to
virHostdevDomainReAttachHostScsiDevices.
This commit is contained in:
Chunyan Liu 2014-03-06 14:45:23 +08:00 committed by Daniel P. Berrange
parent 2d961cf3ba
commit b473b58344

View File

@ -328,27 +328,19 @@ qemuDomainReAttachHostUsbDevices(virQEMUDriverPtr driver,
name, hostdevs, nhostdevs);
}
void
qemuDomainReAttachHostScsiDevices(virQEMUDriverPtr driver,
const char *name,
virDomainHostdevDefPtr *hostdevs,
int nhostdevs)
static void
virHostdevReAttachScsiHostdevs(virHostdevManagerPtr hostdev_mgr,
const char *name,
virDomainHostdevDefPtr *hostdevs,
int nhostdevs)
{
size_t i;
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
virObjectLock(hostdev_mgr->activeScsiHostdevs);
for (i = 0; i < nhostdevs; i++) {
virDomainHostdevDefPtr hostdev = hostdevs[i];
virSCSIDevicePtr scsi;
virSCSIDevicePtr tmp;
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)
@ -397,6 +389,28 @@ qemuDomainReAttachHostScsiDevices(virQEMUDriverPtr driver,
virObjectUnlock(hostdev_mgr->activeScsiHostdevs);
}
void
qemuDomainReAttachHostScsiDevices(virQEMUDriverPtr driver,
const char *name,
virDomainHostdevDefPtr *hostdevs,
int nhostdevs)
{
size_t i;
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
for (i = 0; i < nhostdevs; i++) {
virDomainHostdevDefPtr hostdev = hostdevs[i];
virDomainDeviceDef dev;
dev.type = VIR_DOMAIN_DEVICE_HOSTDEV;
dev.data.hostdev = hostdev;
ignore_value(qemuRemoveSharedDevice(driver, &dev, name));
}
virHostdevReAttachScsiHostdevs(hostdev_mgr, name, hostdevs, nhostdevs);
}
void
qemuDomainReAttachHostDevices(virQEMUDriverPtr driver,
virDomainDefPtr def)