From nobody Tue Sep 9 19:03:24 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 1752132626151267.4085526040727; Thu, 10 Jul 2025 00:30:26 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 2C1A4C2E; Thu, 10 Jul 2025 03:30:25 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 78E93141D; Thu, 10 Jul 2025 03:23:36 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E2B8011C7; Thu, 10 Jul 2025 03:23:19 -0400 (EDT) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 462F41172 for ; Thu, 10 Jul 2025 03:22:53 -0400 (EDT) Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jul 2025 00:22:47 -0700 Received: from unknown (HELO gnr-sp-2s-612.sh.intel.com) ([10.112.230.229]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jul 2025 00:22:44 -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.0 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=1752132173; x=1783668173; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kE2fvaHv9qzStO5CJjaK81HMS9jDgEVDkWRp5gtdSHk=; b=HbLW4KUmueGtIyG4KGyJn9e2IFF4xETswerwaFb7kDqLtUYIACZrgiF1 GtFxHvPM4vhf69pGno11Vr1VbEGhJ0a7/ESlPKeZGebX45bZ6plGP8RmE pHKlhBN5L0cScgBAHkHB0GWfbBZAP00Eh4Y9OeN3FzKUc0eR4963yzbMb 3ck80JGHdkYGnuaoVGA7uFQ+nYE2FwW1mhY0TIPyZ4rv1W65swbQDu8fB kPSbRg5WwybLmXBAVLyowSF1TmAHrd+ZWZb3N+SwoflOtlZiGMhs8dWtZ /y+0YetpflhQdAjmWDQUKVJHvMGpAfpG9kppaMCugkGIpzp5569De2x0G w==; X-CSE-ConnectionGUID: PG9MdXt4TvanBaCbmrvw0w== X-CSE-MsgGUID: 7/kRt5ZpRVGzISj6XEKzsw== X-IronPort-AV: E=McAfee;i="6800,10657,11489"; a="54257169" X-IronPort-AV: E=Sophos;i="6.16,300,1744095600"; d="scan'208";a="54257169" X-CSE-ConnectionGUID: DFugmTL0Sz+iomYRMiV66Q== X-CSE-MsgGUID: BFG8r3d8QxarOyJgJi5M6g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,300,1744095600"; d="scan'208";a="186997225" From: Zhenzhong Duan To: devel@lists.libvirt.org Subject: [PATCH v4 18/23] qemu: Avoid duplicate FakeReboot for secure guest Date: Thu, 10 Jul 2025 03:21:20 -0400 Message-ID: <20250710072127.695558-19-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250710072127.695558-1-zhenzhong.duan@intel.com> References: <20250710072127.695558-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 2GIX7JRYQGBGHPG4RZ3TMK2RUTB3CSTR X-Message-ID-Hash: 2GIX7JRYQGBGHPG4RZ3TMK2RUTB3CSTR 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: 1752132627725116600 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 6d984df412..d726175d42 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.47.1