mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:10 +00:00
system/physmem: make ram_block_discard_range() handle guest_memfd
Most callers of ram_block_discard_range() want to discard both the shared and guest_memfd backing. Only kvm_convert_memory() intentionally discards a single plane during private/shared conversions. Rename the current implementation to ram_block_discard_shared_range() and make ram_block_discard_range() a composite that also discards guest_memfd when present (rb->guest_memfd >= 0). This ensures callers like virtio-mem, virtio-balloon, hv-balloon, migration.. reclaim private pages on discard. Update kvm_convert_memory() to use the plane-specific ram_block_discard_shared_range() since it only needs to discard the shared backing when converting to private. Likewise, after TDVF image copy, use ram_block_discard_shared_range(). Reviewed-by: Peter Xu <peterx@redhat.com> Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Link: https://lore.kernel.org/r/20260604-rdm5-v5-11-5768e6a0943d@redhat.com Signed-off-by: Peter Xu <peterx@redhat.com>
This commit is contained in:
committed by
Peter Xu
parent
c2237aaf6d
commit
1f3241bcae
@@ -3422,7 +3422,7 @@ int kvm_convert_memory(hwaddr start, hwaddr size, bool to_private)
|
||||
*/
|
||||
goto out_unref;
|
||||
}
|
||||
ret = ram_block_discard_range(rb, offset, size);
|
||||
ret = ram_block_discard_shared_range(rb, offset, size);
|
||||
} else {
|
||||
ret = ram_block_discard_guest_memfd_range(rb, offset, size);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user