Re: [PATCH v3 04/70] HostMem: Add mechanism to opt in kvm guest memfd via MachineState

Xiaoyao Li
2023-11-30T07:38:45Z

On 11/20/2023 5:30 PM, David Hildenbrand wrote:
> On 16.11.23 03:53, Xiaoyao Li wrote:
>> On 11/16/2023 2:14 AM, David Hildenbrand wrote:
>>> On 15.11.23 08:14, Xiaoyao Li wrote:
>>>> Add a new member "require_guest_memfd" to memory backends. When it's
>>>> set
>>>> to true, it enables RAM_GUEST_MEMFD in ram_flags, thus private kvm
>>>> guest_memfd will be allocated during RAMBlock allocation.
>>>>
>>>> Memory backend's @require_guest_memfd is wired with
>>>> @require_guest_memfd
>>>> field of MachineState. MachineState::require_guest_memfd is supposed to
>>>> be set by any VMs that requires KVM guest memfd as private memory,
>>>> e.g.,
>>>> TDX VM.
>>>>
>>>> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
>>>
>>> I'm confused, why do we need this if it's going to be the same for all
>>> memory backends right now?
>>>
>>
>> I want to provide a elegant (in my sense) way to configure "the need of
>> guest memfd" instead of checking x86machinestate->vm_type in physmem.c
>>
>
> It's suboptimal right now, but I guess you want to avoid looking up the
> machine e.g., in ram_backend_memory_alloc().
>
> I'd suggest s/require_guest_memfd/guest_memfd/gc in "struct
> HostMemoryBackend".

sure!

> Apart from that LGTM.
>