From 4dbecff9fbd5b5d1154bc7a41a5d4dd00533b359 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Mon, 17 Aug 2009 15:05:23 +0100 Subject: [PATCH] Reset unmanaged PCI host devices before hotplug Right now we're only resetting managed devices before hotplug, but we should reset them irrespective of whether they are managed. * src/qemu_driver.c: reset all PCI hostdevs before hotplug --- src/qemu_driver.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/qemu_driver.c b/src/qemu_driver.c index a638c10c70..06bbf2a181 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -5310,30 +5310,29 @@ static int qemudDomainAttachHostPciDevice(virConnectPtr conn, virDomainHostdevDefPtr hostdev = dev->data.hostdev; char *cmd, *reply; unsigned domain, bus, slot; + pciDevice *pci; if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0) { virReportOOMError(conn); return -1; } - if (hostdev->managed) { - pciDevice *pci = pciGetDevice(conn, - hostdev->source.subsys.u.pci.domain, - hostdev->source.subsys.u.pci.bus, - hostdev->source.subsys.u.pci.slot, - hostdev->source.subsys.u.pci.function); - if (!dev) - return -1; - - if (pciDettachDevice(conn, pci) < 0 || - pciResetDevice(conn, pci) < 0) { - pciFreeDevice(conn, pci); - return -1; - } + pci = pciGetDevice(conn, + hostdev->source.subsys.u.pci.domain, + hostdev->source.subsys.u.pci.bus, + hostdev->source.subsys.u.pci.slot, + hostdev->source.subsys.u.pci.function); + if (!dev) + return -1; + if ((hostdev->managed && pciDettachDevice(conn, pci) < 0) || + pciResetDevice(conn, pci) < 0) { pciFreeDevice(conn, pci); + return -1; } + pciFreeDevice(conn, pci); + if (virAsprintf(&cmd, "pci_add auto host host=%.2x:%.2x.%.1x", hostdev->source.subsys.u.pci.bus, hostdev->source.subsys.u.pci.slot,