From nobody Sat Jun 13 12:17:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1776945950; cv=none; d=zohomail.com; s=zohoarc; b=YIzXg+FL+Ri5/f8yiBSObcjWKk0AHbkiSjL8bNu6lYhGpcsEH9Nvoa8ezEWVG3/mRcqI+0/1kxej3nH2Qvl5ZS1wxQerjKw3mOOmWLWKRsAt15sjRTdoU5i792TzlXl7V8Oz1qyHwean15OxUeyArvXsguGpb+8hugKYGXOtaxw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776945950; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=3XBXDBgEBkfKnVhUD4eqULRsAbEErxf7xhH+Ya0DRxo=; b=QXPdMYJZZU38uPRr8WcgiSyUVWp7MirvrfrRVZUMRDlv0d4f1PIs/S+WllP83E/fePdr+IcA0eTWzIsClFrvI0xIVsSEMCkqbGEBkCuLVbrw2G7NnabbgP5x873JB1nII5fpEgCKMC8kwDS07i0FfU0o3sfn70LjZbPZb9ZP7Ao= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1776945950534944.9143042811316; Thu, 23 Apr 2026 05:05:50 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 568AD4193A; Thu, 23 Apr 2026 08:05:49 -0400 (EDT) Received: from [172.19.199.9] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 601B741AFE; Thu, 23 Apr 2026 07:59:14 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id AF3C7418FA; Thu, 23 Apr 2026 07:58:55 -0400 (EDT) Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 9AEC1417FC for ; Thu, 23 Apr 2026 07:58:53 -0400 (EDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63MMTZB4624184 for ; Thu, 23 Apr 2026 11:58:52 GMT Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4dpenm3bbe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 23 Apr 2026 11:58:52 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.7/8.18.1.7) with ESMTP id 63NBpHJl006473 for ; Thu, 23 Apr 2026 11:58:52 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4dpjjqj0ue-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 23 Apr 2026 11:58:52 +0000 (GMT) Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.1.12) with ESMTP id 63NBwp17029410 for ; Thu, 23 Apr 2026 11:58:51 GMT Received: from akulhall-vm1-ol9.osdevelopmeniad.oraclevcn.com (akulhall-vm1-ol9.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.255.191]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 4dpjjqj0u4-2; Thu, 23 Apr 2026 11:58:51 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=3XBXD BgEBkfKnVhUD4eqULRsAbEErxf7xhH+Ya0DRxo=; b=FfkJW555yzcL5l853hM7L ch+Hw+d0SqkV7vSKAMWneO/N7OyrokfWZGilYzENzSDgAaZpBpKy+aLyp71plj5w s1YIZyzdg3cmGau11IeKqX/xbQlueKcB+woAIeQCwjPgWb/45myVozzGxdnDm9pH EvUtlGowt83PL30uhq2X5jx6L5ibcavHfQtZrIHbAIa9/SbksnM6cvJCnsdNj+i3 oboUwRIM6hmBq9VVdPG5OL7PDkHcYXKSLrfVjJROVYr7RPZNqKt0suNgwlm132iT QglKOBDtDjeJnt4n9bN0mvQOa5SEYC7LDImUDh2uJDFIF9YIzLK2jZt5bb9wDLk/ w== To: devel@lists.libvirt.org Subject: [PATCH v2 1/5] conf,remote: add vcpu-removed domain event Date: Thu, 23 Apr 2026 17:27:25 +0530 Message-ID: <20260423115819.1000720-2-akash.kulhalli@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260423115819.1000720-1-akash.kulhalli@oracle.com> References: <20260423115819.1000720-1-akash.kulhalli@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-23_03,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2604200000 definitions=main-2604230118 X-Authority-Analysis: v=2.4 cv=FNUrAeos c=1 sm=1 tr=0 ts=69ea097c b=1 cx=c_pps a=qoll8+KPOyaMroiJ2sR5sw==:117 a=qoll8+KPOyaMroiJ2sR5sw==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=3I1J8UUJPc9JN9BFgKH3:22 a=yPCof4ZbAAAA:8 a=lP-c2LJKX2x5896Cvb0A:9 cc=ntf awl=host:12292 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDIzMDExOCBTYWx0ZWRfX8uYlitE5/Hrw f/pFvYYWwZM388ePtMtubNxkwbzLnLcJaOvNt22jWHpClnck7TPQEV2Sfd3+zule91TzYZ8aQXF QF5hDsqV2pQnpJ/63GXNq1DD+X2Y/7O+MWFU/7dd95CIbEk8JmY6jHX2S2ud0/0/yyHXtXC5Tcv uiJkI5Jgg89AABhPm0g+8c/8LEYdRlP5MC/t/2yHKI8vbiksTF//yxbbxJ7xSXbUeHi1HDPdIY9 IyKWQxdi1XIR2diyPUOcT8dyV+5oyU7jPvPjGNdb/MjsGeQa3xeDAp6WsWKFqTa+6VcDRNV9hm2 M9WryYYnQmf1vzVzfkrwjhgyXwm1ccHVrFWUr64FZee4rtLiXE3Qp6bvfwDOtNCbm/OD4OhJ3cn YfGyau0LHLiKgyTvgG3DCTN20XCJJ8sDM4QKvJM2bHpy8VhmiRjgsY3o1sDP1hFiwZUvb+1QoXe o7oexbQeA2jngE9jEG1XiyC0oSL+aQQ4swXD4ZeM= X-Proofpoint-GUID: pgQO3jq_FkkQ0m5yi1lPY08GNRVzBKio X-Proofpoint-ORIG-GUID: pgQO3jq_FkkQ0m5yi1lPY08GNRVzBKio Message-ID-Hash: 5NLKXFUICW6BWI7XV5YGB4EDWOVZESWN X-Message-ID-Hash: 5NLKXFUICW6BWI7XV5YGB4EDWOVZESWN X-MailFrom: akash.kulhalli@oracle.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: akash.kulhalli@oracle.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Akash Kulhalli via Devel Reply-To: Akash Kulhalli X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1776945952543158500 Content-Type: text/plain; charset="utf-8" Add a new domain event for completed vCPU removal. Wire the event through the internal event framework and extend the remote protocol so remote clients can receive it. Update virsh and the event-test example accordingly. The event is not emitted anywhere yet. Signed-off-by: Akash Kulhalli Reviewed-by: Peter Krempa --- examples/c/misc/event-test.c | 12 ++++++ include/libvirt/libvirt-domain.h | 22 ++++++++++ src/conf/domain_event.c | 66 +++++++++++++++++++++++++++++ src/conf/domain_event.h | 6 +++ src/libvirt_private.syms | 2 + src/remote/remote_daemon_dispatch.c | 26 ++++++++++++ src/remote/remote_driver.c | 29 +++++++++++++ src/remote/remote_protocol.x | 14 +++++- src/remote_protocol-structs | 6 +++ tools/virsh-domain-event.c | 16 +++++++ 10 files changed, 198 insertions(+), 1 deletion(-) diff --git a/examples/c/misc/event-test.c b/examples/c/misc/event-test.c index 2ce82ca9e088..f9e65c55f064 100644 --- a/examples/c/misc/event-test.c +++ b/examples/c/misc/event-test.c @@ -1039,6 +1039,17 @@ myDomainEventDeviceRemovalFailedCallback(virConnectP= tr conn G_GNUC_UNUSED, return 0; } =20 +static int +myDomainEventVcpuRemovedCallback(virConnectPtr conn G_GNUC_UNUSED, + virDomainPtr dom, + unsigned int vcpuid, + void *opaque G_GNUC_UNUSED) +{ + printf("%s EVENT: Domain %s(%d) vcpu removed: %u\n", + __func__, virDomainGetName(dom), virDomainGetID(dom), vcpuid); + return 0; +} + =20 static const char * metadataTypeToStr(int status) @@ -1183,6 +1194,7 @@ struct domainEventData domainEvents[] =3D { DOMAIN_EVENT(VIR_DOMAIN_EVENT_ID_MEMORY_FAILURE, myDomainEventMemoryFa= ilureCallback), DOMAIN_EVENT(VIR_DOMAIN_EVENT_ID_MEMORY_DEVICE_SIZE_CHANGE, myDomainEv= entMemoryDeviceSizeChangeCallback), DOMAIN_EVENT(VIR_DOMAIN_EVENT_ID_NIC_MAC_CHANGE, myDomainEventNICMACCh= angeCallback), + DOMAIN_EVENT(VIR_DOMAIN_EVENT_ID_VCPU_REMOVED, myDomainEventVcpuRemove= dCallback), }; =20 struct storagePoolEventData { diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 4a8e3114b35d..92d5ecb32d65 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -6965,6 +6965,27 @@ typedef void (*virConnectDomainEventDeviceRemovalFai= ledCallback)(virConnectPtr c const cha= r *devAlias, void *opa= que); =20 +/** + * virConnectDomainEventVcpuRemovedCallback: + * @conn: connection object + * @dom: domain on which the event occurred + * @vcpuid: libvirt XML vCPU id + * @opaque: application specified data + * + * This callback occurs when a vCPU is removed from the domain. + * + * The @vcpuid value matches the ```` value from the doma= in XML. + * + * The callback signature to use when registering for an event of type + * VIR_DOMAIN_EVENT_ID_VCPU_REMOVED with virConnectDomainEventRegisterAny(= ). + * + * Since: 12.3.0 + */ +typedef void (*virConnectDomainEventVcpuRemovedCallback)(virConnectPtr con= n, + virDomainPtr dom, + unsigned int vcpu= id, + void *opaque); + /** * virConnectDomainEventMetadataChangeCallback: * @conn: connection object @@ -7617,6 +7638,7 @@ typedef enum { VIR_DOMAIN_EVENT_ID_MEMORY_FAILURE =3D 25, /* virConnectDomainEventMe= moryFailureCallback (Since: 6.9.0) */ VIR_DOMAIN_EVENT_ID_MEMORY_DEVICE_SIZE_CHANGE =3D 26, /* virConnectDom= ainEventMemoryDeviceSizeChangeCallback (Since: 7.9.0) */ VIR_DOMAIN_EVENT_ID_NIC_MAC_CHANGE =3D 27, /* virConnectDomainEventNIC= MACChangeCallback (Since: 11.2.0) */ + VIR_DOMAIN_EVENT_ID_VCPU_REMOVED =3D 28, /* virConnectDomainEventVcpuR= emovedCallback (Since: 12.3.0) */ =20 # ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_EVENT_ID_LAST diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c index 88087bad4f21..17ad4a0d2c91 100644 --- a/src/conf/domain_event.c +++ b/src/conf/domain_event.c @@ -53,6 +53,7 @@ static virClass *virDomainEventDeviceAddedClass; static virClass *virDomainEventMigrationIterationClass; static virClass *virDomainEventJobCompletedClass; static virClass *virDomainEventDeviceRemovalFailedClass; +static virClass *virDomainEventVcpuRemovedClass; static virClass *virDomainEventMetadataChangeClass; static virClass *virDomainEventBlockThresholdClass; static virClass *virDomainEventMemoryFailureClass; @@ -78,6 +79,7 @@ static void virDomainEventDeviceAddedDispose(void *obj); static void virDomainEventMigrationIterationDispose(void *obj); static void virDomainEventJobCompletedDispose(void *obj); static void virDomainEventDeviceRemovalFailedDispose(void *obj); +static void virDomainEventVcpuRemovedDispose(void *obj); static void virDomainEventMetadataChangeDispose(void *obj); static void virDomainEventBlockThresholdDispose(void *obj); static void virDomainEventMemoryFailureDispose(void *obj); @@ -251,6 +253,13 @@ struct _virDomainEventDeviceRemovalFailed { }; typedef struct _virDomainEventDeviceRemovalFailed virDomainEventDeviceRemo= valFailed; =20 +struct _virDomainEventVcpuRemoved { + virDomainEvent parent; + + unsigned int vcpuid; +}; +typedef struct _virDomainEventVcpuRemoved virDomainEventVcpuRemoved; + struct _virDomainEventMetadataChange { virDomainEvent parent; =20 @@ -337,6 +346,8 @@ virDomainEventsOnceInit(void) return -1; if (!VIR_CLASS_NEW(virDomainEventDeviceRemovalFailed, virDomainEventCl= ass)) return -1; + if (!VIR_CLASS_NEW(virDomainEventVcpuRemoved, virDomainEventClass)) + return -1; if (!VIR_CLASS_NEW(virDomainEventMetadataChange, virDomainEventClass)) return -1; if (!VIR_CLASS_NEW(virDomainEventBlockThreshold, virDomainEventClass)) @@ -484,6 +495,13 @@ virDomainEventDeviceRemovalFailedDispose(void *obj) g_free(event->devAlias); } =20 +static void +virDomainEventVcpuRemovedDispose(void *obj) +{ + virDomainEventVcpuRemoved *event =3D obj; + VIR_DEBUG("obj=3D%p", event); +} + =20 static void virDomainEventPMDispose(void *obj) @@ -1382,6 +1400,43 @@ virDomainEventDeviceRemovalFailedNewFromDom(virDomai= nPtr dom, devAlias); } =20 +static virObjectEvent * +virDomainEventVcpuRemovedNew(int id, + const char *name, + unsigned char *uuid, + unsigned int vcpuid) +{ + virDomainEventVcpuRemoved *ev; + + if (virDomainEventsInitialize() < 0) + return NULL; + + if (!(ev =3D virDomainEventNew(virDomainEventVcpuRemovedClass, + VIR_DOMAIN_EVENT_ID_VCPU_REMOVED, + id, name, uuid))) + return NULL; + + ev->vcpuid =3D vcpuid; + + return (virObjectEvent *)ev; +} + +virObjectEvent * +virDomainEventVcpuRemovedNewFromObj(virDomainObj *obj, + unsigned int vcpuid) +{ + return virDomainEventVcpuRemovedNew(obj->def->id, obj->def->name, + obj->def->uuid, vcpuid); +} + +virObjectEvent * +virDomainEventVcpuRemovedNewFromDom(virDomainPtr dom, + unsigned int vcpuid) +{ + return virDomainEventVcpuRemovedNew(dom->id, dom->name, dom->uuid, + vcpuid); +} + =20 static virObjectEvent * virDomainEventAgentLifecycleNew(int id, @@ -2134,6 +2189,17 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn, goto cleanup; } =20 + case VIR_DOMAIN_EVENT_ID_VCPU_REMOVED: + { + virDomainEventVcpuRemoved *vcpuRemovedEvent; + + vcpuRemovedEvent =3D (virDomainEventVcpuRemoved *)event; + ((virConnectDomainEventVcpuRemovedCallback)cb)(conn, dom, + vcpuRemovedEven= t->vcpuid, + cbopaque); + goto cleanup; + } + case VIR_DOMAIN_EVENT_ID_LAST: break; } diff --git a/src/conf/domain_event.h b/src/conf/domain_event.h index f31cfb9e42ad..1b1b16095a77 100644 --- a/src/conf/domain_event.h +++ b/src/conf/domain_event.h @@ -192,6 +192,12 @@ virDomainEventDeviceRemovalFailedNewFromObj(virDomainO= bj *obj, virObjectEvent * virDomainEventDeviceRemovalFailedNewFromDom(virDomainPtr dom, const char *devAlias); +virObjectEvent * +virDomainEventVcpuRemovedNewFromObj(virDomainObj *obj, + unsigned int vcpuid); +virObjectEvent * +virDomainEventVcpuRemovedNewFromDom(virDomainPtr dom, + unsigned int vcpuid); =20 virObjectEvent * virDomainEventTunableNewFromObj(virDomainObj *obj, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index cf0e71cc6af1..f22b5895db12 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -811,6 +811,8 @@ virDomainEventTrayChangeNewFromDom; virDomainEventTrayChangeNewFromObj; virDomainEventTunableNewFromDom; virDomainEventTunableNewFromObj; +virDomainEventVcpuRemovedNewFromDom; +virDomainEventVcpuRemovedNewFromObj; virDomainEventWatchdogNewFromDom; virDomainEventWatchdogNewFromObj; virDomainQemuMonitorEventNew; diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 7e74ff063f5b..81b0ed00da1a 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -1322,6 +1322,31 @@ remoteRelayDomainEventMemoryDeviceSizeChange(virConn= ectPtr conn, return 0; } =20 +static int +remoteRelayDomainEventVcpuRemoved(virConnectPtr conn, + virDomainPtr dom, + unsigned int vcpuid, + void *opaque) +{ + daemonClientEventCallback *callback =3D opaque; + remote_domain_event_vcpu_removed_msg data; + + if (callback->callbackID < 0 || + !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) + return -1; + + memset(&data, 0, sizeof(data)); + data.callbackID =3D callback->callbackID; + data.vcpuid =3D vcpuid; + make_nonnull_domain(&data.dom, dom); + + remoteDispatchObjectEventSend(callback->client, remoteProgram, + REMOTE_PROC_DOMAIN_EVENT_VCPU_REMOVED, + (xdrproc_t)xdr_remote_domain_event_vcpu_= removed_msg, + &data); + return 0; +} + =20 static int remoteRelayDomainEventNICMACChange(virConnectPtr conn, @@ -1383,6 +1408,7 @@ static virConnectDomainEventGenericCallback domainEve= ntCallbacks[] =3D { VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventMemoryFailure), VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventMemoryDeviceSizeChange= ), VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventNICMACChange), + VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventVcpuRemoved), }; =20 G_STATIC_ASSERT(G_N_ELEMENTS(domainEventCallbacks) =3D=3D VIR_DOMAIN_EVENT= _ID_LAST); diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index ec71eaed8762..c8a4e3f6da98 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -428,6 +428,10 @@ remoteDomainBuildEventMemoryDeviceSizeChange(virNetCli= entProgram *prog, virNetClient *client, void *evdata, void *opaque); static void +remoteDomainBuildEventVcpuRemoved(virNetClientProgram *prog, + virNetClient *client, + void *evdata, void *opaque); +static void remoteConnectNotifyEventConnectionClosed(virNetClientProgram *prog G_GNUC_= UNUSED, virNetClient *client G_GNUC_UNUSE= D, void *evdata, void *opaque); @@ -659,6 +663,10 @@ static virNetClientProgramEvent remoteEvents[] =3D { remoteDomainBuildEventNICMACChange, sizeof(remote_domain_event_nic_mac_change_msg), (xdrproc_t)xdr_remote_domain_event_nic_mac_change_msg }, + { REMOTE_PROC_DOMAIN_EVENT_VCPU_REMOVED, + remoteDomainBuildEventVcpuRemoved, + sizeof(remote_domain_event_vcpu_removed_msg), + (xdrproc_t)xdr_remote_domain_event_vcpu_removed_msg }, }; =20 static void @@ -5138,6 +5146,27 @@ remoteDomainBuildEventMemoryDeviceSizeChange(virNetC= lientProgram *prog G_GNUC_UN virObjectEventStateQueueRemote(priv->eventState, event, msg->callbackI= D); } =20 +static void +remoteDomainBuildEventVcpuRemoved(virNetClientProgram *prog G_GNUC_UNUSED, + virNetClient *client G_GNUC_UNUSED, + void *evdata, void *opaque) +{ + virConnectPtr conn =3D opaque; + remote_domain_event_vcpu_removed_msg *msg =3D evdata; + struct private_data *priv =3D conn->privateData; + virDomainPtr dom; + virObjectEvent *event =3D NULL; + + if (!(dom =3D get_nonnull_domain(conn, msg->dom))) + return; + + event =3D virDomainEventVcpuRemovedNewFromDom(dom, msg->vcpuid); + + virObjectUnref(dom); + + virObjectEventStateQueueRemote(priv->eventState, event, msg->callbackI= D); +} + =20 static void remoteDomainBuildEventNICMACChange(virNetClientProgram *prog G_GNUC_UNUSED, diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 38a83c64eadb..23699e99a60a 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3981,6 +3981,12 @@ struct remote_domain_event_memory_device_size_change= _msg { unsigned hyper size; }; =20 +struct remote_domain_event_vcpu_removed_msg { + int callbackID; + remote_nonnull_domain dom; + unsigned int vcpuid; +}; + =20 struct remote_domain_fd_associate_args { remote_nonnull_domain dom; @@ -7120,5 +7126,11 @@ enum remote_procedure { * @generate: both * @acl: none */ - REMOTE_PROC_DOMAIN_EVENT_NIC_MAC_CHANGE =3D 453 + REMOTE_PROC_DOMAIN_EVENT_NIC_MAC_CHANGE =3D 453, + + /** + * @generate: both + * @acl: none + */ + REMOTE_PROC_DOMAIN_EVENT_VCPU_REMOVED =3D 454 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 0f87d13a5ae1..75c3d0cb2e06 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -3315,6 +3315,11 @@ struct remote_domain_event_memory_device_size_change= _msg { remote_nonnull_string alias; uint64_t size; }; +struct remote_domain_event_vcpu_removed_msg { + int callbackID; + remote_nonnull_domain dom; + u_int vcpuid; +}; struct remote_domain_fd_associate_args { remote_nonnull_domain dom; remote_nonnull_string name; @@ -3791,4 +3796,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_SET_THROTTLE_GROUP =3D 451, REMOTE_PROC_DOMAIN_DEL_THROTTLE_GROUP =3D 452, REMOTE_PROC_DOMAIN_EVENT_NIC_MAC_CHANGE =3D 453, + REMOTE_PROC_DOMAIN_EVENT_VCPU_REMOVED =3D 454, }; diff --git a/tools/virsh-domain-event.c b/tools/virsh-domain-event.c index b9d1cdf019ca..4a9a831b4525 100644 --- a/tools/virsh-domain-event.c +++ b/tools/virsh-domain-event.c @@ -705,6 +705,20 @@ virshEventDeviceRemovalFailedPrint(virConnectPtr conn = G_GNUC_UNUSED, virshEventPrint(opaque, &buf); } =20 +static void +virshEventVcpuRemovedPrint(virConnectPtr conn G_GNUC_UNUSED, + virDomainPtr dom, + unsigned int vcpuid, + void *opaque) +{ + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + + virBufferAsprintf(&buf, + _("event 'vcpu-removed' for domain '%1$s': vcpu %2$u= \n"), + virDomainGetName(dom), vcpuid); + virshEventPrint(opaque, &buf); +} + VIR_ENUM_DECL(virshEventMetadataChangeType); VIR_ENUM_IMPL(virshEventMetadataChangeType, VIR_DOMAIN_METADATA_LAST, @@ -873,6 +887,8 @@ virshDomainEventCallback virshDomainEventCallbacks[] = =3D { VIR_DOMAIN_EVENT_CALLBACK(virshEventMemoryDeviceSizeChangePrint), }, { "nic-mac-change", VIR_DOMAIN_EVENT_CALLBACK(virshEventNICMACChangePrint), }, + { "vcpu-removed", + VIR_DOMAIN_EVENT_CALLBACK(virshEventVcpuRemovedPrint), }, }; G_STATIC_ASSERT(VIR_DOMAIN_EVENT_ID_LAST =3D=3D G_N_ELEMENTS(virshDomainEv= entCallbacks)); =20 --=20 2.47.3 From nobody Sat Jun 13 12:17:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1776946944; cv=none; d=zohomail.com; s=zohoarc; b=b74WT+dBgYtMIErGRHsX2cCw0XPd/6osvYBnP2lPARMMj8Le6cGpR8vBq4qHWoDABPk3SRrqxBrugFDZi6vJGfleQgIgi9j8CLfzUarQUJxL3r8DkXsARJxTwmuRRwpKuMweWhGhlu/xETWvFk6eRs/MYqRnucoRyMk8/6zneNM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776946944; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=83n1vLetyNoa8q9iq9TvxSfC9QgcvGcmW/7mIe52vaU=; b=lDDn87YUoOwmylncyAH/PfsvamSin5GbBNMXSBTRj22lzU8kV+j/3okoHvLUdlW0PpJxWLGPq2YgV6q6jhHQKXtCFfpWEdDfbqaqQhWFcahA1BLodhIa3S7hWMgXFLMFZPMLxT/nuWlNEBIg/gyV8qJzv8+WVRZszx1PNP/rlzk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1776946944542401.7413416091671; Thu, 23 Apr 2026 05:22:24 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id D219C41943; Thu, 23 Apr 2026 08:22:23 -0400 (EDT) Received: from [172.19.199.9] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 19FDC41CB0; Thu, 23 Apr 2026 07:59:33 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 6EA5B417FC; Thu, 23 Apr 2026 07:58:57 -0400 (EDT) Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 91D79418FC for ; Thu, 23 Apr 2026 07:58:54 -0400 (EDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63N6AXm13475631 for ; Thu, 23 Apr 2026 11:58:53 GMT Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4dpenm3ad2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 23 Apr 2026 11:58:53 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.7/8.18.1.7) with ESMTP id 63NBpGih006336 for ; Thu, 23 Apr 2026 11:58:52 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4dpjjqj0un-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 23 Apr 2026 11:58:52 +0000 (GMT) Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.1.12) with ESMTP id 63NBwp19029410 for ; Thu, 23 Apr 2026 11:58:51 GMT Received: from akulhall-vm1-ol9.osdevelopmeniad.oraclevcn.com (akulhall-vm1-ol9.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.255.191]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 4dpjjqj0u4-3; Thu, 23 Apr 2026 11:58:51 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=83n1v LetyNoa8q9iq9TvxSfC9QgcvGcmW/7mIe52vaU=; b=jl/okpe+YEdIf5q4wwFEo x3GxL+babvQcODaIlWT/r2LCLjraSSHSurWZozg7cw/8r+ZX5PCENEeIFJtg2vx/ 9ztQm30ulV/PeyohGoiF6aCsOl2ri+FKQbunAhSxmcM8l3aRjJCaLV3qYHg+QGOQ rkvOmVFTgb4FqmQ7geopFNNqx/IIaaaUjR3SbAESiKzSW2UdCn7oQ0xsBQ/n+vE4 LLXhNredO5iXve+QUReeGoPkeVbHqV2dczGoMWKAIDrD+ph1fKROW9Z7IjrYO7YN MzrlGwxtIa9d4oPNYSixLCMdrBV7nrBRf0d/E97xIaBsRFFngcj6+DwWjEbR7QpZ A== To: devel@lists.libvirt.org Subject: [PATCH v2 2/5] qemu: emit vcpu-removed event on unplug completion Date: Thu, 23 Apr 2026 17:27:26 +0530 Message-ID: <20260423115819.1000720-3-akash.kulhalli@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260423115819.1000720-1-akash.kulhalli@oracle.com> References: <20260423115819.1000720-1-akash.kulhalli@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-23_03,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2604200000 definitions=main-2604230118 X-Authority-Analysis: v=2.4 cv=Xbu5Co55 c=1 sm=1 tr=0 ts=69ea097d b=1 cx=c_pps a=qoll8+KPOyaMroiJ2sR5sw==:117 a=qoll8+KPOyaMroiJ2sR5sw==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=EIcjfB9IiI4px24ztqRk:22 a=yPCof4ZbAAAA:8 a=0LwpQMFJMHrlUmjHoYwA:9 cc=ntf awl=host:12292 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDIzMDExOCBTYWx0ZWRfX1i2Ekbo3EezU 7sI/2J2X/I8AodhNv4aLvWZviFdsPfrgrZhVb2RtmNrS/OxZGY7crfn4wph8iJrSn+rnxM210Nx FdVzb7GTgIQjHabtG3ItnwJ7x5gb+25tPakK+2HrhmhsOeUKgDPKj1oLCxX6Qr7mjoTrjqIFRe3 H1AllVLtWHBgQcVPUcjMKtTUVqJSllovLRg9oUJXI/cxpnsMtN7NTKyCVLKzmBZAXglAIBd9nxA y2DAiuHvG71dHxUWiBQR4N+NZqut9afqdrFacrak7UMHf3lnTlNjM/wTNbuGc2ec3QZXhUxDVWb AKxhJE3DNFSDrtoVdnGsP7GH/hCbvrm9Yh/GvkFpJHhVpFYhDhiIFZ6gN4JSOihUNkljZgF+KDo yyDmsF28iSpI29BVfPR3HtyrTF0CcYhIIu2TBoMTu0lUv3Ma4KuAZ7WVI/3zK/z6GRX+fyAAZuf opTea1oaVckOiuRANt06+qGZiGp/X2AoeP2bG7HM= X-Proofpoint-GUID: Bvg9BnS_CJ2VovCxa2dkMCg64O1kH-sY X-Proofpoint-ORIG-GUID: Bvg9BnS_CJ2VovCxa2dkMCg64O1kH-sY Message-ID-Hash: G6RANYUN4VRKAGGBTBBDKMTAS4MZ53OF X-Message-ID-Hash: G6RANYUN4VRKAGGBTBBDKMTAS4MZ53OF X-MailFrom: akash.kulhalli@oracle.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: akash.kulhalli@oracle.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Akash Kulhalli via Devel Reply-To: Akash Kulhalli X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1776946948744154100 Content-Type: text/plain; charset="utf-8" Emit the vcpu-removed event when QEMU vCPU unplug completes. Hook this into qemuDomainRemoveVcpu(), which covers both the synchronous completion path and the DEVICE_DELETED-driven alias removal path. Signed-off-by: Akash Kulhalli --- src/qemu/qemu_hotplug.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index b7a282b96e52..7828b7d73821 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -6728,6 +6728,7 @@ qemuDomainRemoveVcpu(virDomainObj *vm, unsigned int nvcpus =3D vcpupriv->vcpus; size_t i; ssize_t offlineVcpuWithTid =3D -1; + virObjectEvent *event =3D NULL; =20 if (qemuDomainRefreshVcpuInfo(vm, VIR_ASYNC_JOB_NONE, false) < 0) return -1; @@ -6757,6 +6758,10 @@ qemuDomainRemoveVcpu(virDomainObj *vm, =20 virDomainAuditVcpu(vm, oldvcpus, oldvcpus - nvcpus, "update", true); =20 + /* fire the libvirt `vcpu-removed` event */ + event =3D virDomainEventVcpuRemovedNewFromObj(vm, vcpu); + virObjectEventStateQueue(priv->driver->domainEventState, event); + return 0; } =20 --=20 2.47.3 From nobody Sat Jun 13 12:17:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1776946428; cv=none; d=zohomail.com; s=zohoarc; b=Zoj8yHRwAyn4bE/Yp0fo0zZegu/xslpVH07tKQyO0Z24KkyTecceQlH21NeWxud2XvVaHyObVTNGJUrs5g7fYHfDXXp72W8PfEH1r3AfUL03TJyibIhQZre4a6Hm0bQ4CmWEImrtBjL7fakLChngPVd9e0rtnIs3JWJk5X5kAJU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776946428; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=+8vl950WvDSpbj/F+LIvVppwejhrVn+aGnPzU5DyoIw=; b=goYCi5Ks+T2q3G0UAVMlqxgISfkz4CW313g419sqPkhZtWdy9WrokPuY2YBN9iOQntH5y6ZAcpGKZc4er4nwvNxKK5EIHWUYXAKrr0gflsUqz4vN7f+GkWCN0KO/+t594PIYnZxPSmnDXzd5RTQTfGosJQvalex20DI8W2qY+gA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1776946428414204.55074170626722; Thu, 23 Apr 2026 05:13:48 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 2536E4195E; Thu, 23 Apr 2026 08:13:47 -0400 (EDT) Received: from [172.19.199.9] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 9D16841BA7; Thu, 23 Apr 2026 07:59:24 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 8AA8441902; Thu, 23 Apr 2026 07:58:56 -0400 (EDT) Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id DA5004190B for ; Thu, 23 Apr 2026 07:58:54 -0400 (EDT) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63N6s3HQ3737355 for ; Thu, 23 Apr 2026 11:58:54 GMT Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4dpenjbam5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 23 Apr 2026 11:58:53 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.7/8.18.1.7) with ESMTP id 63NBpFhQ006278 for ; Thu, 23 Apr 2026 11:58:52 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4dpjjqj0uu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 23 Apr 2026 11:58:52 +0000 (GMT) Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.1.12) with ESMTP id 63NBwp1B029410 for ; Thu, 23 Apr 2026 11:58:52 GMT Received: from akulhall-vm1-ol9.osdevelopmeniad.oraclevcn.com (akulhall-vm1-ol9.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.255.191]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 4dpjjqj0u4-4; Thu, 23 Apr 2026 11:58:52 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=+8vl9 50WvDSpbj/F+LIvVppwejhrVn+aGnPzU5DyoIw=; b=eO192SKXGTir99bDf1DtW fusoQ5m0LOK76Hq72la9dl1rgll0+viIOfSKLW7tJZ4EuedRPTfkDpsq2oLs83nU IDx0AAHelfxQFHPIfmdPAFYzMRJN8C122IIncKsF7+kSk+iCbKhDOmZQor98VTKV Y3d71zL8IaIu5S9cVH64A+X2omkOAGiAG5ju4NhYKDvM7wMh8CkDinswf9TF3OXC HyJJK5DtFmH4vb6mCBqHGZULKovkd24xna6g/iXTOUSs2x0RsSBh+X/ZaIEZ3nnS ASJtvAag6fho9mxHyVnhtQH6BR5NX4g/X/f5x1Ih1SB/agX90R4ZEXqkDrKKubFf A== To: devel@lists.libvirt.org Subject: [PATCH v2 3/5] qemu: thread async vcpu unplug through internal helpers Date: Thu, 23 Apr 2026 17:27:27 +0530 Message-ID: <20260423115819.1000720-4-akash.kulhalli@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260423115819.1000720-1-akash.kulhalli@oracle.com> References: <20260423115819.1000720-1-akash.kulhalli@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-23_03,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2604200000 definitions=main-2604230118 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDIzMDExOCBTYWx0ZWRfX91TseApdCD2D 566LY+abv8QAfx3s82DfzXxXC2m+yNITNm/t36+oNAPRDZ2YtC7z90uPBPuiUrPKvO25WKfZEmr YFoUMCJ/ql5peAcnrFhRl5Mw6Nd9DlFu+Bmdgp+URxIAiuAw0eIj2qdCh6FSnoQh0oHR5M3FckV J/OYUzLd3ADdlP0gkJnc5sNgHzJhJgD4KYn/scf6Fhksd4HPOf3P5qPnGrYe+u2xR1EBM8u3kIV bk7UaNa8sqDbG+N/FC24WsqNQcb3gH2LPkDLF+Vvpe8h9K7aOy9+l5OyAGg9YbLSMYfVF8GwWXD eQgkis/0FIFXa3i1had6nlMfX63rozAx6xLr3Y5OpX+nP+mkYSYkgUm8h4E1yU5hBJilNoevvV2 g6N70r2RBDuXKvoqZD20KxleL+qH2HZF2wSvzDbu7PlbOqN26CQBRA23IdTlsGSLEAxmpNXn6Tm /AbCTHy1xJhfKqQlcOCinvV7CKnLugoju4+7hupE= X-Authority-Analysis: v=2.4 cv=Xay5Co55 c=1 sm=1 tr=0 ts=69ea097d b=1 cx=c_pps a=qoll8+KPOyaMroiJ2sR5sw==:117 a=qoll8+KPOyaMroiJ2sR5sw==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=x0eKOSpe3m1H3M0S9YoZ:22 a=yPCof4ZbAAAA:8 a=AQW77OXk34PHnkBC0V0A:9 cc=ntf awl=host:12292 X-Proofpoint-ORIG-GUID: UdULa7QtuJWxGvWtLylfEkXAtG26rdoH X-Proofpoint-GUID: UdULa7QtuJWxGvWtLylfEkXAtG26rdoH Message-ID-Hash: AFIDNY7BOGAZGOJAXB5HPWFUD6FL7O5T X-Message-ID-Hash: AFIDNY7BOGAZGOJAXB5HPWFUD6FL7O5T X-MailFrom: akash.kulhalli@oracle.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: akash.kulhalli@oracle.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Akash Kulhalli via Devel Reply-To: Akash Kulhalli X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1776946428923158500 Content-Type: text/plain; charset="utf-8" Thread an async_unplug flag through the internal QEMU vCPU unplug helpers. When set, the unplug path returns after QEMU accepts the device deletion request and leaves final completion to the existing DEVICE_DELETED handling routines. All callers still pass false, so this does not change behaviour yet. Signed-off-by: Akash Kulhalli Reviewed-by: Peter Krempa --- src/qemu/qemu_driver.c | 5 ++-- src/qemu/qemu_hotplug.c | 52 +++++++++++++++++++++++++++++++++-------- src/qemu/qemu_hotplug.h | 6 +++-- tests/qemuhotplugtest.c | 5 ++-- 4 files changed, 52 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d227ac58cdb4..4d9be3d3a9e5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4303,7 +4303,7 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, ret =3D qemuDomainSetVcpusMax(driver, vm, def, persistentDef, nvcp= us); else ret =3D qemuDomainSetVcpusInternal(driver, vm, def, persistentDef, - nvcpus, hotpluggable); + nvcpus, hotpluggable, false); =20 endjob: if (useAgent) @@ -19220,7 +19220,8 @@ qemuDomainSetVcpu(virDomainPtr dom, } } =20 - ret =3D qemuDomainSetVcpuInternal(driver, vm, def, persistentDef, map,= !!state); + ret =3D qemuDomainSetVcpuInternal(driver, vm, def, persistentDef, map, + !!state, false); =20 endjob: virDomainObjEndJob(vm); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 7828b7d73821..919224ed69f7 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -6793,7 +6793,8 @@ static int qemuDomainHotplugDelVcpu(virQEMUDriver *driver, virQEMUDriverConfig *cfg, virDomainObj *vm, - unsigned int vcpu) + unsigned int vcpu, + bool async_unplug) { virDomainVcpuDef *vcpuinfo =3D virDomainDefGetVcpu(vm->def, vcpu); qemuDomainVcpuPrivate *vcpupriv =3D QEMU_DOMAIN_VCPU_PRIVATE(vcpuinfo); @@ -6808,7 +6809,8 @@ qemuDomainHotplugDelVcpu(virQEMUDriver *driver, return -1; } =20 - qemuDomainMarkDeviceAliasForRemoval(vm, vcpupriv->alias); + if (!async_unplug) + qemuDomainMarkDeviceAliasForRemoval(vm, vcpupriv->alias); =20 rc =3D qemuDomainDeleteDevice(vm, vcpupriv->alias); if (rc < 0) { @@ -6817,6 +6819,12 @@ qemuDomainHotplugDelVcpu(virQEMUDriver *driver, virDomainAuditVcpu(vm, oldvcpus, oldvcpus - nvcpus, "updat= e", false); goto cleanup; } + } else if (async_unplug) { + /* + * Let DEVICE_DELETED finish the unplug asynchronously when qemu + * accepted the delete request. + */ + return 0; } else { if ((rc =3D qemuDomainWaitForDeviceRemoval(vm)) <=3D 0) { if (rc =3D=3D 0) @@ -6837,7 +6845,8 @@ qemuDomainHotplugDelVcpu(virQEMUDriver *driver, ret =3D 0; =20 cleanup: - qemuDomainResetDeviceRemoval(vm); + if (!async_unplug) + qemuDomainResetDeviceRemoval(vm); return ret; } =20 @@ -7008,7 +7017,8 @@ qemuDomainSetVcpusLive(virQEMUDriver *driver, virQEMUDriverConfig *cfg, virDomainObj *vm, virBitmap *vcpumap, - bool enable) + bool enable, + bool async) { qemuDomainObjPrivate *priv =3D vm->privateData; virCgroupEmulatorAllNodesData *emulatorCgroup =3D NULL; @@ -7028,7 +7038,7 @@ qemuDomainSetVcpusLive(virQEMUDriver *driver, if (!virBitmapIsBitSet(vcpumap, nextvcpu)) continue; =20 - if (qemuDomainHotplugDelVcpu(driver, cfg, vm, nextvcpu) < 0) + if (qemuDomainHotplugDelVcpu(driver, cfg, vm, nextvcpu, async)= < 0) goto cleanup; } } @@ -7119,7 +7129,8 @@ qemuDomainSetVcpusInternal(virQEMUDriver *driver, virDomainDef *def, virDomainDef *persistentDef, unsigned int nvcpus, - bool hotpluggable) + bool hotpluggable, + bool async_unplug) { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autoptr(virBitmap) vcpumap =3D NULL; @@ -7144,7 +7155,8 @@ qemuDomainSetVcpusInternal(virQEMUDriver *driver, &enable))) return -1; =20 - if (qemuDomainSetVcpusLive(driver, cfg, vm, vcpumap, enable) < 0) + if (qemuDomainSetVcpusLive(driver, cfg, vm, vcpumap, enable, + async_unplug) < 0) return -1; } =20 @@ -7287,14 +7299,33 @@ qemuDomainVcpuValidateConfig(virDomainDef *def, return 0; } =20 - +/** + * qemuDomainSetVcpuInternal: + * + * When @async_unplug is set to true, libvirt will not wait for + * the guest to comply with the unplug request but instead return + * immediately after receiving the acknowledgement from QEMU. Otherwise, + * libvirt will wait for a brief moment (defined by qemuDomainGetUnplugTim= eout) + * before giving up and returning control to the caller. + * + * If the request results in adding a vcpu, this parameter is ignored. + * + * @param driver the QEMU driver object + * @param vm the domain object + * @param def the live domain definition + * @param persistentDef the persistent (config) domain definition + * @param map a bitmap of cpus to be set to state @state + * @param state enable/disable the vcpus marked in @map + * @param async_unplug only used in case of unplug (i.e. @state=3Dfalse) + */ int qemuDomainSetVcpuInternal(virQEMUDriver *driver, virDomainObj *vm, virDomainDef *def, virDomainDef *persistentDef, virBitmap *map, - bool state) + bool state, + bool async_unplug) { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autoptr(virBitmap) livevcpus =3D NULL; @@ -7326,7 +7357,8 @@ qemuDomainSetVcpuInternal(virQEMUDriver *driver, } =20 if (livevcpus && - qemuDomainSetVcpusLive(driver, cfg, vm, livevcpus, state) < 0) + qemuDomainSetVcpusLive(driver, cfg, vm, livevcpus, state, + async_unplug) < 0) return -1; =20 if (persistentDef) { diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index e6c90253e416..60ed0e174c21 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -106,7 +106,8 @@ qemuDomainSetVcpusInternal(virQEMUDriver *driver, virDomainDef *def, virDomainDef *persistentDef, unsigned int nvcpus, - bool hotpluggable); + bool hotpluggable, + bool async_unplug); =20 int qemuDomainSetVcpuInternal(virQEMUDriver *driver, @@ -114,7 +115,8 @@ qemuDomainSetVcpuInternal(virQEMUDriver *driver, virDomainDef *def, virDomainDef *persistentDef, virBitmap *vcpus, - bool state); + bool state, + bool async_unplug); =20 unsigned long long qemuDomainGetUnplugTimeout(virDomainObj *vm) ATTRIBUTE_MOCKABLE; diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index ea9d3243f8b1..7e49b9ad3661 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -420,7 +420,7 @@ testQemuHotplugCpuGroup(const void *opaque) =20 rc =3D qemuDomainSetVcpusInternal(&driver, data->vm, data->vm->def, data->vm->newDef, params->newcpus, - true); + true, false); =20 if (params->fail) { if (rc =3D=3D 0) @@ -458,7 +458,8 @@ testQemuHotplugCpuIndividual(const void *opaque) goto cleanup; =20 rc =3D qemuDomainSetVcpuInternal(&driver, data->vm, data->vm->def, - data->vm->newDef, map, params->state); + data->vm->newDef, map, params->state, + false); =20 if (params->fail) { if (rc =3D=3D 0) --=20 2.47.3 From nobody Sat Jun 13 12:17:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1776945684; cv=none; d=zohomail.com; s=zohoarc; b=INfz8/HvKqf8jbGVxs63PJ9PILCmg1fH713qzAQh/KJG0acs8WsLCP+feG5xzTDQ8FByg/zwVwoi844DgOiSOY/OWWdKdutn7fVPY7noiiNbNUro+NZhK99kPaWm6fxbwkgOsk3PLRDGh9rkBgFbtzN/4TLXGA7u6uIjnZ79poI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776945684; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=NXl8mOUL4pD83lc5kJ3YTuck7E9ENIpq7qezBlWQK50=; b=eYvXqZVg7FVc6K4KnThDJOCTUP8KDjZskpKSDXiKuquVDo+YGcgK8WYUGroHkXK/ndxQmByASJOm4rTqrLaHmSDelRyHOOZ/BJuP4bkVZzxMUSFhm/LuALqUg9erDJfLz1TeXHbKuqpM81sqqML85sjtfh+O8pZhKgAiCIva7nA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1776945684358553.5332005233563; Thu, 23 Apr 2026 05:01:24 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 8A15F419E4; Thu, 23 Apr 2026 08:01:23 -0400 (EDT) Received: from [172.19.199.9] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id CF1F941AA7; Thu, 23 Apr 2026 07:59:07 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 51FA53F34D; Thu, 23 Apr 2026 07:58:55 -0400 (EDT) Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 2821D3F34D for ; Thu, 23 Apr 2026 07:58:54 -0400 (EDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63N6l2fK4136602 for ; Thu, 23 Apr 2026 11:58:53 GMT Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4dpenmkb0s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 23 Apr 2026 11:58:53 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.7/8.18.1.7) with ESMTP id 63NBpFmd006304 for ; Thu, 23 Apr 2026 11:58:52 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4dpjjqj0uy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 23 Apr 2026 11:58:52 +0000 (GMT) Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.1.12) with ESMTP id 63NBwp1D029410 for ; Thu, 23 Apr 2026 11:58:52 GMT Received: from akulhall-vm1-ol9.osdevelopmeniad.oraclevcn.com (akulhall-vm1-ol9.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.255.191]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 4dpjjqj0u4-5; Thu, 23 Apr 2026 11:58:52 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=NXl8m OUL4pD83lc5kJ3YTuck7E9ENIpq7qezBlWQK50=; b=C7Z4TlH52ED79Lt7GJfgc 9AsnQrLcEJCL/MaKP3qpjfe4QLz2RIeoK9y38VVcnzTWWoyGrbfrmu0U0BKTelJh HqTQRcTREwoSuh+RfZh1C7dTGZ5QgIOicZblR/Ij+ejCsflsL3EdSDDl8RAmuz4v ULdG3QzSsGEr1An7pKNq8PsMPoueftfkK/mumrlmtJ6JkedVHMhwdNdlVw7T3sS5 d38sFCQbUt1ya7Em3kMqTbvKRIoExhBkJapD0ipe7xktEGZERrSB4vBq89wMt7SK ZdssQjsB2Hiq/1bLRA4k9wE6Zvcrks0GgKOTUTZRovDvDxr73cpLmRmd3oJpviDa w== To: devel@lists.libvirt.org Subject: [PATCH v2 4/5] API/qemu: add async unplug flag to virDomainSetVcpusFlags Date: Thu, 23 Apr 2026 17:27:28 +0530 Message-ID: <20260423115819.1000720-5-akash.kulhalli@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260423115819.1000720-1-akash.kulhalli@oracle.com> References: <20260423115819.1000720-1-akash.kulhalli@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-23_03,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2604200000 definitions=main-2604230118 X-Authority-Analysis: v=2.4 cv=PsSjqQM3 c=1 sm=1 tr=0 ts=69ea097d b=1 cx=c_pps a=qoll8+KPOyaMroiJ2sR5sw==:117 a=qoll8+KPOyaMroiJ2sR5sw==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=x4eqshVgHu-cdnggieHk:22 a=yPCof4ZbAAAA:8 a=gEtyn5yjKoQnlD_PDlYA:9 cc=ntf awl=host:12292 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDIzMDExOCBTYWx0ZWRfX+h9QYWnyNMfa hFXqz9Xr97ALB8sfnTMpkCZmAS3mub798eU2IoBc90zc8GMCo6rmZXxkQEYEC2o+hZzbvGyn1q/ enMC/JKdXKXCiLauTBBWcO/T/vG+H2pPP6Md/VpsrHf5Nocd3MB8mUmOzqCZ9avapY7FK2vmvMM KrI4DVdfUfnlvWmkzyH0YigodJAhbpKcCwzZTzH0k/sNKWq5t0z05bI8OeesY7Kp8U1Q8QLpD8w /I1tMMPP68QWWfq1vnALQ9ggz6vbsQ9Mox+Gptji97WFh1uIQBDdPQUSQIyGa3k+SNIJ0DFazDC 6Ued07q4fjLTf3WDNg8KgELxlg8z6QMCvN18jcSc3rob8DFh9Qul5Snfx4eKeH3v8bHC/ip9Edo hMWSJFsApZ/jjvDLYHoF6SIi1ws/ccy9i531seV7de2Eaez/vpbIN/wwvUVcEhaFQeBJuzK1Xa1 gLnnLmfiOHVcO86BEYQ8l9hKIDqxwsJt67sn6tD4= X-Proofpoint-GUID: MGo1kbvdVWdFMwDcl5DXMvzoyCnL75EL X-Proofpoint-ORIG-GUID: MGo1kbvdVWdFMwDcl5DXMvzoyCnL75EL Message-ID-Hash: LJKMSUAC72ZHITDFRTNJXQVXPROIQLO5 X-Message-ID-Hash: LJKMSUAC72ZHITDFRTNJXQVXPROIQLO5 X-MailFrom: akash.kulhalli@oracle.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: akash.kulhalli@oracle.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Akash Kulhalli via Devel Reply-To: Akash Kulhalli X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1776945689934154101 Content-Type: text/plain; charset="utf-8" Add VIR_DOMAIN_VCPU_ASYNC_UNPLUG for virDomainSetVcpusFlags(). With this flag, success indicates that QEMU accepted the unplug request, while final completion is reported by the vcpu-removed event. Rejected requests continue to be reported by the device-removal-failed event. Wire the flag through the QEMU driver, document its semantics, and add virsh support for setvcpus --async. Signed-off-by: Akash Kulhalli Reviewed-by: Peter Krempa --- docs/manpages/virsh.rst | 13 +++++++++++-- include/libvirt/libvirt-domain.h | 1 + src/libvirt-domain.c | 10 ++++++++++ src/qemu/qemu_driver.c | 12 ++++++++++-- tools/virsh-domain.c | 8 ++++++++ 5 files changed, 40 insertions(+), 4 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 80b0ea14a8b3..f4c8e573cd47 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -179,7 +179,8 @@ Most ``virsh`` commands act synchronously, except maybe= shutdown, setvcpus and setmem. In those cases the fact that the ``virsh`` program returned, may not mean the action is complete and you must poll periodically to detect that the guest completed the -operation. +operation. This asynchronous behaviour can be enforced with the +``--async`` flag to ``setvcpus`` only. =20 ``virsh`` strives for backward compatibility. Although the ``help`` command only lists the preferred usage of a command, if an older @@ -4810,7 +4811,7 @@ setvcpus =20 :: =20 - setvcpus domain count [--maximum] [[--config] [--live] | [--current]] [= --guest] [--hotpluggable] + setvcpus domain count [--maximum] [[--config] [--live] | [--current]] [= --guest] [--hotpluggable] [--async] =20 Change the number of virtual CPUs active in a guest domain. By default, this command works on active guest domains. To change the settings for an @@ -4839,6 +4840,14 @@ is up to the hypervisor whether the *--config* flag = is also assumed, and therefore whether the XML configuration is adjusted to make the change persistent. =20 +If *--async* is specified, live vCPU unplug requests are fired without wai= ting +for the guest to comply. This affects only the live unplug part of the +operation; it may optionally be combined with *--config*. Final completion= is +reported by the ``vcpu-removed`` domain event, while rejected unplug reque= sts +continue to be reported by ``device-removal-failed``. If the requested cou= nt +increases the live vCPU count, or only affects the persistent configuratio= n, +*--async* has no effect. This flag cannot be combined with *--guest*. + If *--guest* is specified, then the count of cpus is modified in the guest instead of the hypervisor. This flag is usable only for live domains and may require guest agent to be configured in the guest. diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 92d5ecb32d65..016b6ea700e9 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -2605,6 +2605,7 @@ typedef enum { VIR_DOMAIN_VCPU_MAXIMUM =3D (1 << 2), /* Max rather than current count= (Since: 0.8.5) */ VIR_DOMAIN_VCPU_GUEST =3D (1 << 3), /* Modify state of the cpu in th= e guest (Since: 1.1.0) */ VIR_DOMAIN_VCPU_HOTPLUGGABLE =3D (1 << 4), /* Make vcpus added hot(un)= pluggable (Since: 2.4.0) */ + VIR_DOMAIN_VCPU_ASYNC_UNPLUG =3D (1 << 5), /* Don't wait for the guest= to comply with unplug request(s) (Since: 12.3.0) */ } virDomainVcpuFlags; =20 int virDomainSetVcpus (virDomainPtr domain, diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index db9eea57745c..97af1099f939 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -7773,6 +7773,16 @@ virDomainSetVcpus(virDomainPtr domain, unsigned int = nvcpus) * be used with live guests and is incompatible with VIR_DOMAIN_VCPU_MAXIM= UM. * The usage of this flag may require a guest agent configured. * + * If @flags includes VIR_DOMAIN_VCPU_ASYNC_UNPLUG, live vCPU hot-unplug + * request(s) are fired without waiting for the guest to comply. Success in + * this mode only means that the unplug request(s) were accepted. Final + * completion is reported by VIR_DOMAIN_EVENT_ID_VCPU_REMOVED, carrying the + * XML ```` value for each removed vCPU. Rejected unplug + * requests continue to be reported through the event + * VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED. The success event may be + * delivered before this API call returns. This flag has no effect when th= is + * operation results in an increase in the live vCPU count. + * * Not all hypervisors can support all flag combinations. * * Returns 0 in case of success, -1 in case of failure. diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4d9be3d3a9e5..c9c72b29617f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4269,6 +4269,7 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, virDomainObj *vm =3D NULL; virDomainDef *def; virDomainDef *persistentDef; + bool async_unplug =3D !!(flags & VIR_DOMAIN_VCPU_ASYNC_UNPLUG); bool hotpluggable =3D !!(flags & VIR_DOMAIN_VCPU_HOTPLUGGABLE); bool useAgent =3D !!(flags & VIR_DOMAIN_VCPU_GUEST); int ret =3D -1; @@ -4277,7 +4278,8 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, VIR_DOMAIN_AFFECT_CONFIG | VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_GUEST | - VIR_DOMAIN_VCPU_HOTPLUGGABLE, -1); + VIR_DOMAIN_VCPU_HOTPLUGGABLE | + VIR_DOMAIN_VCPU_ASYNC_UNPLUG, -1); =20 if (!(vm =3D qemuDomainObjFromDomain(dom))) goto cleanup; @@ -4297,13 +4299,19 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) goto endjob; =20 + if (async_unplug && (useAgent || !def)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("asynchronous mode is supported only for live vcp= u unplug")); + goto endjob; + } + if (useAgent) ret =3D qemuDomainSetVcpusAgent(vm, nvcpus); else if (flags & VIR_DOMAIN_VCPU_MAXIMUM) ret =3D qemuDomainSetVcpusMax(driver, vm, def, persistentDef, nvcp= us); else ret =3D qemuDomainSetVcpusInternal(driver, vm, def, persistentDef, - nvcpus, hotpluggable, false); + nvcpus, hotpluggable, async_unplu= g); =20 endjob: if (useAgent) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 08a1ce395378..1fccee4bc9ed 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -7667,6 +7667,10 @@ static const vshCmdOptDef opts_setvcpus[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("make added vcpus hot(un)pluggable") }, + {.name =3D "async", + .type =3D VSH_OT_BOOL, + .help =3D N_("return after firing vcpu unplug request(s)") + }, {.name =3D NULL} }; =20 @@ -7681,11 +7685,13 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd) bool current =3D vshCommandOptBool(cmd, "current"); bool guest =3D vshCommandOptBool(cmd, "guest"); bool hotpluggable =3D vshCommandOptBool(cmd, "hotpluggable"); + bool async =3D vshCommandOptBool(cmd, "async"); unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; =20 VSH_EXCLUSIVE_OPTIONS_VAR(current, live); VSH_EXCLUSIVE_OPTIONS_VAR(current, config); VSH_EXCLUSIVE_OPTIONS_VAR(guest, config); + VSH_EXCLUSIVE_OPTIONS_VAR(async, guest); =20 VSH_REQUIRE_OPTION_VAR(maximum, config); =20 @@ -7699,6 +7705,8 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd) flags |=3D VIR_DOMAIN_VCPU_MAXIMUM; if (hotpluggable) flags |=3D VIR_DOMAIN_VCPU_HOTPLUGGABLE; + if (async) + flags |=3D VIR_DOMAIN_VCPU_ASYNC_UNPLUG; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; --=20 2.47.3 From nobody Sat Jun 13 12:17:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1776946661; cv=none; d=zohomail.com; s=zohoarc; b=JN60sE7jzvRXdzLltzKmia7N5YntfhfO28BG0x0uvIscFZyMS8yZRDpmRHnTosaJISHVmgVlXLeVHL180CtuTezoimUAM7h9Oea2PeDxeNcClGCMUQYkJPG0eWekxSiEdLm8u0/798VapeuauG6MtPGgZwIaPfuukg8uB9Mty6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776946661; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=GGXtLV63YxflWJehmeBXFra3NqXPxY+BNdKGTytihic=; b=f5O03pL/XUF19WVCW7YvPA+pZmMyA2JM6jOApjXQhot12yPExd48HZOGq/0BTsLS6cHceSX69lRjTczIB6T9Mwgaf/B73v30X+jXZSZjebSHiGVD1C62wWOV+H4oDLHy0rERFBS5P8CD7Ja+m2SE1WhhfWaWmNDRlNs6zITRTjo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1776946661937583.9443039962999; Thu, 23 Apr 2026 05:17:41 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 3BD793F304; Thu, 23 Apr 2026 08:17:41 -0400 (EDT) Received: from [172.19.199.9] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 31A6841989; Thu, 23 Apr 2026 07:59:29 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id C4133417FC; Thu, 23 Apr 2026 07:58:56 -0400 (EDT) Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 4E7EE41905 for ; Thu, 23 Apr 2026 07:58:55 -0400 (EDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63N6BWeB2586195 for ; Thu, 23 Apr 2026 11:58:54 GMT Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4dpenrkave-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 23 Apr 2026 11:58:54 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.7/8.18.1.7) with ESMTP id 63NBpFeO006281 for ; Thu, 23 Apr 2026 11:58:52 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4dpjjqj0v2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 23 Apr 2026 11:58:52 +0000 (GMT) Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.1.12) with ESMTP id 63NBwp1F029410 for ; Thu, 23 Apr 2026 11:58:52 GMT Received: from akulhall-vm1-ol9.osdevelopmeniad.oraclevcn.com (akulhall-vm1-ol9.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.255.191]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 4dpjjqj0u4-6; Thu, 23 Apr 2026 11:58:52 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=GGXtL V63YxflWJehmeBXFra3NqXPxY+BNdKGTytihic=; b=HTFx/KIcLfuVXSdlL3gnL ZU/oOqPUqiLO095SKiclWk06sZWLRpVGqCDV7aEv7iVday2pxrJpe2P46rHr65YC /FCuNLfUj8X4kcyyi2cIu0xeHvf5u9Zjj0gWGG078bfFJP39RNdbz/D20LW8z05X bz2iFlqbKXwFGud6DJ2xdpnTERMWgiVWxSuZ4iKKiFs6nx1sSkIE0OMxzFOTPKYW GYvd4conc1cbhsHpFRiF82yHYPFd/GklpA7jgp9qfE7OIlnKk5QYLX3LG+WdBNXB lhdSJejmYpAElqy02eGrUTNj57gC0fZRfnm5rOYhtctA0zk/5C4SiySMBViMU8eK g== To: devel@lists.libvirt.org Subject: [PATCH v2 5/5] API/qemu: add async unplug flag to virDomainSetVcpu Date: Thu, 23 Apr 2026 17:27:29 +0530 Message-ID: <20260423115819.1000720-6-akash.kulhalli@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260423115819.1000720-1-akash.kulhalli@oracle.com> References: <20260423115819.1000720-1-akash.kulhalli@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-23_03,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2604200000 definitions=main-2604230118 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDIzMDExOCBTYWx0ZWRfX5cYuue7PO9dy o39E/oVh6VvQIP6x4hjv5EDOiN5tgXUEZ4X8kKFN6iEbrJKR7V1LwUmU5MiXu9ctpOAIi0JBygH dnjw+Ta5qwxGyB5krVyuE0aCvGCMHkQkV6zt0IDhR1G1O/2Io+Ur8QMsrwMj3P1W9VD65oSaYYz MkcUuv41oxz77cGAR55qE4TgkxKoba24GWMNDFTpTjDI7XwyfAmtY13pK9Jtj/2yEVAtlPjIYpn DEUp/4eNJrcBn98XR7m2UZQ+j3xoVntfDzviFQ60xAlzp6234MzFPcZO5XjYKyjaClvzDrno03T URpBlwW2oyomzDaLolVsH73fig+lyq85fszjXyF4AnaMgI3nh/Mk00imY8LyQDQ7WGAj6bgeLQ5 9hV1L3CD1jx4RaeJ0X9JXlBAu/NfLCEz0J5miPih67rxbupO9L5Eo2PIjbLa+FokuPBzXZtb07r E8pJ2wxUZgyhcigATMj1oQWGMSIuDGfRwN8uJH1k= X-Proofpoint-GUID: JXemBTQmfgPERM1GroO1tINLpb-2QLeg X-Proofpoint-ORIG-GUID: JXemBTQmfgPERM1GroO1tINLpb-2QLeg X-Authority-Analysis: v=2.4 cv=JeKMa0KV c=1 sm=1 tr=0 ts=69ea097e b=1 cx=c_pps a=qoll8+KPOyaMroiJ2sR5sw==:117 a=qoll8+KPOyaMroiJ2sR5sw==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=RD47p0oAkeU5bO7t-o6f:22 a=yPCof4ZbAAAA:8 a=Rh8pJKq3MEYQnjLNRPYA:9 cc=ntf awl=host:12292 Message-ID-Hash: ISGEHKYETOXXAGIOW525AQEMVISTER4N X-Message-ID-Hash: ISGEHKYETOXXAGIOW525AQEMVISTER4N X-MailFrom: akash.kulhalli@oracle.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: akash.kulhalli@oracle.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Akash Kulhalli via Devel Reply-To: Akash Kulhalli X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1776946663839154100 Content-Type: text/plain; charset="utf-8" Add VIR_DOMAIN_SETVCPU_ASYNC_UNPLUG for virDomainSetVcpu(). Define a dedicated virDomainSetVcpuBehaviour flag type and wire the new flag through the QEMU driver. As with setvcpus async unplug, success indicates request acceptance while final completion is reported by the vcpu-removed event. Update the API documentation and add virsh support for setvcpu --async. Signed-off-by: Akash Kulhalli --- docs/manpages/virsh.rst | 10 ++++++++-- include/libvirt/libvirt-domain.h | 14 ++++++++++++++ src/libvirt-domain.c | 11 ++++++++++- src/qemu/qemu_driver.c | 12 ++++++++++-- tools/virsh-domain.c | 8 ++++++++ 5 files changed, 50 insertions(+), 5 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index f4c8e573cd47..7b3c853aea27 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -180,7 +180,7 @@ setvcpus and setmem. In those cases the fact that the `= `virsh`` program returned, may not mean the action is complete and you must poll periodically to detect that the guest completed the operation. This asynchronous behaviour can be enforced with the -``--async`` flag to ``setvcpus`` only. +``--async`` flag to ``setvcpus`` and ``setvcpu`` only. =20 ``virsh`` strives for backward compatibility. Although the ``help`` command only lists the preferred usage of a command, if an older @@ -4871,7 +4871,7 @@ setvcpu =20 :: =20 - setvcpu domain vcpulist [--enable] | [--disable] + setvcpu domain vcpulist [--enable] | [--disable] [--async] [[--live] [--config] | [--current]] =20 Change state of individual vCPUs using hot(un)plug mechanism. @@ -4891,6 +4891,12 @@ If *--current* is specified, it is equivalent to eit= her *--live* or default. Both *--live* and *--config* flags may be given, but *--current* is exclusive. =20 +If *--async* is specified with *--disable*, live vCPU unplug requests are +fired without waiting for the guest to comply. This may optionally be +combined with *--config*. Final completion of this operation is reported +by the ``vcpu-removed`` domain event, while rejected unplug requests conti= nue +to be reported by ``device-removal-failed``. + =20 shutdown -------- diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 016b6ea700e9..2b6c498ed5ab 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -329,6 +329,20 @@ typedef enum { /* 1 << 2 is reserved for virTypedParameterFlags */ } virDomainModificationImpact; =20 +/** + * virDomainSetVcpuBehaviour: + * + * These flags must be used when calling the `virDomainSetVcpu` API. + * + * Since: 12.3.0 + */ +typedef enum { + VIR_DOMAIN_SETVCPU_AFFECT_CURRENT =3D VIR_DOMAIN_AFFECT_CURRENT, /* Af= fect current domain state. (Since: 0.9.2) */ + VIR_DOMAIN_SETVCPU_AFFECT_LIVE =3D VIR_DOMAIN_AFFECT_LIVE, /* Affect r= unning domain state. (Since: 0.9.2) */ + VIR_DOMAIN_SETVCPU_AFFECT_CONFIG =3D VIR_DOMAIN_AFFECT_CONFIG, /* Affe= ct persistent domain state. (Since: 0.9.2) */ + VIR_DOMAIN_SETVCPU_ASYNC_UNPLUG =3D 1 << 2 /* Do not wait for the gues= t to comply with the request (Since: 12.3.0) */ +} virDomainSetVcpuBehaviour; + /** * virDomainInfo: * diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 97af1099f939..e3d1b76bcd01 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -13135,7 +13135,7 @@ virDomainSetGuestVcpus(virDomainPtr domain, * @domain: pointer to domain object * @vcpumap: text representation of a bitmap of vcpus to set * @state: 0 to disable/1 to enable cpus described by @vcpumap - * @flags: bitwise-OR of virDomainModificationImpact + * @flags: bitwise-OR of virDomainSetVcpuBehaviour * * Enables/disables individual vcpus described by @vcpumap in the hypervis= or. * @@ -13144,6 +13144,15 @@ virDomainSetGuestVcpus(virDomainPtr domain, * * Note that OSes and hypervisors may require vCPU 0 to stay online. * + * If @flags includes VIR_DOMAIN_SETVCPU_ASYNC_UNPLUG, live vCPU disable (= hot-unplug) + * request(s) are fired without waiting for the guest to comply. Success in + * this mode means only that the unplug request(s) were accepted. Final + * completion is reported by VIR_DOMAIN_EVENT_ID_VCPU_REMOVED, carrying the + * XML ```` value for each removed vCPU. Rejected unplug + * requests continue to be reported by VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_= FAILED. + * The success event may be delivered before this API call returns. This f= lag + * has no effect when the selected vCPUs are enabled. + * * Returns 0 on success, -1 on error. * * Since: 3.1.0 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c9c72b29617f..9a20486725cb 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19177,12 +19177,14 @@ qemuDomainSetVcpu(virDomainPtr dom, virDomainObj *vm =3D NULL; virDomainDef *def =3D NULL; virDomainDef *persistentDef =3D NULL; + bool async_unplug =3D !!(flags & VIR_DOMAIN_SETVCPU_ASYNC_UNPLUG); g_autoptr(virBitmap) map =3D NULL; ssize_t lastvcpu; int ret =3D -1; =20 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | - VIR_DOMAIN_AFFECT_CONFIG, -1); + VIR_DOMAIN_AFFECT_CONFIG | + VIR_DOMAIN_SETVCPU_ASYNC_UNPLUG, -1); =20 if (state !=3D 0 && state !=3D 1) { virReportInvalidArg(state, "%s", _("unsupported state value")); @@ -19228,8 +19230,14 @@ qemuDomainSetVcpu(virDomainPtr dom, } } =20 + if (async_unplug && (!def)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("asynchronous mode is supported only for live vcp= u unplug")); + goto endjob; + } + ret =3D qemuDomainSetVcpuInternal(driver, vm, def, persistentDef, map, - !!state, false); + !!state, async_unplug); =20 endjob: virDomainObjEndJob(vm); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 1fccee4bc9ed..76369e8694ce 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -7837,6 +7837,10 @@ static const vshCmdOptDef opts_setvcpu[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("disable cpus specified by cpumap") }, + {.name =3D "async", + .type =3D VSH_OT_BOOL, + .help =3D N_("return after firing vcpu unplug request") + }, VIRSH_COMMON_OPT_DOMAIN_CONFIG, VIRSH_COMMON_OPT_DOMAIN_LIVE, VIRSH_COMMON_OPT_DOMAIN_CURRENT, @@ -7851,6 +7855,7 @@ cmdSetvcpu(vshControl *ctl, const vshCmd *cmd) bool disable =3D vshCommandOptBool(cmd, "disable"); bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); + bool async =3D vshCommandOptBool(cmd, "async"); const char *vcpulist =3D NULL; int state =3D 0; unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; @@ -7859,11 +7864,14 @@ cmdSetvcpu(vshControl *ctl, const vshCmd *cmd) =20 VSH_EXCLUSIVE_OPTIONS("current", "live"); VSH_EXCLUSIVE_OPTIONS("current", "config"); + VSH_EXCLUSIVE_OPTIONS("async", "enable"); =20 if (config) flags |=3D VIR_DOMAIN_AFFECT_CONFIG; if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; + if (async) + flags |=3D VIR_DOMAIN_SETVCPU_ASYNC_UNPLUG; =20 if (!(enable || disable)) { vshError(ctl, "%s", _("one of --enable, --disable is required")); --=20 2.47.3