From nobody Fri Nov 21 10:18:11 2025 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=1763545264; cv=none; d=zohomail.com; s=zohoarc; b=FOFpfcl8RB/KOvslLwS4+xbgdvi+CS8LhQk/swKlNQJ0ItSnf+EQAk8UXmGZiuH8DzvCr2DYAxxbJiMIXWIS4lPgddWpSvKtDV+iAc/oFp5q38VDFbWNEjQDy2QA/HZEVL3IXgJGLjLw/t37TtRqAIENygxnQldRAwflnjcpI8w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1763545264; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=59RYCYyy62xUrjZ5BfUJcDRzmt3v3/oHoCoWKj5chVA=; b=fu3cQboHQcq+J3m9wrP4yCDPiXPlT0apy0K40hFSFOTtRaZOxFGfU9jQFsktPX7WxLFtqxEFOqB938a10AwgvDfdgIjXsPlDHalpM38S/Ln2OeFO3OA438bC4oE3Hj1NpWdRJO9CI/zpYXPlWJYZuFLqxX0Khi2CD1/1vwTqrVE= 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 17635452647451008.2994483181474; Wed, 19 Nov 2025 01:41:04 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 087764408F; Wed, 19 Nov 2025 04:41:02 -0500 (EST) Received: from [172.19.199.50] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 5FC7D43F93; Wed, 19 Nov 2025 04:38:18 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 6E99D41BC7; Wed, 19 Nov 2025 04:38:00 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 542AF43EBD for ; Wed, 19 Nov 2025 04:37:59 -0500 (EST) 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-133-8H9F6fR9MyOOF7hZy_XmRQ-1; Wed, 19 Nov 2025 04:37:57 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 8BA781801301 for ; Wed, 19 Nov 2025 09:37:56 +0000 (UTC) Received: from speedmetal.openshiftapps.com (unknown [10.45.242.12]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C319B180049F for ; Wed, 19 Nov 2025 09:37:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763545079; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=59RYCYyy62xUrjZ5BfUJcDRzmt3v3/oHoCoWKj5chVA=; b=h6RQLbZvOQfHd4LHEKNF4y7pFsrsZMd/9TAs9e77Td7MVan3HHBxlgeAfzwm+l77u3CGDU 8PPJnIKNkWnJlGMYH7MYNyGbqHJ9sLIPtWdUGtrofE89clFXqDMSiRE4X/4jhAASbWWp6f 26++MukYPQLSaJ4daNtw6M0g4x8jpwY= X-MC-Unique: 8H9F6fR9MyOOF7hZy_XmRQ-1 X-Mimecast-MFC-AGG-ID: 8H9F6fR9MyOOF7hZy_XmRQ_1763545076 To: devel@lists.libvirt.org Subject: [PATCH 2/8] qemuProcessReconnect: Continue reconnection if VM untergoes fake-reboot Date: Wed, 19 Nov 2025 10:37:45 +0100 Message-ID: <8985da4e76587874e0007e4d92cc69aa845d5da8.1763544909.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Qfg2hRxXWU7Nvy1DvY131II7ltAuUyT-K6sv_YKCIRM_1763545076 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: BRTOPSETCRVK65RLTTYSILAGHIXCK2KP X-Message-ID-Hash: BRTOPSETCRVK65RLTTYSILAGHIXCK2KP X-MailFrom: pkrempa@redhat.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 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: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1763545265917158500 Content-Type: text/plain; charset="utf-8" From: Peter Krempa 'qemuProcessShutdownOrReboot' may or may not kill the VM. In 'qemuProcessReconnect' if we decided that the VM was in a state requiring 'qemuProcessShutdownOrReboot' to be called we'd stop the reconnection unconditionally. Now if the VM ought to undergo a fake reboot we really need to reconnect to the process because the process will be kept around for much longer. Make qemuProcessShutdownOrReboot return whether it killed the VM and continue the reconnection if it didn't. Signed-off-by: Peter Krempa --- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_process.c | 25 +++++++++++++++++++++---- src/qemu/qemu_process.h | 3 ++- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1f7e587f61..d99528724e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3557,7 +3557,7 @@ processGuestPanicEvent(virQEMUDriver *driver, case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART: qemuDomainSetFakeReboot(vm, true); - qemuProcessShutdownOrReboot(vm); + ignore_value(qemuProcessShutdownOrReboot(vm)); break; case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE: diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 45fc32a663..bbd9859ef4 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -597,7 +597,16 @@ qemuProcessFakeReboot(void *opaque) } -void +/** + * qemuProcessShutdownOrReboot: + * @vm: domain object + * + * Perform the appropriate action when the guest OS shuts down. This can be + * either fake reboot (the VM is reset started again) or the VM is termina= ted. + * + * The function returns true if the VM was terminated. + */ +bool qemuProcessShutdownOrReboot(virDomainObj *vm) { qemuDomainObjPrivate *priv =3D vm->privateData; @@ -620,9 +629,14 @@ qemuProcessShutdownOrReboot(virDomainObj *vm) qemuDomainSetFakeReboot(vm, false); virObjectUnref(vm); } + + return false; } else { ignore_value(qemuProcessKill(vm, VIR_QEMU_PROCESS_KILL_NOWAIT)); + return true; } + + return false; } @@ -714,7 +728,7 @@ qemuProcessHandleShutdown(qemuMonitor *mon G_GNUC_UNUSE= D, if (priv->agent) qemuAgentNotifyEvent(priv->agent, QEMU_AGENT_EVENT_SHUTDOWN); - qemuProcessShutdownOrReboot(vm); + ignore_value(qemuProcessShutdownOrReboot(vm)); unlock: virObjectUnlock(vm); @@ -9705,8 +9719,11 @@ qemuProcessReconnect(void *opaque) reason =3D=3D VIR_DOMAIN_PAUSED_USER)) { VIR_DEBUG("Finishing shutdown sequence for domain %s", obj->def->name); - qemuProcessShutdownOrReboot(obj); - goto cleanup; + /* qemuProcessShutdownOrReboot returns 'true' if the VM was termin= ated. + * If the VM is kept (e.g. for fake reboot) we need to continue the + * reconnection */ + if (qemuProcessShutdownOrReboot(obj)) + goto cleanup; } /* if domain requests security driver we haven't loaded, report error,= but diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 9f783790ac..426e11d79e 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -192,7 +192,8 @@ int qemuProcessKill(virDomainObj *vm, unsigned int flag= s); int qemuProcessFakeRebootViaRecreate(virDomainObj *vm, bool locked); -void qemuProcessShutdownOrReboot(virDomainObj *vm); +bool qemuProcessShutdownOrReboot(virDomainObj *vm) + G_GNUC_WARN_UNUSED_RESULT; void qemuProcessAutoDestroy(virDomainObj *dom, virConnectPtr conn); --=20 2.51.1