From nobody Thu Oct 30 23:13:07 2025 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=1753449597; cv=none; d=zohomail.com; s=zohoarc; b=kpJSlXkojOKCAeacysIBdxlVFWK465wgGlb8WBr3eoMarFbpSjPr9jaQLEtfGnFpBVom1+pI9bZxLE9D8Onq+OoJvqkbXPGCi0JsLYYI8AHzKZP4PTRsiswpSKJHfa71rbmHOs3BZooT0UXJI7ShedxGyAgnuWh9e/TQXx/HNQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753449597; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BjaK3DHae0L+tvH83IKYZFxcoyYS5iwSjWvHNKFN12w=; b=OayRfrAFQRPWKEzr7HQ9YH1+RBHkk+xXeMRPlH7UtPBvXaENcO3jy4xDSl8xRDAaNBN7l+vf3F7iUzlWREiVp15jRtzgzEGFNxR8wDju2NraYmwgUytAG1Xp+RE1h8k+CR5Pe4AoCJrzO5b9gdH5R09p4uRgmCdV4DTsEQGvcC0= 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) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1753449597242965.2289019130476; Fri, 25 Jul 2025 06:19:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1057791.1425502 (Exim 4.92) (envelope-from ) id 1ufIKw-0007C3-3s; Fri, 25 Jul 2025 13:19:46 +0000 Received: by outflank-mailman (output) from mailman id 1057791.1425502; Fri, 25 Jul 2025 13:19:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ufIKw-0007Bu-1G; Fri, 25 Jul 2025 13:19:46 +0000 Received: by outflank-mailman (input) for mailman id 1057791; Fri, 25 Jul 2025 13:19:45 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ufIKu-0007Aq-VV for xen-devel@lists.xenproject.org; Fri, 25 Jul 2025 13:19:44 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 068493ed-695a-11f0-b895-0df219b8e170; Fri, 25 Jul 2025 15:19:42 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 561D92170E; Fri, 25 Jul 2025 13:19:42 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 275E2134E8; Fri, 25 Jul 2025 13:19:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id HVQ2CG6Eg2jYPAAAD6G6ig (envelope-from ); Fri, 25 Jul 2025 13:19:42 +0000 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: 068493ed-695a-11f0-b895-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1753449582; 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=BjaK3DHae0L+tvH83IKYZFxcoyYS5iwSjWvHNKFN12w=; b=u63xHcK9oTeHakB3sAW52n2jzfehuPFKbkUx6X/FEavtXOSfFOyOh0XJgVCMdlOhp9LEo1 JBFooOCjpDfOn7sZF3zMgIVR8zc8Zt3fp2OOOSQf+hXhJkTasUcfHP2+79ocwFXkoBWBT4 zl3YtdGrhZajsDtFEaFFL4bHxDUmJlg= Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1753449582; 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=BjaK3DHae0L+tvH83IKYZFxcoyYS5iwSjWvHNKFN12w=; b=u63xHcK9oTeHakB3sAW52n2jzfehuPFKbkUx6X/FEavtXOSfFOyOh0XJgVCMdlOhp9LEo1 JBFooOCjpDfOn7sZF3zMgIVR8zc8Zt3fp2OOOSQf+hXhJkTasUcfHP2+79ocwFXkoBWBT4 zl3YtdGrhZajsDtFEaFFL4bHxDUmJlg= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Julien Grall , Anthony PERARD , Jason Andryuk Subject: [PATCH v2 2/7] tools/xenstored: support specification of migration stream version Date: Fri, 25 Jul 2025 15:19:23 +0200 Message-ID: <20250725131928.19286-3-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250725131928.19286-1-jgross@suse.com> References: <20250725131928.19286-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:helo]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Level: X-Spam-Score: -2.80 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1753449599469116600 Content-Type: text/plain; charset="utf-8" In order to prepare xenstored supporting migration stream versions other than 1, add a parameter to the live update command allowing to specify the version of the migration stream. This will allow going back from xenstored using version 2 per default to a xenstored only accepting version 1. For now only version 1 is supported. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- tools/xenstored/control.c | 6 ++--- tools/xenstored/lu.c | 21 ++++++++++----- tools/xenstored/lu.h | 1 + tools/xs-clients/xenstore_control.c | 41 ++++++++++++++++++++++------- 4 files changed, 50 insertions(+), 19 deletions(-) diff --git a/tools/xenstored/control.c b/tools/xenstored/control.c index 9561289179..953c01b735 100644 --- a/tools/xenstored/control.c +++ b/tools/xenstored/control.c @@ -289,7 +289,7 @@ static struct cmd_s cmds[] =3D { * Mini-OS: -b * -d (multiple of those) * 2. New command-line (optional): -c - * 3. Start of update: -s [-F] [-t ] + * 3. Start of update: -s [-F] [-t ] [-v ] * Any sub-operation needs to respond with the string "OK" in case * of success, any other response indicates failure. * A started live-update sequence can be aborted via "-a" (not @@ -297,8 +297,8 @@ static struct cmd_s cmds[] =3D { * sub-operation). */ { "live-update", do_control_lu, - "[-c ] [-F] [-t ] \n" - " Default timeout is 60 seconds.", 5 }, + "[-c ] [-F] [-t ] [-v ] \n" + " Default timeout is 60 seconds, default version is 1.", 7 }, #endif { "logfile", do_control_logfile, "" }, { "memreport", do_control_memreport, "[]" }, diff --git a/tools/xenstored/lu.c b/tools/xenstored/lu.c index 4fccbbc195..330820a8a2 100644 --- a/tools/xenstored/lu.c +++ b/tools/xenstored/lu.c @@ -283,7 +283,7 @@ static const char *lu_dump_state(const void *ctx, struc= t connection *conn) return "Dump state open error"; =20 memcpy(pre.ident, XS_STATE_IDENT, sizeof(pre.ident)); - pre.version =3D htobe32(XS_STATE_VERSION); + pre.version =3D htobe32(lu_status->version); pre.flags =3D XS_STATE_FLAGS; if (fwrite(&pre, sizeof(pre), 1, fp) !=3D 1) { ret =3D "Dump write error"; @@ -412,13 +412,16 @@ static bool do_lu_start(struct delayed_request *req) } =20 static const char *lu_start(const void *ctx, struct connection *conn, - bool force, unsigned int to) + bool force, unsigned int to, unsigned int vers) { syslog(LOG_INFO, "live-update: start, force=3D%d, to=3D%u\n", force, to); =20 if (!lu_status || lu_status->conn !=3D conn) return "Not in live-update session."; =20 + if (!vers || vers > XS_STATE_VERSION) + return "Migration stream version not supported."; + #ifdef __MINIOS__ if (lu_status->kernel_size !=3D lu_status->kernel_off) return "Kernel not complete."; @@ -426,6 +429,7 @@ static const char *lu_start(const void *ctx, struct con= nection *conn, =20 lu_status->force =3D force; lu_status->timeout =3D to; + lu_status->version =3D vers; lu_status->started_at =3D time(NULL); lu_status->in =3D conn->in; =20 @@ -441,6 +445,7 @@ int do_control_lu(const void *ctx, struct connection *c= onn, const char **vec, unsigned int i; bool force =3D false; unsigned int to =3D 0; + unsigned int vers =3D XS_STATE_VERSION; =20 if (num < 1) return EINVAL; @@ -457,15 +462,19 @@ int do_control_lu(const void *ctx, struct connection = *conn, const char **vec, return EINVAL; } else if (!strcmp(vec[0], "-s")) { for (i =3D 1; i < num; i++) { - if (!strcmp(vec[i], "-F")) + if (!strcmp(vec[i], "-F")) { force =3D true; - else if (!strcmp(vec[i], "-t") && i < num - 1) { + } else if (!strcmp(vec[i], "-t") && i < num - 1) { i++; to =3D atoi(vec[i]); - } else + } else if (!strcmp(vec[i], "-v") && i < num - 1) { + i++; + vers =3D atoi(vec[i]); + } else { return EINVAL; + } } - ret =3D lu_start(ctx, conn, force, to); + ret =3D lu_start(ctx, conn, force, to, vers); if (!ret) return errno; } else { diff --git a/tools/xenstored/lu.h b/tools/xenstored/lu.h index dacc9b6e42..512b8a6db2 100644 --- a/tools/xenstored/lu.h +++ b/tools/xenstored/lu.h @@ -26,6 +26,7 @@ struct live_update { /* Start parameters. */ bool force; unsigned int timeout; + unsigned int version; time_t started_at; }; =20 diff --git a/tools/xs-clients/xenstore_control.c b/tools/xs-clients/xenstor= e_control.c index 548363ee70..4b523931ce 100644 --- a/tools/xs-clients/xenstore_control.c +++ b/tools/xs-clients/xenstore_control.c @@ -26,7 +26,8 @@ static int add_to_buf(char **buf, const char *val, int le= n) return len + vallen; } =20 -static int live_update_start(struct xs_handle *xsh, bool force, unsigned i= nt to) +static int live_update_start(struct xs_handle *xsh, bool force, unsigned i= nt to, + unsigned int vers) { int len =3D 0; char *buf =3D NULL, *ret; @@ -40,6 +41,15 @@ static int live_update_start(struct xs_handle *xsh, bool= force, unsigned int to) free(ret); if (force) len =3D add_to_buf(&buf, "-F", len); + if (vers) { + if (asprintf(&ret, "%u", vers) < 0) { + free(buf); + return 1; + } + len =3D add_to_buf(&buf, "-v", len); + len =3D add_to_buf(&buf, ret, len); + free(ret); + } if (len < 0) return 1; =20 @@ -197,7 +207,8 @@ static int send_kernel_blob(struct xs_handle *xsh, cons= t char *binary) * 3. start update (includes flags) */ static int live_update_stubdom(struct xs_handle *xsh, const char *binary, - const char *cmdline, bool force, unsigned i= nt to) + const char *cmdline, bool force, unsigned i= nt to, + unsigned int vers) { int rc; =20 @@ -211,7 +222,7 @@ static int live_update_stubdom(struct xs_handle *xsh, c= onst char *binary, goto abort; } =20 - rc =3D live_update_start(xsh, force, to); + rc =3D live_update_start(xsh, force, to, vers); if (rc) goto abort; =20 @@ -231,7 +242,8 @@ static int live_update_stubdom(struct xs_handle *xsh, c= onst char *binary, * 3. start update (includes flags) */ static int live_update_daemon(struct xs_handle *xsh, const char *binary, - const char *cmdline, bool force, unsigned in= t to) + const char *cmdline, bool force, unsigned in= t to, + unsigned int vers) { int len =3D 0, rc; char *buf =3D NULL, *ret; @@ -256,7 +268,7 @@ static int live_update_daemon(struct xs_handle *xsh, co= nst char *binary, goto abort; } =20 - rc =3D live_update_start(xsh, force, to); + rc =3D live_update_start(xsh, force, to, vers); if (rc) goto abort; =20 @@ -270,7 +282,7 @@ static int live_update_daemon(struct xs_handle *xsh, co= nst char *binary, static int live_update(struct xs_handle *xsh, int argc, char **argv) { int rc =3D 0; - unsigned int i, to =3D 60; + unsigned int i, to =3D 60, vers =3D 0; char *binary =3D NULL, *cmdline =3D NULL, *val; bool force =3D false; =20 @@ -291,10 +303,19 @@ static int live_update(struct xs_handle *xsh, int arg= c, char **argv) goto out; } to =3D atoi(argv[i]); - } else if (!strcmp(argv[i], "-F")) + } else if (!strcmp(argv[i], "-F")) { force =3D true; - else + } else if (!strcmp(argv[i], "-v")) { + i++; + if (i =3D=3D argc) { + fprintf(stderr, "Missing version value\n"); + rc =3D 2; + goto out; + } + vers =3D atoi(argv[i]); + } else { binary =3D argv[i]; + } } =20 if (!binary) { @@ -305,9 +326,9 @@ static int live_update(struct xs_handle *xsh, int argc,= char **argv) =20 val =3D xs_read(xsh, XBT_NULL, "/tool/xenstored/domid", &i); if (val) - rc =3D live_update_stubdom(xsh, binary, cmdline, force, to); + rc =3D live_update_stubdom(xsh, binary, cmdline, force, to, vers); else - rc =3D live_update_daemon(xsh, binary, cmdline, force, to); + rc =3D live_update_daemon(xsh, binary, cmdline, force, to, vers); =20 free(val); =20 --=20 2.43.0