On Thu, Jul 11, 2019 at 17:53:48 +0200, Michal Privoznik wrote:
In near future we will have a list of PCI devices we want to
detach (held in virPCIDeviceListPtr) but we don't have
virDomainHostdevDefPtr. That's okay because
virHostdevPreparePCIDevices() 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(a)redhat.com>
---
src/util/virhostdev.c | 48 ++++++++++++++++++++++++++++---------------
1 file changed, 32 insertions(+), 16 deletions(-)
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index a3647a6cf4..88b0828675 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -613,27 +613,22 @@ virHostdevRestoreNetConfig(virDomainHostdevDefPtr hostdev,
}
}
-int
-virHostdevPreparePCIDevices(virHostdevManagerPtr mgr,
- const char *drv_name,
- const char *dom_name,
- const unsigned char *uuid,
- virDomainHostdevDefPtr *hostdevs,
- int nhostdevs,
- unsigned int flags)
+
+static int
+virHostdevPreparePCIDevicesImpl(virHostdevManagerPtr mgr,
+ const char *drv_name,
+ const char *dom_name,
+ const unsigned char *uuid,
+ virPCIDeviceListPtr pcidevs,
+ virDomainHostdevDefPtr *hostdevs,
+ int nhostdevs,
+ unsigned int flags)
{
- VIR_AUTOUNREF(virPCIDeviceListPtr) pcidevs = NULL;
int last_processed_hostdev_vf = -1;
size_t i;
int ret = -1;
virPCIDeviceAddressPtr devAddr = NULL;
- if (!nhostdevs)
- return 0;
-
- if (!(pcidevs = virHostdevGetPCIHostDeviceList(hostdevs, nhostdevs)))
- return -1;
-
virObjectLock(mgr->activePCIHostdevs);
virObjectLock(mgr->inactivePCIHostdevs);
@@ -906,10 +901,31 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr,
cleanup:
virObjectUnlock(mgr->activePCIHostdevs);
virObjectUnlock(mgr->inactivePCIHostdevs);
-
return ret;
Spurious whitespace change.
}
+
+int
+virHostdevPreparePCIDevices(virHostdevManagerPtr mgr,
+ const char *drv_name,
+ const char *dom_name,
+ const unsigned char *uuid,
+ virDomainHostdevDefPtr *hostdevs,
+ int nhostdevs,
+ unsigned int flags)
+{
+ VIR_AUTOUNREF(virPCIDeviceListPtr) pcidevs = NULL;
+
+ if (!nhostdevs)
+ return 0;
+
+ if (!(pcidevs = virHostdevGetPCIHostDeviceList(hostdevs, nhostdevs)))
+ return -1;
+
+ return virHostdevPreparePCIDevicesImpl(mgr, drv_name, dom_name, uuid,
+ pcidevs, hostdevs, nhostdevs, flags);
+}
+
Two empty lines please, similarly to what you are adding around the new
funcs.
ACK