From b2985cfe33fec7b332d6d2cfa432082b63fe7117 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Mon, 10 Jun 2019 17:19:01 +0200 Subject: [PATCH] virHostdevReAttachPCIDevices: Construct pcidevs list earlier MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/util/virhostdev.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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 -- 2.47.2