From nobody Wed Dec 17 03:40:20 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 header.i=@intel.com; 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=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1750845596166964.598096731916; Wed, 25 Jun 2025 02:59:56 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 2B974145C; Wed, 25 Jun 2025 05:59:55 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 8CA6914C9; Wed, 25 Jun 2025 05:52:03 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4A3A11482; Wed, 25 Jun 2025 05:51:54 -0400 (EDT) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 A1A6214AB for ; Wed, 25 Jun 2025 05:51:21 -0400 (EDT) Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2025 02:50:15 -0700 Received: from spr-s2600bt.bj.intel.com ([10.240.192.127]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2025 02:50:11 -0700 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, 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/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1750845081; x=1782381081; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qAVSswuSDh9SiL3XDB2zPWPb6TabA+WAQRh7OG/NIyg=; b=MILOPZOp3SfFA1Dk2n+nrearI6XerQRpMm6MRwao8KL2TNTHhvqdb30v Z1vAc7zkQN9LmQXto7GJ7HWsQGd/0mBFatIc3AbvsaLwHOXXOXMw703dK 4abWl5jop9+/0EYt8lPZj/1xznqvVQ90n95BD6fdCYiWwoSIT7K1q/q+B 94qcgPE6g/H96E6cQuMqKypz4PNcx5IDMihSeKnajmawpGrlm5ObkeMog BY40JjQYzNmC3zbDcMgEeAUrm1CidpPV8syxLkN3LQPkNbj5r0mjGX3dk X0eFqUuU/l7UJ1vDmfqavm2henYtJYCOEB8k9bUtbnpGLq/9+XOIxC7ji A==; X-CSE-ConnectionGUID: h09HVbcdTdSycboB2DiOEg== X-CSE-MsgGUID: ROWmojT8SjKHK678aVeBiA== X-IronPort-AV: E=McAfee;i="6800,10657,11474"; a="70680414" X-IronPort-AV: E=Sophos;i="6.16,264,1744095600"; d="scan'208";a="70680414" X-CSE-ConnectionGUID: ywkysMVvR+C5uDxStu/YIQ== X-CSE-MsgGUID: EQwytsH4TyWYHP9lZOD30w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,264,1744095600"; d="scan'208";a="151787075" From: Zhenzhong Duan To: devel@lists.libvirt.org Subject: [PATCH v2 14/21] qemu: Avoid duplicate FakeReboot for secure guest Date: Wed, 25 Jun 2025 17:45:26 +0800 Message-Id: <20250625094533.234897-15-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250625094533.234897-1-zhenzhong.duan@intel.com> References: <20250625094533.234897-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: YKJQKEX5I5ZDE3FV4M3O7UTYRKMDNKAE X-Message-ID-Hash: YKJQKEX5I5ZDE3FV4M3O7UTYRKMDNKAE X-MailFrom: zhenzhong.duan@intel.com X-Mailman-Rule-Hits: nonmember-moderation 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 CC: phrdina@redhat.com, pkrempa@redhat.com, jjongsma@redhat.com, jsuchane@redhat.com, chenyi.qiang@intel.com, isaku.yamahata@intel.com, xiaoyao.li@intel.com, chao.p.peng@intel.com, Zhenzhong Duan 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: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1750845596830116600 Content-Type: text/plain; charset="utf-8" For secure guest, FakeReboot kills original QEMU instance and create new one. During this process, QEMU send SHUTDOWN event with "host-signal" reason which can trigger another FakeReboot. Check if a FakeReboot is ongoing and bypass "host-signal" processing which originally comes from FakeReboot. Signed-off-by: Zhenzhong Duan Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_monitor.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 1608fa86cd..ae3b13cdb2 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1073,6 +1073,16 @@ qemuMonitorEmitShutdown(qemuMonitor *mon, virTristat= eBool guest, * with it here. */ if (vm->def->sec && vm->def->sec->sectype =3D=3D VIR_DOMAIN_LAUNCH_SECURITY_TDX) { + qemuDomainObjPrivate *priv =3D vm->privateData; + + /* For secure guest, FakeReboot kills original QEMU instance and + * create new one. During this process, QEMU send SHUTDOWN event + * with "host-signal" reason which can trigger another FakeReboot. + * Check if a FakeReboot is ongoing and bypass "host-signal" + * processing which is originally come from FakeReboot. */ + if (priv->fakeReboot && STREQ_NULLABLE(reason, "host-signal")) + return; + if ((STREQ_NULLABLE(reason, "guest-shutdown") && vm->def->onPoweroff =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTAR= T) || (STREQ_NULLABLE(reason, "guest-reset") && --=20 2.34.1