From: Marc-André Lureau <[email protected]> Hi,
This is an attempt to fix the incompatibility of virtio-mem with confidential VMs. The solution implements what was discussed earlier with D. Hildenbrand: https://patchwork.ozlabs.org/project/qemu-devel/patch/[email protected]/#3502238 The first patches are misc cleanups. Then some code refactoring to have split a manager/source. And finally, the manager learns to deal with multiple sources. I haven't done thorough testing. I only launched a SEV guest with a virtio-mem device. It would be nice to have more tests for those scenarios with VFIO/virtio-mem/confvm.. In any case, review & testing needed! (should fix https://issues.redhat.com/browse/RHEL-131968) v3: issues found by Cédric - fix assertion error on shutdown, due to rcu-defer cleanup - fix API doc warnings v2: - drop replay_{populated,discarded} from source, suggested by Peter Xu - add extra manager cleanup - add r-b tags for preliminary patches thanks Marc-André Lureau (15): system/rba: use DIV_ROUND_UP memory: drop RamDiscardListener::double_discard_supported virtio-mem: use warn_report_err_once() system/memory: minor doc fix kvm: replace RamDicardManager by the RamBlockAttribute system/memory: split RamDiscardManager into source and manager system/memory: move RamDiscardManager to separate compilation unit system/memory: constify section arguments system/ram-discard-manager: implement replay via is_populated iteration virtio-mem: remove replay_populated/replay_discarded implementation system/ram-discard-manager: drop replay from source interface system/memory: implement RamDiscardManager multi-source aggregation system/physmem: destroy ram block attributes before RCU-deferred reclaim system/memory: add RamDiscardManager reference counting and cleanup tests: add unit tests for RamDiscardManager multi-source aggregation include/hw/vfio/vfio-container.h | 2 +- include/hw/vfio/vfio-cpr.h | 2 +- include/hw/virtio/virtio-mem.h | 3 - include/system/memory.h | 287 +---- include/system/ram-discard-manager.h | 358 ++++++ include/system/ramblock.h | 3 +- accel/kvm/kvm-all.c | 2 +- hw/vfio/cpr-legacy.c | 4 +- hw/vfio/listener.c | 12 +- hw/virtio/virtio-mem.c | 290 +---- migration/ram.c | 6 +- system/memory.c | 83 +- system/memory_mapping.c | 4 +- system/physmem.c | 2 +- system/ram-block-attributes.c | 279 +---- system/ram-discard-manager.c | 612 +++++++++ tests/unit/test-ram-discard-manager-stubs.c | 48 + tests/unit/test-ram-discard-manager.c | 1234 +++++++++++++++++++ system/meson.build | 1 + tests/unit/meson.build | 8 +- 20 files changed, 2361 insertions(+), 879 deletions(-) create mode 100644 include/system/ram-discard-manager.h create mode 100644 system/ram-discard-manager.c create mode 100644 tests/unit/test-ram-discard-manager-stubs.c create mode 100644 tests/unit/test-ram-discard-manager.c -- 2.53.0
