This signals xen to do a KEXEC_TYPE_LIVE_UPDATE kexec operation. Signed-off-by: Varad Gautam <vrd@xxxxxxxxx> --- kexec/kexec-xen.c | 12 ++++++++---- kexec/kexec.c | 11 ++++++++++- kexec/kexec.h | 6 ++++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/kexec/kexec-xen.c b/kexec/kexec-xen.c index 83629ba..da514d0 100644 --- a/kexec/kexec-xen.c +++ b/kexec/kexec-xen.c @@ -242,15 +242,19 @@ int xen_kexec_status(uint64_t kexec_flags) return ret; } -void xen_kexec_exec(void) +void xen_kexec_exec(uint64_t kexec_flags) { xc_interface *xch; - + uint8_t type = KEXEC_TYPE_DEFAULT; + xch = xc_interface_open(NULL, NULL, 0); if (!xch) return; - xc_kexec_exec(xch, KEXEC_TYPE_DEFAULT); + if (kexec_flags & KEXEC_LIVE_UPDATE) + type = KEXEC_TYPE_LIVE_UPDATE; + + xc_kexec_exec(xch, type); xc_interface_close(xch); } @@ -277,7 +281,7 @@ int xen_kexec_status(uint64_t kexec_flags) return -1; } -void xen_kexec_exec(void) +void xen_kexec_exec(uint64_t kexec_flags) { } diff --git a/kexec/kexec.c b/kexec/kexec.c index da61d6d..7ef3d2a 100644 --- a/kexec/kexec.c +++ b/kexec/kexec.c @@ -906,7 +906,7 @@ static int my_shutdown(void) static int my_exec(void) { if (xen_present()) - xen_kexec_exec(); + xen_kexec_exec(kexec_flags); else reboot(LINUX_REBOOT_CMD_KEXEC); /* I have failed if I make it here */ @@ -1012,6 +1012,8 @@ void usage(void) " If capture kernel is being unloaded\n" " specify -p with -u.\n" " -e, --exec Execute a currently loaded kernel.\n" + " --exec-live-update Execute a currently loaded xen image after\n" + "storing the state required to live update.\n" " -t, --type=TYPE Specify the new kernel is of this type.\n" " --mem-min=<addr> Specify the lowest memory address to\n" " load code into.\n" @@ -1397,6 +1399,13 @@ int main(int argc, char *argv[]) do_unload = 1; kexec_file_flags |= KEXEC_FILE_UNLOAD; break; + case OPT_EXEC_LIVE_UPDATE: + if ( !xen_present() ) { + fprintf(stderr, "--exec-live-update only works under xen.\n"); + return 1; + } + kexec_flags |= KEXEC_LIVE_UPDATE; + /* fallthrough */ case OPT_EXEC: do_load = 0; do_shutdown = 0; diff --git a/kexec/kexec.h b/kexec/kexec.h index 8021f39..f0f347d 100644 --- a/kexec/kexec.h +++ b/kexec/kexec.h @@ -234,7 +234,8 @@ extern int file_types; #define OPT_ENTRY 261 #define OPT_PRINT_CKR_SIZE 262 #define OPT_LOAD_LIVE_UPDATE 263 -#define OPT_MAX 264 +#define OPT_EXEC_LIVE_UPDATE 264 +#define OPT_MAX 265 #define KEXEC_OPTIONS \ { "help", 0, 0, OPT_HELP }, \ { "version", 0, 0, OPT_VERSION }, \ @@ -245,6 +246,7 @@ extern int file_types; { "load", 0, 0, OPT_LOAD }, \ { "unload", 0, 0, OPT_UNLOAD }, \ { "exec", 0, 0, OPT_EXEC }, \ + { "exec-live-update", 0, 0, OPT_EXEC_LIVE_UPDATE}, \ { "load-preserve-context", 0, 0, OPT_LOAD_PRESERVE_CONTEXT}, \ { "load-jump-back-helper", 0, 0, OPT_LOAD_JUMP_BACK_HELPER }, \ { "load-live-update", 0, 0, OPT_LOAD_LIVE_UPDATE }, \ @@ -326,7 +328,7 @@ void cmdline_add_liveupdate(char **base); int xen_present(void); int xen_kexec_load(struct kexec_info *info); int xen_kexec_unload(uint64_t kexec_flags); -void xen_kexec_exec(void); +void xen_kexec_exec(uint64_t kexec_flags); int xen_kexec_status(uint64_t kexec_flags); extern unsigned long long get_kernel_sym(const char *text); -- 2.7.4 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 _______________________________________________ kexec mailing list kexec@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/kexec