mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-26 07:36:19 +00:00
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:
parent
1214023887
commit
ec4ad1a5f5
@ -1002,30 +1002,17 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* @oldStateDir:
|
static void
|
||||||
* For upgrade purpose: see virHostdevRestoreNetConfig
|
virHostdevReAttachPCIDevicesImpl(virHostdevManagerPtr mgr,
|
||||||
*/
|
|
||||||
void
|
|
||||||
virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr,
|
|
||||||
const char *drv_name,
|
const char *drv_name,
|
||||||
const char *dom_name,
|
const char *dom_name,
|
||||||
|
virPCIDeviceListPtr pcidevs,
|
||||||
virDomainHostdevDefPtr *hostdevs,
|
virDomainHostdevDefPtr *hostdevs,
|
||||||
int nhostdevs,
|
int nhostdevs,
|
||||||
const char *oldStateDir)
|
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,
|
||||||
|
Loading…
Reference in New Issue
Block a user