From nobody Mon Feb 9 22:39:08 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=1610639364; cv=none; d=zohomail.com; s=zohoarc; b=j6EI+lMzvkxe0yyO2LRuT5M9J9PYvbwD0YFlebd4g20AsK7MfqptUh+lLR2Fjn0juFLNutXEVzCK7ixz9J9hR8S2joPByBkMiFFZmAm9RexkHp+SFRhv2CgXVM00ysF8HvlJWQWydcYO+1NJDZMdKCzZHLdVkrgjSNKCaspipAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610639364; 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=iR6mpN6JQlOv+YSxhvafMHQDyRtw3t8nq8G7VprsFtI=; b=NUr7999Ubcdt2+eaj0pHS9MZ0BYZ9WIX57V8DtZ6uFg2Sno2tqgHLsgfemZlw/drS0KtWhAnOHxceTy9XL8dJaATGlCSa9rEbnvWsmvaVw5P2UtscRoxQqeKZDXIyAOFzdH7nQu+UC55IMbfztDjafnY1w+a/f2lVxT7Dn/6xA0= 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 1610639364562174.85149115704712; Thu, 14 Jan 2021 07:49:24 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.67257.119925 (Exim 4.92) (envelope-from ) id 1l04rp-0005Vu-RD; Thu, 14 Jan 2021 15:48:57 +0000 Received: by outflank-mailman (output) from mailman id 67257.119925; Thu, 14 Jan 2021 15:48:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l04rp-0005Vn-Nh; Thu, 14 Jan 2021 15:48:57 +0000 Received: by outflank-mailman (input) for mailman id 67257; Thu, 14 Jan 2021 15:48:56 +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 1l04iB-0002Sh-K6 for xen-devel@lists.xenproject.org; Thu, 14 Jan 2021 15:38:59 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2a398fed-cfbb-4ab9-bf50-64dde4240f45; Thu, 14 Jan 2021 15:38:11 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 5E7E8AF19; Thu, 14 Jan 2021 15:38:09 +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: 2a398fed-cfbb-4ab9-bf50-64dde4240f45 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=1610638689; 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=iR6mpN6JQlOv+YSxhvafMHQDyRtw3t8nq8G7VprsFtI=; b=XbzDZFd0H/6I9sGxRBGak3DJTRXlnHIsiqgnEL7dD44/DaKF9ly8emgcyBkBU2Plnee68h y+bVXn3MsG3bUFlhiN+lDKLS8aVfi/39bNH65B2UED0PJVu61kYqtlXTxIo3r3dm6/DRve LznHt8AAfW5Ij2b3/0tfjYzuC9hXqiw= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Ian Jackson , Wei Liu Subject: [PATCH v11 13/27] tools/xenstore: add the basic framework for doing the live update Date: Thu, 14 Jan 2021 16:37:49 +0100 Message-Id: <20210114153803.2591-14-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 the main framework for executing the live update. This for now only defines the basic execution steps with empty dummy functions. This final step returning means failure, as in case of success the new executable will have taken over. Signed-off-by: Juergen Gross --- V4: - const (Julien Grall) V11: - split lu_check_lu_allowed() - use delay_request() framework --- tools/xenstore/xenstored_control.c | 83 +++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/tools/xenstore/xenstored_control.c b/tools/xenstore/xenstored_= control.c index 2e0827b9ef..5193c55781 100644 --- a/tools/xenstore/xenstored_control.c +++ b/tools/xenstore/xenstored_control.c @@ -22,6 +22,7 @@ Interactive commands for Xen Store Daemon. #include #include #include +#include #include #include #include @@ -44,6 +45,11 @@ struct live_update { #endif =20 char *cmdline; + + /* Start parameters. */ + bool force; + unsigned int timeout; + time_t started_at; }; =20 static struct live_update *lu_status; @@ -304,9 +310,64 @@ static const char *lu_arch(const void *ctx, struct con= nection *conn, } #endif =20 +static bool lu_check_lu_allowed(void) +{ + return true; +} + +static const char *lu_reject_reason(const void *ctx) +{ + return "BUSY"; +} + +static const char *lu_dump_state(const void *ctx, struct connection *conn) +{ + return NULL; +} + +static const char *lu_activate_binary(const void *ctx) +{ + return "Not yet implemented."; +} + +static bool do_lu_start(struct delayed_request *req) +{ + time_t now =3D time(NULL); + const char *ret; + char *resp; + + if (!lu_check_lu_allowed()) { + if (now < lu_status->started_at + lu_status->timeout) + return false; + if (!lu_status->force) { + ret =3D lu_reject_reason(req); + goto out; + } + } + + /* Dump out internal state, including "OK" for live update. */ + ret =3D lu_dump_state(req->in, lu_status->conn); + if (!ret) { + /* Perform the activation of new binary. */ + ret =3D lu_activate_binary(req->in); + } + + /* We will reach this point only in case of failure. */ + out: + talloc_free(lu_status); + + resp =3D talloc_strdup(req->in, ret); + send_reply(lu_status->conn, XS_CONTROL, resp, strlen(resp) + 1); + + return true; +} + static const char *lu_start(const void *ctx, struct connection *conn, bool force, unsigned int to) { + const char *ret; + int rc =3D 0; + syslog(LOG_INFO, "live-update: start, force=3D%d, to=3D%u\n", force, to); =20 if (!lu_status || lu_status->conn !=3D conn) @@ -317,8 +378,24 @@ static const char *lu_start(const void *ctx, struct co= nnection *conn, return "Kernel not complete."; #endif =20 - /* Will be replaced by real live-update later. */ + lu_status->force =3D force; + lu_status->timeout =3D to; + lu_status->started_at =3D time(NULL); + + rc =3D delay_request(conn, conn->in, do_lu_start, NULL); + + /* Dump out internal state, including "OK" for live update. */ + ret =3D lu_dump_state(ctx, conn); + if (ret) + goto out; + + /* Perform the activation of new binary. */ + ret =3D lu_activate_binary(ctx); + /* We will reach this point only in case of failure. */ + + out: talloc_free(lu_status); + errno =3D rc; =20 return NULL; } @@ -356,6 +433,10 @@ static int do_control_lu(void *ctx, struct connection = *conn, return EINVAL; } ret =3D lu_start(ctx, conn, force, to); + if (errno) + return errno; + if (!ret) + return 0; } else { errno =3D 0; ret =3D lu_arch(ctx, conn, vec, num); --=20 2.26.2