]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hostmem/shm: Allow shm memory backend serve as shared memory for coco-VMs
authorXiaoyao Li <xiaoyao.li@intel.com>
Mon, 21 Jul 2025 06:52:20 +0000 (14:52 +0800)
committerPeter Xu <peterx@redhat.com>
Mon, 3 Nov 2025 21:04:10 +0000 (16:04 -0500)
shm can surely serve as the shared memory for coco-VMs. But currently it
doesn't check the backend->guest_memfd to pass down the RAM_GUEST_MEMFD
flag. It leads to failure when creating coco-VMs (e.g., TDX guest) which
require private mmeory.

Set and pass down RAM_GUEST_MEMFD when backend->guest_memfd is true, to
allow shm memory backend serve as shared memory for coco-VMs.

Cc: Stefano Garzarella <sgarzare@redhat.com>
Cc: qemu-stable <qemu-stable@nongnu.org>
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20250721065220.895606-1-xiaoyao.li@intel.com
Signed-off-by: Peter Xu <peterx@redhat.com>
backends/hostmem-shm.c

index f66211a2ec929782eae1088dff3323ccae950624..806e2670e0393c8304817c11596b967c4bc9e134 100644 (file)
@@ -54,6 +54,7 @@ have_fd:
     /* Let's do the same as memory-backend-ram,share=on would do. */
     ram_flags = RAM_SHARED;
     ram_flags |= backend->reserve ? 0 : RAM_NORESERVE;
+    ram_flags |= backend->guest_memfd ? RAM_GUEST_MEMFD : 0;
 
     return memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend),
                                               backend_name, backend->size,