This series adds asynchronous live vCPU unplug support for QEMU.
It introduces a new flag `VIR_DOMAIN_VCPU_ASYNC` for the vCPU management APIs
and adds a new libvirt event with the ID `VIR_DOMAIN_EVENT_ID_VCPU_REMOVED`
that contains the vCPU ID. When async mode is requested, libvirt returns after
successfully submitting the unplug request, instead of doing a short wait
for the event to arrive (like its non-async counterpart); it reports the final
outcome through domain events: successful completion emits a `vcpu-removed`
event while guest-rejected unplug requests continue to emit
`device-removal-failed`.
This also addresses the current gap where a successful vCPU hot-unplug
does not emit any domain event that `virsh event` (or any listener that
uses the libvirt APIs) can observe. With the new event now in
place, third-party API users can now watch for successful unplug completion
events, instead of only seeing failure notification events.
Async mode is limited to live vCPU unplug only.
The series also threads the new event through the remote protocol and
extends the user-facing tooling around it: both `virsh setvcpus` and
`virsh setvcpu` gain a new `--async` flag, and `virsh event` gains
`vcpu-removed` as an event that it can watch for and track successful
unplug operations.
All existing tests covering these paths have passed. A follow-up commit
adding/enhancing explicit async test coverage is forthcoming.
Related discussion:
[0] https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/thread/2J53UIW4MFGEPANXNXEIFMHZ6X5TO3K4/
---
examples/c/misc/event-test.c | 12 ++++++
include/libvirt/libvirt-domain.h | 23 ++++++++++++
src/conf/domain_event.c | 66 +++++++++++++++++++++++++++++++++
src/conf/domain_event.h | 6 +++
src/libvirt-domain.c | 40 +++++++++++++++++++-
src/libvirt_private.syms | 2 +
src/qemu/qemu_driver.c | 33 ++++++++++++++---
src/qemu/qemu_hotplug.c | 74 ++++++++++++++++++++++++++++++++-----
src/qemu/qemu_hotplug.h | 8 ++--
src/remote/remote_daemon_dispatch.c | 26 +++++++++++++
src/remote/remote_driver.c | 29 +++++++++++++++
src/remote/remote_protocol.x | 14 ++++++-
src/remote_protocol-structs | 6 +++
tests/qemuhotplugtest.c | 6 ++-
tools/virsh-domain-event.c | 16 ++++++++
tools/virsh-domain.c | 34 +++++++++++++++++
16 files changed, 373 insertions(+), 22 deletions(-)