mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
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.
This commit is contained in:
parent
cc875b8372
commit
eaff16113a
@ -9741,7 +9741,9 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuNodeDeviceDettach(virNodeDevicePtr dev)
|
qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
|
||||||
|
const char *driverName,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virQEMUDriverPtr driver = dev->conn->privateData;
|
virQEMUDriverPtr driver = dev->conn->privateData;
|
||||||
virPCIDevicePtr pci;
|
virPCIDevicePtr pci;
|
||||||
@ -9749,6 +9751,8 @@ qemuNodeDeviceDettach(virNodeDevicePtr dev)
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
bool in_inactive_list = false;
|
bool in_inactive_list = false;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
if (qemuNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
|
if (qemuNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -9756,12 +9760,22 @@ qemuNodeDeviceDettach(virNodeDevicePtr dev)
|
|||||||
if (!pci)
|
if (!pci)
|
||||||
return -1;
|
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->activePciHostdevs);
|
||||||
virObjectLock(driver->inactivePciHostdevs);
|
virObjectLock(driver->inactivePciHostdevs);
|
||||||
in_inactive_list = virPCIDeviceListFind(driver->inactivePciHostdevs, pci);
|
in_inactive_list = virPCIDeviceListFind(driver->inactivePciHostdevs, pci);
|
||||||
|
|
||||||
if (virPCIDeviceDetach(pci, driver->activePciHostdevs,
|
if (virPCIDeviceDetach(pci, driver->activePciHostdevs,
|
||||||
driver->inactivePciHostdevs, "pci-stub") < 0)
|
driver->inactivePciHostdevs, NULL) < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -9773,6 +9787,12 @@ out:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuNodeDeviceDettach(virNodeDevicePtr dev)
|
||||||
|
{
|
||||||
|
return qemuNodeDeviceDetachFlags(dev, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuNodeDeviceReAttach(virNodeDevicePtr dev)
|
qemuNodeDeviceReAttach(virNodeDevicePtr dev)
|
||||||
{
|
{
|
||||||
@ -14721,6 +14741,7 @@ static virDriver qemuDriver = {
|
|||||||
.domainMigratePrepare2 = qemuDomainMigratePrepare2, /* 0.5.0 */
|
.domainMigratePrepare2 = qemuDomainMigratePrepare2, /* 0.5.0 */
|
||||||
.domainMigrateFinish2 = qemuDomainMigrateFinish2, /* 0.5.0 */
|
.domainMigrateFinish2 = qemuDomainMigrateFinish2, /* 0.5.0 */
|
||||||
.nodeDeviceDettach = qemuNodeDeviceDettach, /* 0.6.1 */
|
.nodeDeviceDettach = qemuNodeDeviceDettach, /* 0.6.1 */
|
||||||
|
.nodeDeviceDetachFlags = qemuNodeDeviceDetachFlags, /* 1.0.5 */
|
||||||
.nodeDeviceReAttach = qemuNodeDeviceReAttach, /* 0.6.1 */
|
.nodeDeviceReAttach = qemuNodeDeviceReAttach, /* 0.6.1 */
|
||||||
.nodeDeviceReset = qemuNodeDeviceReset, /* 0.6.1 */
|
.nodeDeviceReset = qemuNodeDeviceReset, /* 0.6.1 */
|
||||||
.domainMigratePrepareTunnel = qemuDomainMigratePrepareTunnel, /* 0.7.2 */
|
.domainMigratePrepareTunnel = qemuDomainMigratePrepareTunnel, /* 0.7.2 */
|
||||||
|
Loading…
Reference in New Issue
Block a user