mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-03 10:25:16 +00:00
Reset PCI host devices after hot-unplug
When we hot-unplug a PCI host device from a guest, we should reset it. Both managed and unmanaged devices should be reset, but only managed devices should be re-attached. * src/qemu_driver.c: reset devices in qemudDomainDetachHostPciDevice()
This commit is contained in:
parent
4dbecff9fb
commit
12edef9a6a
@ -5780,6 +5780,7 @@ static int qemudDomainDetachHostPciDevice(virConnectPtr conn,
|
|||||||
virDomainHostdevDefPtr detach;
|
virDomainHostdevDefPtr detach;
|
||||||
char *cmd, *reply;
|
char *cmd, *reply;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
pciDevice *pci;
|
||||||
|
|
||||||
for (i = 0 ; i < vm->def->nhostdevs ; i++) {
|
for (i = 0 ; i < vm->def->nhostdevs ; i++) {
|
||||||
unsigned domain = vm->def->hostdevs[i]->source.subsys.u.pci.domain;
|
unsigned domain = vm->def->hostdevs[i]->source.subsys.u.pci.domain;
|
||||||
@ -5848,16 +5849,19 @@ static int qemudDomainDetachHostPciDevice(virConnectPtr conn,
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
if (detach->managed) {
|
pci = pciGetDevice(conn,
|
||||||
pciDevice *pci = pciGetDevice(conn,
|
detach->source.subsys.u.pci.domain,
|
||||||
detach->source.subsys.u.pci.domain,
|
detach->source.subsys.u.pci.bus,
|
||||||
detach->source.subsys.u.pci.bus,
|
detach->source.subsys.u.pci.slot,
|
||||||
detach->source.subsys.u.pci.slot,
|
detach->source.subsys.u.pci.function);
|
||||||
detach->source.subsys.u.pci.function);
|
if (!pci)
|
||||||
if (!pci || pciReAttachDevice(conn, pci) < 0)
|
ret = -1;
|
||||||
|
else {
|
||||||
|
if (pciResetDevice(conn, pci) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
if (pci)
|
if (detach->managed && pciReAttachDevice(conn, pci) < 0)
|
||||||
pciFreeDevice(conn, pci);
|
ret = -1;
|
||||||
|
pciFreeDevice(conn, pci);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != --vm->def->nhostdevs)
|
if (i != --vm->def->nhostdevs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user