From nobody Sun Feb 8 19:59:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1664247892041848.2629348587474; Mon, 26 Sep 2022 20:04:52 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.412199.655451 (Exim 4.92) (envelope-from ) id 1od0tP-0003Zw-Ag; Tue, 27 Sep 2022 03:04:19 +0000 Received: by outflank-mailman (output) from mailman id 412199.655451; Tue, 27 Sep 2022 03:04:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1od0tP-0003Zn-7k; Tue, 27 Sep 2022 03:04:19 +0000 Received: by outflank-mailman (input) for mailman id 412199; Tue, 27 Sep 2022 03:04:17 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1od0tN-0002Wn-N3 for xen-devel@lists.xenproject.org; Tue, 27 Sep 2022 03:04:17 +0000 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 126bfb2c-3e11-11ed-9648-05401a9f4f97; Tue, 27 Sep 2022 05:04:16 +0200 (CEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 16DCB5C0194; Mon, 26 Sep 2022 23:04:16 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 26 Sep 2022 23:04:16 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 26 Sep 2022 23:04:15 -0400 (EDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 126bfb2c-3e11-11ed-9648-05401a9f4f97 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= invisiblethingslab.com; h=cc:cc:content-transfer-encoding:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1664247856; x=1664334256; bh=bVEPwgLcbq+BZ1Wl7+Gkkocayb9AhcjX3Ls ejAExFkI=; b=l6pbj9Ojnwg8wA/IiuSwALGS1l2xZ96b9R4dZqI0hqOuZ/5OY0g kTlBJQYsnb+cxSvycEQ17gAu1FgbAdYqUamg6htQEGYbsAh8AR8rTNoKdRzMBRNv +0QUGyjcFZiqxOUlZWWHHbuSCbD93kPoDegn48lISK9pB16bFhiLaB3S3UlCF8Yu 0HPsB+PDaAsfzkG0Jzlpsqv/VqNWdw1mFleGfIV8iXesOh/SiRipJ4qmV29DO0Pa QqR4Fw459OOPbRKWyGAPHm+K91VB9Tz+ez73AhHS+6q3CL8v7y0qVIZoTst91RcF z+sGiQzMo8wJpz9QvWIiimER20QdGq7Z5Ig== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1664247856; x=1664334256; bh=bVEPwgLcbq+BZ 1Wl7+Gkkocayb9AhcjX3LsejAExFkI=; b=ZmdooMZN0BCcdS/rDTwwrNLYEIBCV 0lTv4hGq2wWwci8x0r2+eVV7S/+Um2jMRxBJDwaseF+KWXqz5hod6u2wpnrBoZ/W DDlczt0ztAp7Q8iRdfZhH+T4meVjgOihkZrPC2CmAbPLfnrcLX5FXyjx+a5yYFUq eivnM2evkO1wAdSzAS8RaINXWYlXfs694urDS1MVdDdhV1NHBeIqouALQUqd2GTT tEBrFIxstOS23ilk/TAMNmXYzETbPyQwVfLFPBeidoXtGX4ux+FtCEKWjc2DECRm 7cVq3PwOAlUCnQZECEeuYbAyOBUuZXN9URGIcYELXY9QVkRVLpPdOS9fw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeegfedgieelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepffgvmhhi ucforghrihgvucfqsggvnhhouhhruceouggvmhhisehinhhvihhsihgslhgvthhhihhngh hslhgrsgdrtghomheqnecuggftrfgrthhtvghrnhepjeffjefggfeugeduvedvjeekgfeh gffhhfffjeetkeelueefffetfffhtdduheetnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepuggvmhhisehinhhvihhsihgslhgvthhhihhnghhs lhgrsgdrtghomh X-ME-Proxy: Feedback-ID: iac594737:Fastmail From: Demi Marie Obenour To: xen-devel@lists.xenproject.org Cc: Demi Marie Obenour , Wei Liu , Anthony PERARD , Juergen Gross Subject: [PATCH 4/5] libxl: Fix race condition in domain suspension Date: Mon, 26 Sep 2022 23:04:00 -0400 Message-Id: X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1664247893534100009 Content-Type: text/plain; charset="utf-8" Check if the domain has suspended after setting the XenStore watch to prevent race conditions. Also check if a guest has suspended when the timeout handler is called, and do not consider this to be a timeout. Signed-off-by: Demi Marie Obenour --- tools/libs/light/libxl_dom_suspend.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/libs/light/libxl_dom_suspend.c b/tools/libs/light/libxl_= dom_suspend.c index d276b3c17e70105c19c82e9da570a24297d039f5..42c0e0a152e04fab34152d71156= 4ffe148f24a4c 100644 --- a/tools/libs/light/libxl_dom_suspend.c +++ b/tools/libs/light/libxl_dom_suspend.c @@ -209,7 +209,8 @@ static void domain_suspend_common_wait_guest_evtchn(lib= xl__egc *egc, libxl__ev_evtchn *evev); static void suspend_common_wait_guest_watch(libxl__egc *egc, libxl__ev_xswatch *xsw, const char *watch_path, const char *event_pa= th); -static void suspend_common_wait_guest_check(libxl__egc *egc, +/* Returns true if a callback was called, false otherwise */ +static bool suspend_common_wait_guest_check(libxl__egc *egc, libxl__domain_suspend_state *dsps); static void suspend_common_wait_guest_timeout(libxl__egc *egc, libxl__ev_time *ev, const struct timeval *requested_abs, int rc); @@ -426,7 +427,7 @@ static int check_guest_status(libxl__gc *gc, const uint= 32_t domid, return 0; } =20 -static void suspend_common_wait_guest_check(libxl__egc *egc, +static bool suspend_common_wait_guest_check(libxl__egc *egc, libxl__domain_suspend_state *dsps) { STATE_AO_GC(dsps->ao); @@ -441,7 +442,7 @@ static void suspend_common_wait_guest_check(libxl__egc = *egc, =20 if (!(info.flags & XEN_DOMINF_shutdown)) /* keep waiting */ - return; + return false; =20 shutdown_reason =3D (info.flags >> XEN_DOMINF_shutdownshift) & XEN_DOMINF_shutdownmask; @@ -452,11 +453,15 @@ static void suspend_common_wait_guest_check(libxl__eg= c *egc, } =20 LOGD(DEBUG, domid, "guest has suspended"); + dsps->guest_responded =3D 1; + libxl__xswait_stop(gc, &dsps->pvcontrol); domain_suspend_common_guest_suspended(egc, dsps); - return; + return true; =20 err: + libxl__xswait_stop(gc, &dsps->pvcontrol); domain_suspend_common_done(egc, dsps, ERROR_FAIL); + return true; } =20 static void suspend_common_wait_guest_timeout(libxl__egc *egc, @@ -464,6 +469,8 @@ static void suspend_common_wait_guest_timeout(libxl__eg= c *egc, { libxl__domain_suspend_state *dsps =3D CONTAINER_OF(ev, *dsps, guest_ti= meout); STATE_AO_GC(dsps->ao); + if (suspend_common_wait_guest_check(egc, dsps)) + return; if (rc =3D=3D ERROR_TIMEDOUT) { LOGD(ERROR, dsps->domid, "guest did not suspend, timed out"); rc =3D ERROR_GUEST_TIMEDOUT; --=20 Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab