[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] tools/xenstore: save new binary for live update



commit e867af081d9418101ae85e716f9cacc4a7087bdd
Author:     Juergen Gross <jgross@xxxxxxxx>
AuthorDate: Wed Jan 13 14:00:17 2021 +0100
Commit:     Juergen Gross <jgross@xxxxxxxx>
CommitDate: Thu Jan 21 17:30:55 2021 +0100

    tools/xenstore: save new binary for live update
    
    Save the new binary name for the daemon case and the new kernel for
    stubdom in order to support live update of Xenstore..
    
    Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
    Reviewed-by: Paul Durrant <paul@xxxxxxx>
    Reviewed-by: Julien Grall <jgrall@xxxxxxxxxx>
    Acked-by: Wei Liu <wl@xxxxxxx>
---
 tools/xenstore/xenstored_control.c | 41 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/tools/xenstore/xenstored_control.c 
b/tools/xenstore/xenstored_control.c
index 7854b7f46f..95ac1a1648 100644
--- a/tools/xenstore/xenstored_control.c
+++ b/tools/xenstore/xenstored_control.c
@@ -1,5 +1,5 @@
 /*
-    Interactive commands for Xen Store Daemon.
+Interactive commands for Xen Store Daemon.
     Copyright (C) 2017 Juergen Gross, SUSE Linux GmbH
 
     This program is free software; you can redistribute it and/or modify
@@ -22,6 +22,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <syslog.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
 
 #include "utils.h"
 #include "talloc.h"
@@ -31,6 +34,14 @@
 struct live_update {
        /* For verification the correct connection is acting. */
        struct connection *conn;
+
+#ifdef __MINIOS__
+       void *kernel;
+       unsigned int kernel_size;
+       unsigned int kernel_off;
+#else
+       char *filename;
+#endif
 };
 
 static struct live_update *lu_status;
@@ -215,6 +226,13 @@ static const char *lu_binary_alloc(const void *ctx, struct 
connection *conn,
        if (ret)
                return ret;
 
+       lu_status->kernel = talloc_size(lu_status, size);
+       if (!lu_status->kernel)
+               return "Allocation failure.";
+
+       lu_status->kernel_size = size;
+       lu_status->kernel_off = 0;
+
        return NULL;
 }
 
@@ -224,6 +242,12 @@ static const char *lu_binary_save(const void *ctx, struct 
connection *conn,
        if (!lu_status || lu_status->conn != conn)
                return "Not in live-update session.";
 
+       if (lu_status->kernel_off + size > lu_status->kernel_size)
+               return "Too much kernel data.";
+
+       memcpy(lu_status->kernel + lu_status->kernel_off, data, size);
+       lu_status->kernel_off += size;
+
        return NULL;
 }
 
@@ -243,13 +267,23 @@ static const char *lu_binary(const void *ctx, struct 
connection *conn,
                             const char *filename)
 {
        const char *ret;
+       struct stat statbuf;
 
        syslog(LOG_INFO, "live-update: binary %s\n", filename);
 
+       if (stat(filename, &statbuf))
+               return "File not accessible.";
+       if (!(statbuf.st_mode & (S_IXOTH | S_IXGRP | S_IXUSR)))
+               return "File not executable.";
+
        ret = lu_begin(conn);
        if (ret)
                return ret;
 
+       lu_status->filename = talloc_strdup(lu_status, filename);
+       if (!lu_status->filename)
+               return "Allocation failure.";
+
        return NULL;
 }
 
@@ -272,6 +306,11 @@ static const char *lu_start(const void *ctx, struct 
connection *conn,
        if (!lu_status || lu_status->conn != conn)
                return "Not in live-update session.";
 
+#ifdef __MINIOS__
+       if (lu_status->kernel_size != lu_status->kernel_off)
+               return "Kernel not complete.";
+#endif
+
        /* Will be replaced by real live-update later. */
        talloc_free(lu_status);
 
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.