Skip to content

KVM: API to block and resume all running vcpus in a vm

Emanuele Giuseppe Esposito kvm linux-doc lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 17 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4linux-headers/linux/kvm.h: introduce kvm_userspace_memory_region_list ioctlinclude/uapi/linux/kvm.h+3 -00 replies
2/4KVM: introduce kvm_clear_all_cpus_requestDocumentation/virt/kvm/vcpu-requests.rst virt/kvm/kvm_main.c+13 -00 replies
3/4KVM: introduce memory transaction semaphorevirt/kvm/kvm_main.c+14 -03 replies
4/4KVM: use signals to abort enter_guest/blocking and retryarch/x86/include/asm/kvm_host.h arch/x86/kvm/x86.c virt/kvm/kvm_main.c+31 -04 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 0/4] KVM: API to block and resume all running vcpus in a vm

This new API allows the userspace to stop all running vcpus using KVM_KICK_ALL_RUNNING_VCPUS ioctl, and resume them with KVM_RESUME_ALL_KICKED_VCPUS.
A "running" vcpu is a vcpu that is executing the KVM_RUN ioctl.

This serie is especially helpful to userspace hypervisors like QEMU when they need to perform operations on memslots without the risk of having a vcpu reading them in the meanwhile. With "memslots operations" we mean grow, shrink, merge and split memslots, which are not "atomic" because there is a time window between the DELETE memslot operation and the CREATE one. Currently, each memslot operation is performed with one or more ioctls.
For example, merging two memslots into one would imply:
DELETE(m1)
DELETE(m2)
CREATE(m1+m2)

And a vcpu could attempt to read m2 right after it is deleted, but before the new one is created.

Therefore the simplest solution is to pause all vcpus in the kvm side, so that:
- userspace just needs to call the new API before making memslots changes, keeping modifications to the minimum
- dirty page updates are also performed when vcpus are blocked, so there is no time window between the dirty page ioctl and memslots modifications, since vcpus are all stopped.
- no need to modify the existing memslots API

Emanuele Giuseppe Esposito (4):
linux-headers/linux/kvm.h: introduce kvm_userspace_memory_region_list
ioctl
KVM: introduce kvm_clear_all_cpus_request
KVM: introduce memory transaction semaphore
KVM: use signals to abort enter_guest/blocking and retry

 Documentation/virt/kvm/vcpu-requests.rst |  3 ++
 arch/x86/include/asm/kvm_host.h          |  2 ++
 arch/x86/kvm/x86.c                       |  8 +++++
 include/uapi/linux/kvm.h                 |  3 ++
 virt/kvm/kvm_main.c                      | 45 ++++++++++++++++++++++++
 5 files changed, 61 insertions(+)
Signature · 1 line
2.31.1