On 9/8/26 22:48, Michael Roth wrote:
> When convert-in-place=true, the guest_memfd instance created by
> memory-backend-memfd (when guest-memfd=on option is specified) should
> also be used internally for private memory.
> 
> Do this by dup()'ing the guest_memfd FD provided by the backend so the
> separate cleanup paths for shared vs. private FDs can be managed in the
> same way they are currently for convert-in-place=false (where shared
> memory must come from something other than guest_memfd).
> 
> Introduce a new RAM_GUEST_MEMFD_SHARED flag that can be used to
> limit this dup()'ing to specific backend types like
> memory-backend-memfd.
> 
> Signed-off-by: Michael Roth <[email protected]>
> ---
>  backends/hostmem-memfd.c |  1 +
>  include/system/memory.h  |  3 +++
>  system/physmem.c         | 48 +++++++++++++++++++++++++++++++++++++---
>  3 files changed, 49 insertions(+), 3 deletions(-)
> 
> diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c
> index 6576331441..a9759e682b 100644
> --- a/backends/hostmem-memfd.c
> +++ b/backends/hostmem-memfd.c
> @@ -89,6 +89,7 @@ have_fd:
>      backend->aligned = true;
>      ram_flags = backend->share ? RAM_SHARED : RAM_PRIVATE;
>      ram_flags |= backend->reserve ? 0 : RAM_NORESERVE;
> +    ram_flags |= RAM_GUEST_MEMFD_SHARED;
>      ram_flags |= backend->guest_memfd_private ? RAM_GUEST_MEMFD_PRIVATE : 0;
>      return memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), 
> name,
>                                            backend->size, ram_flags, fd, 0, 
> errp);
> diff --git a/include/system/memory.h b/include/system/memory.h
> index 027ca81bd2..81616bfe39 100644
> --- a/include/system/memory.h
> +++ b/include/system/memory.h
> @@ -274,6 +274,9 @@ typedef struct IOMMUTLBEvent {
>   */
>  #define RAM_PRIVATE (1 << 13)
>  
> +/* RAM can be shared that has kvm guest memfd backend */
> +#define RAM_GUEST_MEMFD_SHARED   (1 << 14)

Trying to understand the semantics, should that be SHAREABLE ?

-- 
Cheers,

David


Reply via email to