virHostdevReAttachPCIDevices: Separate out function body

In near future we will have a list of PCI devices we want to
re-attach to the host (held in virPCIDeviceListPtr) but we don't
have virDomainHostdevDefPtr. That's okay because
virHostdevReAttachPCIDevices() works with virPCIDeviceListPtr
mostly anyway. And in very few places where it needs
virDomainHostdevDefPtr are not interesting for our case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Michal Privoznik 2019-06-11 10:24:04 +02:00
parent 1214023887
commit ec4ad1a5f5

View File

@ -1002,30 +1002,17 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr,
} }
/* @oldStateDir: static void
* For upgrade purpose: see virHostdevRestoreNetConfig virHostdevReAttachPCIDevicesImpl(virHostdevManagerPtr mgr,
*/ const char *drv_name,
void const char *dom_name,
virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr, virPCIDeviceListPtr pcidevs,
const char *drv_name, virDomainHostdevDefPtr *hostdevs,
const char *dom_name, int nhostdevs,
virDomainHostdevDefPtr *hostdevs, const char *oldStateDir)
int nhostdevs,
const char *oldStateDir)
{ {
g_autoptr(virPCIDeviceList) pcidevs = NULL;
size_t i; size_t i;
if (!nhostdevs)
return;
if (!(pcidevs = virHostdevGetPCIHostDeviceList(hostdevs, nhostdevs))) {
VIR_ERROR(_("Failed to allocate PCI device list: %s"),
virGetLastErrorMessage());
virResetLastError();
return;
}
virObjectLock(mgr->activePCIHostdevs); virObjectLock(mgr->activePCIHostdevs);
virObjectLock(mgr->inactivePCIHostdevs); virObjectLock(mgr->inactivePCIHostdevs);
@ -1121,6 +1108,35 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr,
virObjectUnlock(mgr->inactivePCIHostdevs); virObjectUnlock(mgr->inactivePCIHostdevs);
} }
/* @oldStateDir:
* For upgrade purpose: see virHostdevRestoreNetConfig
*/
void
virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr,
const char *drv_name,
const char *dom_name,
virDomainHostdevDefPtr *hostdevs,
int nhostdevs,
const char *oldStateDir)
{
g_autoptr(virPCIDeviceList) pcidevs = NULL;
if (!nhostdevs)
return;
if (!(pcidevs = virHostdevGetPCIHostDeviceList(hostdevs, nhostdevs))) {
VIR_ERROR(_("Failed to allocate PCI device list: %s"),
virGetLastErrorMessage());
virResetLastError();
return;
}
virHostdevReAttachPCIDevicesImpl(mgr, drv_name, dom_name, pcidevs,
hostdevs, nhostdevs, oldStateDir);
}
int int
virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr, virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr,
virDomainHostdevDefPtr *hostdevs, virDomainHostdevDefPtr *hostdevs,