From nobody Mon Feb 9 22:39:11 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=1610639422; cv=none; d=zohomail.com; s=zohoarc; b=FCHDie0cnJfNMjYDdtl9xr6PN7vShlxZ6+1rhG1X3y9Gj4i2mp2yyLoY3/7T1ZXqnfz5BvMh31un4xIrBUkox1t1xwth4AldtaMGB+/YSJjU4j1iSlAKEI4FSaoGWjev5XNC0IMN3zkfvACRUFlgP7qs5HVtIGe1nu+HfvLeV6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610639422; 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=slP8ly01gF/AGpapuBih7H1vDBntjiFHvZ8tgMRiyM0=; b=dFoWc+bO6+LrgYM7HGJrn9cV6lSYh+zhvvj38ljDktpYDeGu1eCzlF6qCACwNYD9L2EfekCyE0E4iYWJEzLPl6Km18hQnsldBBj/uI+KxOlTbNxTeau3cmMwFAqMmtTR5/6ADZoikcaOcl24RMyfy87ngjvRjzRnSxnELR0f7VA= 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 1610639422377597.7263411940869; Thu, 14 Jan 2021 07:50:22 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.67281.119961 (Exim 4.92) (envelope-from ) id 1l04sv-0006Wv-TL; Thu, 14 Jan 2021 15:50:05 +0000 Received: by outflank-mailman (output) from mailman id 67281.119961; Thu, 14 Jan 2021 15:50:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l04sv-0006Wn-OL; Thu, 14 Jan 2021 15:50:05 +0000 Received: by outflank-mailman (input) for mailman id 67281; Thu, 14 Jan 2021 15:50:04 +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 1l04ip-0002Sh-LP for xen-devel@lists.xenproject.org; Thu, 14 Jan 2021 15:39:39 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 4ebe08d5-f8f5-4d26-9036-fe714f229409; Thu, 14 Jan 2021 15:38:14 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 23572AF37; Thu, 14 Jan 2021 15:38: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: 4ebe08d5-f8f5-4d26-9036-fe714f229409 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=1610638692; 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=slP8ly01gF/AGpapuBih7H1vDBntjiFHvZ8tgMRiyM0=; b=F75voBapIN3se+kN46W+BIEtJzJV+A3E5E6AA12WXPyx7FERTltRX/g+PHZQROt4aAfd/a W9VMpIl6am75AYgySSFRtIkV5W4fFh0AH6EpCDWW/LGoP1IsFVvGh9zNh2l7EKbxZtgw/l M0FCSgNHFeMsmadoWIUxFDyToZkIYzA= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Ian Jackson , Wei Liu Subject: [PATCH v11 27/27] tools/xenstore: activate new binary for live update Date: Thu, 14 Jan 2021 16:38:03 +0100 Message-Id: <20210114153803.2591-28-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210114153803.2591-1-jgross@suse.com> References: <20210114153803.2591-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" Add activation of the new binary for live update. The daemon case is handled completely, while for stubdom we only add stubs. Signed-off-by: Juergen Gross --- V7: - added unbinding dom0 and virq event channels V8: - no longer close dom0 evtchn (Julien Grall) V10: - remember original argc and argv (taken from deleted patch) --- tools/xenstore/xenstored_control.c | 61 +++++++++++++++++++++++++++++- tools/xenstore/xenstored_core.c | 5 +++ tools/xenstore/xenstored_core.h | 3 ++ tools/xenstore/xenstored_domain.c | 6 +++ tools/xenstore/xenstored_domain.h | 1 + 5 files changed, 75 insertions(+), 1 deletion(-) diff --git a/tools/xenstore/xenstored_control.c b/tools/xenstore/xenstored_= control.c index 900b82bd40..906beae1f9 100644 --- a/tools/xenstore/xenstored_control.c +++ b/tools/xenstore/xenstored_control.c @@ -16,6 +16,7 @@ Interactive commands for Xen Store Daemon. along with this program; If not, see . */ =20 +#include #include #include #include @@ -335,6 +336,11 @@ static void lu_get_dump_state(struct lu_dump_state *st= ate) static void lu_close_dump_state(struct lu_dump_state *state) { } + +static char *lu_exec(const void *ctx, int argc, char **argv) +{ + return "NYI"; +} #else static const char *lu_binary(const void *ctx, struct connection *conn, const char *filename) @@ -434,6 +440,14 @@ static void lu_close_dump_state(struct lu_dump_state *= state) unlink(filename); talloc_free(filename); } + +static char *lu_exec(const void *ctx, int argc, char **argv) +{ + argv[0] =3D lu_status->filename; + execvp(argv[0], argv); + + return "Error activating new binary."; +} #endif =20 static bool lu_check_lu_allowed(void) @@ -572,7 +586,52 @@ void lu_read_state(void) =20 static const char *lu_activate_binary(const void *ctx) { - return "Not yet implemented."; + int argc; + char **argv; + unsigned int i; + + if (lu_status->cmdline) { + argc =3D 4; /* At least one arg + progname + "-U" + NULL. */ + for (i =3D 0; lu_status->cmdline[i]; i++) + if (isspace(lu_status->cmdline[i])) + argc++; + argv =3D talloc_array(ctx, char *, argc); + if (!argv) + return "Allocation failure."; + + i =3D 0; + argc =3D 1; + argv[1] =3D strtok(lu_status->cmdline, " \t"); + while (argv[argc]) { + if (!strcmp(argv[argc], "-U")) + i =3D 1; + argc++; + argv[argc] =3D strtok(NULL, " \t"); + } + + if (!i) { + argv[argc++] =3D "-U"; + argv[argc] =3D NULL; + } + } else { + for (i =3D 0; i < orig_argc; i++) + if (!strcmp(orig_argv[i], "-U")) + break; + + argc =3D orig_argc; + argv =3D talloc_array(ctx, char *, orig_argc + 2); + if (!argv) + return "Allocation failure."; + + memcpy(argv, orig_argv, orig_argc * sizeof(*argv)); + if (i =3D=3D orig_argc) + argv[argc++] =3D "-U"; + argv[argc] =3D NULL; + } + + domain_deinit(); + + return lu_exec(ctx, argc, argv); } =20 static bool do_lu_start(struct delayed_request *req) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_cor= e.c index 3e133b475c..f6980478dd 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -73,6 +73,9 @@ static unsigned int delayed_requests; =20 static int sock =3D -1; =20 +int orig_argc; +char **orig_argv; + static bool verbose =3D false; LIST_HEAD(connections); int tracefd =3D -1; @@ -2070,6 +2073,8 @@ int main(int argc, char *argv[]) const char *pidfile =3D NULL; int timeout; =20 + orig_argc =3D argc; + orig_argv =3D argv; =20 while ((opt =3D getopt_long(argc, argv, "DE:F:HNPS:t:A:M:T:RVW:U", option= s, NULL)) !=3D -1) { diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_cor= e.h index 6ac5a6fbfa..589699e833 100644 --- a/tools/xenstore/xenstored_core.h +++ b/tools/xenstore/xenstored_core.h @@ -222,6 +222,9 @@ void dtrace_io(const struct connection *conn, const str= uct buffered_data *data, void reopen_log(void); void close_log(void); =20 +extern int orig_argc; +extern char **orig_argv; + extern char *tracefile; extern int tracefd; =20 diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_d= omain.c index cbeb2a309c..3d4d0649a2 100644 --- a/tools/xenstore/xenstored_domain.c +++ b/tools/xenstore/xenstored_domain.c @@ -783,6 +783,12 @@ void domain_init(int evtfd) virq_port =3D rc; } =20 +void domain_deinit(void) +{ + if (virq_port) + xenevtchn_unbind(xce_handle, virq_port); +} + void domain_entry_inc(struct connection *conn, struct node *node) { struct domain *d; diff --git a/tools/xenstore/xenstored_domain.h b/tools/xenstore/xenstored_d= omain.h index 1cc1c03ed8..dc97591713 100644 --- a/tools/xenstore/xenstored_domain.h +++ b/tools/xenstore/xenstored_domain.h @@ -46,6 +46,7 @@ int do_reset_watches(struct connection *conn, struct buff= ered_data *in); =20 void domain_init(int evtfd); void dom0_init(void); +void domain_deinit(void); =20 /* Returns the implicit path of a connection (only domains have this) */ const char *get_implicit_path(const struct connection *conn); --=20 2.26.2