Re: [PATCH 2/7] guest_memfd: Introduce an object to manage the guest-memfd with RamDiscardManager

David Hildenbrand
2025-01-20T10:48:46Z

Sorry, I was traveling end of last week. I wrote a mail on the train and
apparently it was swallowed somehow ...

>> Not sure that's the right place. Isn't it the (cc) machine that controls
>> the state?
>
> KVM does, via MemoryRegion->RAMBlock->guest_memfd.

Right; I consider KVM part of the machine.

>
>> It's not really the memory backend, that's just the memory provider.
>
> Sorry but is not "providing memory" the purpose of "memory backend"? :)

Hehe, what I wanted to say is that a memory backend is just something to
create a RAMBlock. There are different ways to create a RAMBlock, even
guest_memfd ones.

guest_memfd is stored per RAMBlock. I assume the state should be stored
per RAMBlock as well, maybe as part of a "guest_memfd state" thing.

Now, the question is, who is the manager?

1) The machine. KVM requests the machine to perform the transition, and
the machine takes care of updating the guest_memfd state and notifying
any listeners.

2) The RAMBlock. Then we need some other Object to trigger that. Maybe
RAMBlock would have to become an object, or we allocate separate objects.

I'm leaning towards 1), but I might be missing something.

--
Cheers,

David / dhildenb