On Mon, Aug 17, 2009 at 03:10:17PM +0100, Mark McLoughlin wrote: > 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() > --- > src/qemu_driver.c | 22 +++++++++++++--------- > 1 files changed, 13 insertions(+), 9 deletions(-) > > diff --git a/src/qemu_driver.c b/src/qemu_driver.c > index 06bbf2a..187497f 100644 > --- a/src/qemu_driver.c > +++ b/src/qemu_driver.c > @@ -5780,6 +5780,7 @@ static int qemudDomainDetachHostPciDevice(virConnectPtr conn, > virDomainHostdevDefPtr detach; > char *cmd, *reply; > int i, ret; > + pciDevice *pci; > > for (i = 0 ; i < vm->def->nhostdevs ; i++) { > unsigned domain = vm->def->hostdevs[i]->source.subsys.u.pci.domain; > @@ -5848,16 +5849,19 @@ static int qemudDomainDetachHostPciDevice(virConnectPtr conn, > > ret = 0; > > - if (detach->managed) { > - pciDevice *pci = pciGetDevice(conn, > - detach->source.subsys.u.pci.domain, > - detach->source.subsys.u.pci.bus, > - detach->source.subsys.u.pci.slot, > - detach->source.subsys.u.pci.function); > - if (!pci || pciReAttachDevice(conn, pci) < 0) > + pci = pciGetDevice(conn, > + detach->source.subsys.u.pci.domain, > + detach->source.subsys.u.pci.bus, > + detach->source.subsys.u.pci.slot, > + detach->source.subsys.u.pci.function); > + if (!pci) > + ret = -1; > + else { > + if (pciResetDevice(conn, pci) < 0) > + ret = -1; > + if (detach->managed && pciReAttachDevice(conn, pci) < 0) > ret = -1; > - if (pci) > - pciFreeDevice(conn, pci); > + pciFreeDevice(conn, pci); > } > > if (i != --vm->def->nhostdevs) ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list