tools/xenstore: add command line handling for live update
authorJuergen Gross <jgross@suse.com>
Wed, 13 Jan 2021 13:00:18 +0000 (14:00 +0100)
committerJuergen Gross <jgross@suse.com>
Thu, 21 Jan 2021 16:30:57 +0000 (17:30 +0100)
Updating an instance of Xenstore via live update needs to hand over
the command line parameters to the updated instance. Those can be
either the parameters used by the updated instance or new ones when
supplied when starting the live update.

So when supplied store the new command line parameters in lu_status.

As it is related add a new option -U (or --live-update") to the command
line of xenstored which will be added when starting the new instance.
This enables to perform slightly different initializations when
started as a result of live update.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Acked-by: Wei Liu <wl@xen.org>
tools/xenstore/xenstored_control.c
tools/xenstore/xenstored_core.c

index 95ac1a16482f24212851701aa4b7794fa6ce8ee3..2e0827b9ef8ebdb2588c22f127a76ab7904143ae 100644 (file)
@@ -42,6 +42,8 @@ struct live_update {
 #else
        char *filename;
 #endif
+
+       char *cmdline;
 };
 
 static struct live_update *lu_status;
@@ -211,6 +213,10 @@ static const char *lu_cmdline(const void *ctx, struct connection *conn,
        if (!lu_status || lu_status->conn != conn)
                return "Not in live-update session.";
 
+       lu_status->cmdline = talloc_strdup(lu_status, cmdline);
+       if (!lu_status->cmdline)
+               return "Allocation failure.";
+
        return NULL;
 }
 
index e1b92c3dc86e04b52e10c422f65f918cd0a88322..0dddf24327e79e46495f8ef05de0bb5e84cc5299 100644 (file)
@@ -1969,6 +1969,7 @@ static struct option options[] = {
        { "internal-db", 0, NULL, 'I' },
        { "verbose", 0, NULL, 'V' },
        { "watch-nb", 1, NULL, 'W' },
+       { "live-update", 0, NULL, 'U' },
        { NULL, 0, NULL, 0 } };
 
 extern void dump_conn(struct connection *conn); 
@@ -1983,11 +1984,12 @@ int main(int argc, char *argv[])
        bool dofork = true;
        bool outputpid = false;
        bool no_domain_init = false;
+       bool live_update = false;
        const char *pidfile = NULL;
        int timeout;
 
 
-       while ((opt = getopt_long(argc, argv, "DE:F:HNPS:t:A:M:T:RVW:", options,
+       while ((opt = getopt_long(argc, argv, "DE:F:HNPS:t:A:M:T:RVW:U", options,
                                  NULL)) != -1) {
                switch (opt) {
                case 'D':
@@ -2045,6 +2047,9 @@ int main(int argc, char *argv[])
                case 'p':
                        priv_domid = strtol(optarg, NULL, 10);
                        break;
+               case 'U':
+                       live_update = true;
+                       break;
                }
        }
        if (optind != argc)