Skip to content

RFC Expose available KVM free memory slot count to help avoid aborts

Alex Williamson kvm 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 47 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2kvm: Allow querying free slotskvm-all.c kvm.h+18 -00 replies
2/2device-assignment: Count required kvm memory slotshw/device-assignment.c hw/device-assignment.h+61 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/2] Expose available KVM free memory slot count to help avoid aborts

When doing device assignment, we use cpu_register_physical_memory() to directly map the qemu mmap of the device resource into the address space of the guest. The unadvertised feature of the register physical memory code path on kvm, at least for this type of mapping, is that it needs to allocate an index from a small, fixed array of memory slots. Even better, if it can't get an index, the code aborts deep in the kvm specific bits, preventing the caller from having a chance to recover.

It's really easy to hit this by hot adding too many assigned devices to a guest (pretty easy to hit with too many devices at instantiation time too, but the abort is slightly more bearable there).

I'm assuming it's pretty difficult to make the memory slot array dynamically sized. If that's not the case, please let me know as that would be a much better solution.

I'm not terribly happy with the solution in this series, it doesn't provide any guarantees whether a cpu_register_physical_memory() will succeed, only slightly better educated guesses.

Are there better ideas how we could solve this? Thanks,

Alex

---

Alex Williamson (2):
device-assignment: Count required kvm memory slots
kvm: Allow querying free slots

 hw/device-assignment.c |   59 +++++++++++++++++++++++++++++++++++++++++++++++-
 hw/device-assignment.h |    3 ++
 kvm-all.c              |   16 +++++++++++++
 kvm.h                  |    2 ++
 4 files changed, 79 insertions(+), 1 deletions(-)