[libvirt] [PATCH 4/5] conf: drop hugepage non-anoymous memory requirement

John Ferlan jferlan at redhat.com
Tue Sep 11 13:10:20 UTC 2018



On 09/11/2018 04:37 AM, Marc-André Lureau wrote:
> Hi
> 
> On Tue, Sep 11, 2018 at 2:56 AM, John Ferlan <jferlan at redhat.com> wrote:
>>
>> "non-anonymous"
>>
>> On 09/07/2018 07:32 AM, marcandre.lureau at redhat.com wrote:
>>> From: Marc-André Lureau <marcandre.lureau at redhat.com>
>>>
>>> memfd is able to allocate hugepage anonymous memory.
>>>
>>> Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
>>> ---
>>>  src/conf/domain_conf.c | 7 -------
>>>  1 file changed, 7 deletions(-)
>>>
>>
>>> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>>> index 86199623cc..696cf6ef18 100644
>>> --- a/src/conf/domain_conf.c
>>> +++ b/src/conf/domain_conf.c
>>> @@ -6186,13 +6186,6 @@ virDomainDefMemtuneValidate(const virDomainDef *def)
>>>          return -1;
>>>      }
>>>
>>> -    if (mem->source == VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS) {
>>> -        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
>>> -                       _("hugepages are not allowed with anonymous "
>>> -                         "memory source"));
>>> -        return -1;
>>> -    }
>>> -
>>
>>
>> I believe we need to move this check into qemu specific code that would
>> then be able to test for QEMU_CAPS_OBJECT_MEMORY_MEMFD_HUGETLB
> 
> 
> Would that be what you have in mind?
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 5329899b13..d152466e28 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -3950,10 +3950,19 @@ qemuDomainDefValidateFeatures(const virDomainDef *def,
> 
> 
>  static int
> -qemuDomainDefValidateMemory(const virDomainDef *def)
> +qemuDomainDefValidateMemory(const virDomainDef *def,
> +                            virQEMUCapsPtr qemuCaps)
>  {
>      const long system_page_size = virGetSystemPageSizeKB();
> 
> +    if (def->mem.nhugepages != 0 &&
> +        def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS &&
> +        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_MEMFD_HUGETLB)) {
> +        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                       _("anonymous memory source with hugepages is
> not supported"));
> +        return -1;
> +    }
> +
>      /* We can't guarantee any other mem.access
>       * if no guest NUMA nodes are defined. */
>      if (def->mem.nhugepages != 0 &&
> @@ -4094,7 +4103,7 @@ qemuDomainDefValidate(const virDomainDef *def,
>      if (qemuDomainDefValidateFeatures(def, qemuCaps) < 0)
>          goto cleanup;
> 
> -    if (qemuDomainDefValidateMemory(def) < 0)
> +    if (qemuDomainDefValidateMemory(def, qemuCaps) < 0)
>          goto cleanup;
> 
>      ret = 0;
> 

Yes, more or less... That's the end result, but we have to "get there"
first.  I'll post the "getting there" first patch and then can adjust
your series from there.

Tks

John

>> See qemuDomainDefValidateMemory and go from there. I think this may
>> require 2 patches though... One to move the two checks that I don't
>> think are "mem" specific and the next to add the "filter" that if the
>> capability exists, then we can support; otherwise, still fail.
>>
>> "Theoretically speaking" those are qemu specific checks - the nodemask
>> checks done after this would appear to be more generic.
>>
>> John
>>
>>
>>>      for (i = 0; i < mem->nhugepages; i++) {
>>>          size_t j;
>>>          ssize_t nextBit;
>>>




More information about the libvir-list mailing list