From nobody Wed Dec 4 18:55:59 2024 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 1716532589862125.44927170406402; Thu, 23 May 2024 23:36:29 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D56711A6F; Fri, 24 May 2024 02:36:28 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 45FF51B68; Fri, 24 May 2024 02:27:03 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id CA6ED1C40; Fri, 24 May 2024 02:26:52 -0400 (EDT) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 A090E1B63 for ; Fri, 24 May 2024 02:26:01 -0400 (EDT) Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2024 23:24:59 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2024 23:24:57 -0700 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, 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=1716531962; x=1748067962; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4ZNbYEs8F3uY5hXAxzpw2goYosoheWsngMdlpvbqayw=; b=Tu+XLWnbP/UICX0m/w82Ms3csgaLCFl3/2vFUsOFT81cCeqkHvRScRDt Jh7sdOCMuM6fd8fauLkMM9lSQ3olbXu/u1W4E5tPorkfMGAf17FzDLjnG w9KRr7xDBuOjcUQVZgPrVUKcybih5SYpwZLBU6vOHh86tpvD8F2JWPiaW IzaYbD85cmiKkWAjFNpzpCckLcErHVyfi+Wb4qXI0XhQWMXUmw2bQQxBG GlBn8XO4CBuch7VYADJm97ZR8ngAwcW2QJolde4v+abhQUR6hxYBsAMpZ g/Z6UaZHyCjlQktSDRjEqth5o8PpZhmFsbntwLXhD7g5nXkXUxE0lK8Wc w==; X-CSE-ConnectionGUID: 40XnJi9pQfue2VRWLSszdQ== X-CSE-MsgGUID: B07rA5cdRMaWowRPDo6YOQ== X-IronPort-AV: E=McAfee;i="6600,9927,11081"; a="13081290" X-IronPort-AV: E=Sophos;i="6.08,184,1712646000"; d="scan'208";a="13081290" X-CSE-ConnectionGUID: wqbVPEs6Ru2aktWFU3+E1g== X-CSE-MsgGUID: 0ARj4BxYSF6DjgNkAB35HA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,184,1712646000"; d="scan'208";a="34034049" From: Zhenzhong Duan To: devel@lists.libvirt.org Subject: [PATCH rfcv4 11/13] qemu: Avoid duplicate FakeReboot for secure guest Date: Fri, 24 May 2024 14:21:26 +0800 Message-Id: <20240524062128.523820-12-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524062128.523820-1-zhenzhong.duan@intel.com> References: <20240524062128.523820-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JUXEN4CSXCEKI536NCGAP5EQXOV2XNMQ X-Message-ID-Hash: JUXEN4CSXCEKI536NCGAP5EQXOV2XNMQ 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: 1716532591219100001 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 is originally come 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 7f7053054f..3aadd89aec 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1075,6 +1075,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