From nobody Mon Feb 9 01:30:39 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; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1608054029; cv=none; d=zohomail.com; s=zohoarc; b=VAJrdT1NWiEsUlmFywlBBTq899pCBt6vuhOskk+Cs89BO0KnSgMtVbHLhh8Ncl7YVj5qrxtRqLAtxi0XSfAdKPk3fnKzEKt25mpsGYzZqpFt3DAJq+//riavGtBc+M129LFD4bsGx74JlBkBC8hmePPyWvB80NYrYmc0Ct7gfHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608054029; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FspAu+0zxN5f+kBxTUaFqpiXMEMEL35uaqc65DYbH+U=; b=IuA2XGyTN/Uj0YbMMszCwSIATFBjXwujz/Xc2hVBGp1G3ybMI4H0c0NpYasvYzfE6vAusaakMPxGiK48+vFKT35XePOxQqsTa5HlKhkBNKna5SsoXfTaKiY7Fzx+Xr5eaPj36aeQI7Xfa3+Nc9S8oMorB1UizsduEv4wOv2ebNM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1608054029619260.28591645878294; Tue, 15 Dec 2020 09:40:29 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.54669.95155 (Exim 4.92) (envelope-from ) id 1kpDTJ-0001m3-Oa; Tue, 15 Dec 2020 16:46:45 +0000 Received: by outflank-mailman (output) from mailman id 54669.95155; Tue, 15 Dec 2020 16:46:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kpDTJ-0001lw-Ld; Tue, 15 Dec 2020 16:46:45 +0000 Received: by outflank-mailman (input) for mailman id 54669; Tue, 15 Dec 2020 16:46:45 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kpDJt-00066M-Ib for xen-devel@lists.xenproject.org; Tue, 15 Dec 2020 16:37:01 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ef3335b5-2c28-45c3-b9c3-4c4ff1e53e81; Tue, 15 Dec 2020 16:36:15 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id AA173B712; Tue, 15 Dec 2020 16:36:12 +0000 (UTC) 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: ef3335b5-2c28-45c3-b9c3-4c4ff1e53e81 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1608050172; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FspAu+0zxN5f+kBxTUaFqpiXMEMEL35uaqc65DYbH+U=; b=WYjMGffV3cHOlieIVijpD/JpBAYGwjWoFeZF+pBfxCAeriK5IAr+ISrP0xfa/hcw6SuHCt jVVXGRZY/WKCML5J9L3bMHYydkYN5FEnpFZdSTQM+vHbq/qv1JjkYMn4SgqMgGmGZVsbCt kV3F5wAAexfDePQ4yB2IC1tJrdS4XMI= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Julien Grall , Ian Jackson , Wei Liu , Juergen Gross , Paul Durrant Subject: [PATCH v10 24/25] tools/xenstore: handle dying domains in live update Date: Tue, 15 Dec 2020 17:36:02 +0100 Message-Id: <20201215163603.21700-25-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201215163603.21700-1-jgross@suse.com> References: <20201215163603.21700-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" From: Julien Grall A domain could just be dying when live updating Xenstore, so the case of not being able to map the ring page or to connect to the event channel must be handled gracefully. Signed-off-by: Julien Grall Reviewed-by: Paul Durrant --- V4: - new patch (Julien, I hope adding the Sob: is okay?) V10: - removed "XXX..." comment (Julien Grall) Signed-off-by: Juergen Gross --- tools/xenstore/xenstored_control.c | 7 +++++++ tools/xenstore/xenstored_domain.c | 25 +++++++++++++++++-------- tools/xenstore/xenstored_domain.h | 2 ++ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/tools/xenstore/xenstored_control.c b/tools/xenstore/xenstored_= control.c index 8a1e3b35fe..dee55de264 100644 --- a/tools/xenstore/xenstored_control.c +++ b/tools/xenstore/xenstored_control.c @@ -544,6 +544,13 @@ void lu_read_state(void) lu_close_dump_state(&state); =20 talloc_free(ctx); + + /* + * We may have missed the VIRQ_DOM_EXC notification and a domain may + * have died while we were live-updating. So check all the domains are + * still alive. + */ + check_domains(true); } =20 static const char *lu_activate_binary(const void *ctx) diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_d= omain.c index 0cd8234bd1..dfda90c791 100644 --- a/tools/xenstore/xenstored_domain.c +++ b/tools/xenstore/xenstored_domain.c @@ -220,7 +220,7 @@ static bool get_domain_info(unsigned int domid, xc_domi= nfo_t *dominfo) dominfo->domid =3D=3D domid; } =20 -static void domain_cleanup(void) +void check_domains(bool restore) { xc_dominfo_t dominfo; struct domain *domain; @@ -244,7 +244,14 @@ static void domain_cleanup(void) domain->shutdown =3D true; notify =3D 1; } - if (!dominfo.dying) + /* + * On Restore, we may have been unable to remap the + * interface and the port. As we don't know whether + * this was because of a dying domain, we need to + * check if the interface and port are still valid. + */ + if (!dominfo.dying && domain->port && + domain->interface) continue; } if (domain->conn) { @@ -270,7 +277,7 @@ void handle_event(void) barf_perror("Failed to read from event fd"); =20 if (port =3D=3D virq_port) - domain_cleanup(); + check_domains(false); =20 if (xenevtchn_unmask(xce_handle, port) =3D=3D -1) barf_perror("Failed to write to event fd"); @@ -442,14 +449,16 @@ static struct domain *introduce_domain(const void *ct= x, if (!domain->introduced) { interface =3D is_master_domain ? xenbus_map() : map_interface(domid); - if (!interface) + if (!interface && !restore) return NULL; if (new_domain(domain, port, restore)) { rc =3D errno; - if (is_master_domain) - unmap_xenbus(interface); - else - unmap_interface(interface); + if (interface) { + if (is_master_domain) + unmap_xenbus(interface); + else + unmap_interface(interface); + } errno =3D rc; return NULL; } diff --git a/tools/xenstore/xenstored_domain.h b/tools/xenstore/xenstored_d= omain.h index 8f3b4e0f8b..1cc1c03ed8 100644 --- a/tools/xenstore/xenstored_domain.h +++ b/tools/xenstore/xenstored_domain.h @@ -21,6 +21,8 @@ =20 void handle_event(void); =20 +void check_domains(bool restore); + /* domid, mfn, eventchn, path */ int do_introduce(struct connection *conn, struct buffered_data *in); =20 --=20 2.26.2