[libvirt] [PATCH v1 01/31] virHostdevPreparePCIDevices: Separate out function body
Peter Krempa
pkrempa at redhat.com
Tue Jul 16 11:57:08 UTC 2019
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 at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190716/44091291/attachment-0001.sig>
More information about the libvir-list
mailing list