提交 eaff1611 编写于 作者: L Laine Stump

qemu: implement virNodeDeviceDetachFlags backend

The differences from virNodeDeviceDettach are very minor:

1) Check that the flags are 0.

2) Set the virPCIDevice's stubDriver according to the driverName that
   is passed in.

3) Call virPCIDeviceDetach with a NULL stubDriver, indicating it
   should get the name of the stub driver from the virPCIDevice
   object.
上级 cc875b83
......@@ -9741,7 +9741,9 @@ out:
}
static int
qemuNodeDeviceDettach(virNodeDevicePtr dev)
qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
const char *driverName,
unsigned int flags)
{
virQEMUDriverPtr driver = dev->conn->privateData;
virPCIDevicePtr pci;
......@@ -9749,6 +9751,8 @@ qemuNodeDeviceDettach(virNodeDevicePtr dev)
int ret = -1;
bool in_inactive_list = false;
virCheckFlags(0, -1);
if (qemuNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
return -1;
......@@ -9756,12 +9760,22 @@ qemuNodeDeviceDettach(virNodeDevicePtr dev)
if (!pci)
return -1;
if (!driverName || STREQ(driverName, "kvm")) {
virPCIDeviceSetStubDriver(pci, "pci-stub");
} else if (STREQ(driverName, "vfio")) {
virPCIDeviceSetStubDriver(pci, "vfio-pci");
} else {
virReportError(VIR_ERR_INVALID_ARG,
_("unknown driver name '%s'"), driverName);
goto out;
}
virObjectLock(driver->activePciHostdevs);
virObjectLock(driver->inactivePciHostdevs);
in_inactive_list = virPCIDeviceListFind(driver->inactivePciHostdevs, pci);
if (virPCIDeviceDetach(pci, driver->activePciHostdevs,
driver->inactivePciHostdevs, "pci-stub") < 0)
driver->inactivePciHostdevs, NULL) < 0)
goto out;
ret = 0;
......@@ -9773,6 +9787,12 @@ out:
return ret;
}
static int
qemuNodeDeviceDettach(virNodeDevicePtr dev)
{
return qemuNodeDeviceDetachFlags(dev, NULL, 0);
}
static int
qemuNodeDeviceReAttach(virNodeDevicePtr dev)
{
......@@ -14721,6 +14741,7 @@ static virDriver qemuDriver = {
.domainMigratePrepare2 = qemuDomainMigratePrepare2, /* 0.5.0 */
.domainMigrateFinish2 = qemuDomainMigrateFinish2, /* 0.5.0 */
.nodeDeviceDettach = qemuNodeDeviceDettach, /* 0.6.1 */
.nodeDeviceDetachFlags = qemuNodeDeviceDetachFlags, /* 1.0.5 */
.nodeDeviceReAttach = qemuNodeDeviceReAttach, /* 0.6.1 */
.nodeDeviceReset = qemuNodeDeviceReset, /* 0.6.1 */
.domainMigratePrepareTunnel = qemuDomainMigratePrepareTunnel, /* 0.7.2 */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册