[PATCH v3 02/14] qemu_process: Deduplicate code in qemuProcessNeedHugepagesPath()

Peter Krempa pkrempa at redhat.com
Mon May 3 11:09:12 UTC 2021


On Fri, Apr 23, 2021 at 15:24:24 +0200, Michal Privoznik wrote:
> The aim of qemuProcessNeedHugepagesPath() is to return whether
> guest needs private path inside HugeTLBFS mounts (deducted from
> domain definition @def) or whether the memory device that user is
> hotplugging in needs the private path (deducted from the @mem
> argument). The actual creation of the path is done in the only
> caller qemuProcessBuildDestroyMemoryPaths().
> 
> The rule for the first case (@def) and the second case (@mem) is
> the same (domain has a DIMM device that has HP requested) and is
> written twice. Move the logic into a function to deduplicate the
> code.
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  src/qemu/qemu_process.c | 29 +++++++++++++++++++++++------
>  1 file changed, 23 insertions(+), 6 deletions(-)
> 
> diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
> index 92c1f0ab74..449e5f1547 100644
> --- a/src/qemu/qemu_process.c
> +++ b/src/qemu/qemu_process.c
> @@ -3872,6 +3872,27 @@ qemuProcessReconnectCheckMemAliasOrderMismatch(virDomainObj *vm)
>  }
>  
>  
> +static bool
> +qemuProcessDomainMemoryDefNeedHugepagesPath(const virDomainMemoryDef *mem,
> +                                            const long system_pagesize)
> +{
> +    switch (mem->model) {
> +    case VIR_DOMAIN_MEMORY_MODEL_DIMM:
> +        return mem->pagesize &&
> +            mem->pagesize != system_pagesize;

Put both terms on a single line.

Reviewed-by: Peter Krempa <pkrempa at redhat.com>




More information about the libvir-list mailing list