提交 e991b09d 编写于 作者: C Chunyan Liu 提交者: Daniel P. Berrange

add 3 wrapper functions for prepare/reattach/update domain hostdevs

上级 4dd9f103
......@@ -1297,20 +1297,24 @@ virHookInitialize;
virHookPresent;
#util/virhostdev.h
# util/virhostdev.h
virHostdevManagerGetDefault;
virHostdevPCINodeDeviceDetach;
virHostdevPCINodeDeviceReAttach;
virHostdevPCINodeDeviceReset;
virHostdevPrepareDomainDevices;
virHostdevPreparePCIDevices;
virHostdevPrepareSCSIDevices;
virHostdevPrepareUSBDevices;
virHostdevReAttachDomainDevices;
virHostdevReAttachPCIDevices;
virHostdevReAttachSCSIDevices;
virHostdevReAttachUSBDevices;
virHostdevUpdateActivePCIDevices;
virHostdevUpdateActiveSCSIDevices;
virHostdevUpdateActiveUSBDevices;
virHostdevUpdateDomainActiveDevices;
# util/viridentity.h
virIdentityGetAttr;
......
......@@ -1468,3 +1468,106 @@ out:
virObjectUnlock(hostdev_mgr->activePCIHostdevs);
return ret;
}
int
virHostdevPrepareDomainDevices(virHostdevManagerPtr mgr,
const char *driver,
virDomainDefPtr def,
unsigned int flags)
{
if (!def->nhostdevs)
return 0;
if (mgr == NULL)
return -1;
if (flags & VIR_HOSTDEV_SP_PCI) {
if (virHostdevPreparePCIDevices(mgr, driver,
def->name, def->uuid,
def->hostdevs,
def->nhostdevs,
flags) < 0)
return -1;
}
if (flags & VIR_HOSTDEV_SP_USB) {
if (virHostdevPrepareUSBDevices(mgr, driver, def->name,
def->hostdevs, def->nhostdevs,
flags) < 0)
return -1;
}
if (flags & VIR_HOSTDEV_SP_SCSI) {
if (virHostdevPrepareSCSIDevices(mgr, driver, def->name,
def->hostdevs, def->nhostdevs) < 0)
return -1;
}
return 0;
}
/* @oldStateDir
* For upgrade purpose: see virHostdevReAttachPciHostdevs
*/
void
virHostdevReAttachDomainDevices(virHostdevManagerPtr mgr,
const char *driver,
virDomainDefPtr def,
unsigned int flags,
const char *oldStateDir)
{
if (!def->nhostdevs || !mgr)
return;
if (flags & VIR_HOSTDEV_SP_PCI) {
virHostdevReAttachPCIDevices(mgr, driver, def->name,
def->hostdevs, def->nhostdevs,
oldStateDir);
}
if (flags & VIR_HOSTDEV_SP_USB) {
virHostdevReAttachUSBDevices(mgr, driver, def->name,
def->hostdevs, def->nhostdevs);
}
if (flags & VIR_HOSTDEV_SP_SCSI) {
virHostdevReAttachSCSIDevices(mgr, driver, def->name,
def->hostdevs, def->nhostdevs);
}
}
int
virHostdevUpdateDomainActiveDevices(virHostdevManagerPtr mgr,
const char *driver,
virDomainDefPtr def,
unsigned int flags)
{
if (!def->nhostdevs)
return 0;
if (flags & VIR_HOSTDEV_SP_PCI) {
if (virHostdevUpdateActivePCIDevices(mgr,
def->hostdevs,
def->nhostdevs,
driver, def->name) < 0)
return -1;
}
if (flags & VIR_HOSTDEV_SP_USB) {
if (virHostdevUpdateActiveUSBDevices(mgr,
def->hostdevs,
def->nhostdevs,
driver, def->name) < 0)
return -1;
}
if (flags & VIR_HOSTDEV_SP_SCSI) {
if (virHostdevUpdateActiveSCSIDevices(mgr,
def->hostdevs,
def->nhostdevs,
driver, def->name) < 0)
return -1;
}
return 0;
}
......@@ -35,6 +35,10 @@
typedef enum {
VIR_HOSTDEV_STRICT_ACS_CHECK = (1 << 0), /* strict acs check */
VIR_HOSTDEV_COLD_BOOT = (1 << 1), /* cold boot */
VIR_HOSTDEV_SP_PCI = (1 << 8), /* support pci passthrough */
VIR_HOSTDEV_SP_USB = (1 << 9), /* support usb passthrough */
VIR_HOSTDEV_SP_SCSI = (1 << 10), /* support scsi passthrough */
} virHostdevFlag;
......@@ -108,6 +112,22 @@ virHostdevUpdateActiveSCSIDevices(virHostdevManagerPtr mgr,
int nhostdevs,
const char *drv_name,
const char *dom_name);
int
virHostdevUpdateDomainActiveDevices(virHostdevManagerPtr mgr,
const char *driver,
virDomainDefPtr def,
unsigned int flags);
int
virHostdevPrepareDomainDevices(virHostdevManagerPtr mgr,
const char *driver,
virDomainDefPtr def,
unsigned int flags);
void
virHostdevReAttachDomainDevices(virHostdevManagerPtr mgr,
const char *driver,
virDomainDefPtr def,
unsigned int flags,
const char *oldStateDir);
/* functions used by NodeDevDetach/Reattach/Reset */
int virHostdevPCINodeDeviceDetach(virHostdevManagerPtr mgr,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册