From: Michal Privoznik Date: Mon, 10 Jun 2019 15:19:01 +0000 (+0200) Subject: virHostdevReAttachPCIDevices: Construct pcidevs list earlier X-Git-Tag: v5.5.0-rc1~135 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2985cfe33fec7b332d6d2cfa432082b63fe7117;p=thirdparty%2Flibvirt.git virHostdevReAttachPCIDevices: Construct pcidevs list earlier There's no need to translate virDomainHostdevDef-s into virPCIDevice-s with locked list of PCI devices. Signed-off-by: Michal Privoznik Reviewed-by: Ján Tomko --- diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index 7b5ccf2daf..91359a310d 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -963,16 +963,16 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr, if (!nhostdevs) return; - virObjectLock(mgr->activePCIHostdevs); - virObjectLock(mgr->inactivePCIHostdevs); - if (!(pcidevs = virHostdevGetPCIHostDeviceList(hostdevs, nhostdevs))) { VIR_ERROR(_("Failed to allocate PCI device list: %s"), virGetLastErrorMessage()); virResetLastError(); - goto cleanup; + return; } + virObjectLock(mgr->activePCIHostdevs); + virObjectLock(mgr->inactivePCIHostdevs); + /* Reattaching devices to the host involves several steps; each * of them is described at length below */ @@ -1088,10 +1088,9 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr, virPCIDeviceGetName(actual)); } - cleanup: - virObjectUnref(pcidevs); virObjectUnlock(mgr->activePCIHostdevs); virObjectUnlock(mgr->inactivePCIHostdevs); + virObjectUnref(pcidevs); } int