[PATCH 2/9] tools/xenstore: perform kexec for stubdom live update

Juergen Gross posted 9 patches 4 months ago
There is a newer version of this series
[PATCH 2/9] tools/xenstore: perform kexec for stubdom live update
Posted by Juergen Gross 4 months ago
For the final step of live-update in stubdom, call kexec().

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 tools/xenstored/lu_minios.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/tools/xenstored/lu_minios.c b/tools/xenstored/lu_minios.c
index b14a0b29d5..b8ca631610 100644
--- a/tools/xenstored/lu_minios.c
+++ b/tools/xenstored/lu_minios.c
@@ -8,13 +8,44 @@
 #include <stdlib.h>
 #include <syslog.h>
 
+#include <mini-os/kexec.h>
+
 #include "talloc.h"
 #include "lu.h"
+#include "core.h"
 
 #ifndef NO_LIVE_UPDATE
 char *lu_exec(const void *ctx, int argc, char **argv)
 {
-	return "NYI";
+	int i;
+	int ret;
+	char *errbuf;
+	char *cmdline;
+
+	if (!lu_status->kernel)
+		return "No new kernel";
+
+	cmdline = talloc_strdup(ctx, "");
+	if (!cmdline)
+		return "Allocation failure";
+	for (i = 1; argv[i]; i++) {
+		if (i > 1) {
+			cmdline = talloc_append_string(ctx, cmdline, " ");
+			if (!cmdline)
+				return "Allocation failure";
+		}
+		cmdline = talloc_append_string(ctx, cmdline, argv[i]);
+		if (!cmdline)
+			return "Allocation failure";
+	}
+
+	ret = kexec(lu_status->kernel, lu_status->kernel_size, cmdline);
+
+	errbuf = talloc_asprintf(ctx, "kexec() returned %d", ret);
+	if (!errbuf)
+		errbuf = "kexec() returned";
+
+	return errbuf;
 }
 
 static const char *lu_binary_alloc(const void *ctx, struct connection *conn,
-- 
2.43.0
Re: [PATCH 2/9] tools/xenstore: perform kexec for stubdom live update
Posted by Jason Andryuk 3 months, 2 weeks ago
On 2025-07-02 04:12, Juergen Gross wrote:
> For the final step of live-update in stubdom, call kexec().
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>