On Thu, Apr 16, 2026 at 21:51:23 +0530, Akash Kulhalli via Devel wrote:
Add VIR_DOMAIN_VCPU_ASYNC to the vCPU management APIs and introduce VIR_DOMAIN_EVENT_ID_VCPU_REMOVED, carrying the libvirt XML vCPU id.
For live vCPU unplug, async mode returns after successfully submitting the unplug request instead of doing the short wait used by the non-async path. The live XML is left unchanged until completion is confirmed, and the final outcome is reported through domain events: successful completion emits VCPU_REMOVED, while guest-rejected unplug requests continue to emit DEVICE_REMOVAL_FAILED.
This closes the current gap where successful vCPU hot-unplug emits no domain event for virsh event or other libvirt event consumers to observe. Thread the new event through the remote protocol, add --async to virsh setvcpus and virsh setvcpu, and teach virsh event and event-test about vcpu-removed.
Async mode is supported only for live vCPU unplug.
Signed-off-by: Akash Kulhalli <akash.kulhalli@oracle.com> --- 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 +++++++++++++
Before I even start looking at this note that we require patches to be separated to reasonable logical blocks (as individual patches, yet the code must still build cleanly). For this patch you will have to definitely separate at least the addition of the event and corresponding RPC changes. They are definitely a separate block. next patch then adds new flag and the implementation (if it's not too complex) and/or the virsh implementation, depending how you choose. Proper review will follow later.
16 files changed, 373 insertions(+), 22 deletions(-)
[...]
@@ -19220,7 +19237,13 @@ qemuDomainSetVcpu(virDomainPtr dom, } }
- ret = qemuDomainSetVcpuInternal(driver, vm, def, persistentDef, map, !!state); + if (async && (persistentDef || !def)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("asynchronous mode is supported only for live vcpu unplug")); + goto endjob;
When you're doing a combined live+config unplug it imo should also allow to use the async mode.