From nobody Mon Feb 9 21:03:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; 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 8.43.85.245 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=1743433610; cv=none; d=zohomail.com; s=zohoarc; b=iVaKZ2UlSVz8nJot+EKPrybYPW05FvtZMp3WKdZAVcvLxm2FSDDksaLgQFQnivj8eFb/1GXLvW58/1U/7fFJ48FNXO5UAO/o1yebulR5Yu0AjDsouk0DVq1F3TSIMAyGaKCjfSGORNn0UBaemXg+Et1160A7Y72yYsfoj/dXl3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1743433610; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=uzrYjXFtcqoq3XYCYTiZRBMff2BN1UcLEI1YYqFEO1E=; b=hTt2IqgfP+tiEKfwTprbBvkDZYYw/oPpYyaisq4qgQBy1tvHUOvb39S46TBFa6gYW43KMCYu9m9aiPpTalQeQ98X7ejVgPmk2KNp1zxUML/u3W/NcEMQMPXYmRJ+2L0YNNI24On/hVxz7/T01rDbg6Tt/C4wX51fgCdKulncI4I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 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 [8.43.85.245]) by mx.zohomail.com with SMTPS id 1743433610080670.8110788693268; Mon, 31 Mar 2025 08:06:50 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1490BC5A; Mon, 31 Mar 2025 11:06:49 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 047F4135C; Mon, 31 Mar 2025 11:04:28 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D104712BC; Mon, 31 Mar 2025 11:04:23 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 6F01B11B0 for ; Mon, 31 Mar 2025 11:04:15 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-507-yZRdlhywMwSNIsu0_FPnMQ-1; Mon, 31 Mar 2025 11:04:13 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A156918001F7 for ; Mon, 31 Mar 2025 15:04:12 +0000 (UTC) Received: from kshcheti-thinkpadp1gen4i.tpbc.com (unknown [10.43.2.246]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AF4CB1955BEF; Mon, 31 Mar 2025 15:04:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743433455; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ycAK1INawR8f5vqvkcSznquuosX7Sn4kw/j53kfcdmg=; b=SBDrmbVSiVq3WtzfntUO4HnKS/elIWKdUpy0e4cuM1LDkgMsZn7dJ1lzqncfUO97LPzlye H6Ph8Xlk8pDUDh5/irf/5+bWA/fhR5bWHGLqwvoEsXef4sPhtTFpSseCWWyLHhYcFsP20z Auw8+UONf8dUu5Zd2uDFplJuGKWWQrc= X-MC-Unique: yZRdlhywMwSNIsu0_FPnMQ-1 X-Mimecast-MFC-AGG-ID: yZRdlhywMwSNIsu0_FPnMQ_1743433452 To: devel@lists.libvirt.org Subject: [PATCH 4/4] ch: fix timeout while domain is still running Date: Mon, 31 Mar 2025 17:01:41 +0200 Message-ID: <20250331150359.276206-5-kshcheti@redhat.com> In-Reply-To: <20250331150359.276206-1-kshcheti@redhat.com> References: <20250331150359.276206-1-kshcheti@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 6tdjysUyjl2mhEPBBSCaPstiqB_ee0MY7Lpn7AB-iKs_1743433452 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: VQNBIELEJZNGJSXVV6ASFUPTX3WNTG4L X-Message-ID-Hash: VQNBIELEJZNGJSXVV6ASFUPTX3WNTG4L X-MailFrom: kshcheti@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Kirill Shchetiniuk X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Kirill Shchetiniuk via Devel Reply-To: Kirill Shchetiniuk X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1743433612489019100 Content-Type: text/plain; charset="utf-8"; x-default="true" Previously, the CH driver would timeout even if one or more domains were still running, only an active virsh session prevented the driver's timeout. To address this, an inhibitor has been added to ensure driver remains active as long as any domain is still running. Inhibitor is now held when a domain starts up or when the driver successfully reconnects to a running domain. This now prevents the driver from timeout while any domain is still running. Inhibitor is later released with domain shutdown, ensuring correct running domains count. Resolves: https://gitlab.com/libvirt/libvirt/-/issues/743 Signed-off-by: Kirill Shchetiniuk --- src/ch/ch_conf.h | 4 ++++ src/ch/ch_driver.c | 15 +++++++++++++-- src/ch/ch_process.c | 6 ++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/ch/ch_conf.h b/src/ch/ch_conf.h index 8beeb69b95..ca9151e5d8 100644 --- a/src/ch/ch_conf.h +++ b/src/ch/ch_conf.h @@ -26,6 +26,7 @@ #include "ch_capabilities.h" #include "virebtables.h" #include "object_event.h" +#include "virinhibitor.h" =20 #define CH_DRIVER_NAME "CH" #define CH_CMD "cloud-hypervisor" @@ -92,6 +93,9 @@ struct _virCHDriver =20 /* Immutable pointer, self-locking APIs */ virObjectEventState *domainEventState; + + /* Immutable pointer, self-locking APIs */ + virInhibitor *inhibitor; }; =20 #define CH_SAVE_MAGIC "libvirt-xml\n \0 \r" diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index 465528baf1..2d72de3ed2 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -42,6 +42,7 @@ #include "viruuid.h" #include "virnuma.h" #include "virhostmem.h" +#include "virinhibitor.h" =20 #define VIR_FROM_THIS VIR_FROM_CH =20 @@ -1411,6 +1412,7 @@ static int chStateCleanup(void) virObjectUnref(ch_driver->domains); virObjectUnref(ch_driver->hostdevMgr); virObjectUnref(ch_driver->domainEventState); + virInhibitorFree(ch_driver->inhibitor); virMutexDestroy(&ch_driver->lock); g_clear_pointer(&ch_driver, g_free); =20 @@ -1421,8 +1423,8 @@ static virDrvStateInitResult chStateInitialize(bool privileged, const char *root, bool monolithic G_GNUC_UNUSED, - virStateInhibitCallback callback G_GNUC_UNUSED, - void *opaque G_GNUC_UNUSED) + virStateInhibitCallback callback, + void *opaque) { int ret =3D VIR_DRV_STATE_INIT_ERROR; int rv; @@ -1473,6 +1475,15 @@ chStateInitialize(bool privileged, goto cleanup; } =20 + /* Setup inhibitor to be able to avoid timeout */ + ch_driver->inhibitor =3D virInhibitorNew(VIR_INHIBITOR_WHAT_SHUTDOWN, + _("Libvirt Cloud-Hypervisor"), + _("Cloud-Hypervisor virtual mac= hines are running"), + VIR_INHIBITOR_MODE_DELAY, + callback, + opaque); + + /* Transient domains load */ if (virDomainObjListLoadAllConfigs(ch_driver->domains, cfg->stateDir, diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index d7a5ecc09c..8f61a5f220 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -997,6 +997,8 @@ virCHProcessStart(virCHDriver *driver, =20 virCHDomainSaveStatus(vm); =20 + virInhibitorHold(driver->inhibitor); + return 0; =20 cleanup: @@ -1072,6 +1074,8 @@ virCHProcessStop(virCHDriver *driver, vm->def->id =3D -1; g_clear_pointer(&priv->machineName, g_free); =20 + virInhibitorRelease(driver->inhibitor); + virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, reason); =20 virHostdevReAttachDomainDevices(driver->hostdevMgr, CH_DRIVER_NAME, de= f, @@ -1253,6 +1257,8 @@ virCHProcessReconnect(void *opaque) if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto error; =20 + virInhibitorHold(driver->inhibitor); + cleanup: virDomainObjEndJob(vm); virDomainObjEndAPI(&vm); --=20 2.48.1