From: Varad Gautam <vrd@amazon.de>
To: kexec@lists.infradead.org
Cc: Varad Gautam <vrd@amazon.de>, dwmw@amazon.co.uk
Subject: [PATCH v2 3/3] kexec-xen: Introduce --exec-live-update to trigger a live update
Date: Wed, 1 Apr 2020 18:57:17 +0200 [thread overview]
Message-ID: <1585760237-26924-3-git-send-email-vrd@amazon.de> (raw)
In-Reply-To: <1585760237-26924-1-git-send-email-vrd@amazon.de>
This signals xen to do a KEXEC_TYPE_LIVE_UPDATE kexec operation.
Signed-off-by: Varad Gautam <vrd@amazon.de>
---
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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2020-04-01 16:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-01 16:57 [PATCH v2 1/3] kexec-xen: Introduce xen_get_kexec_range to wrap xc_kexec_get_range Varad Gautam
2020-04-01 16:57 ` [PATCH v2 2/3] kexec: Introduce --load-live-update for xen Varad Gautam
2020-04-01 16:57 ` Varad Gautam [this message]
2020-04-07 12:00 ` [PATCH v2 1/3] kexec-xen: Introduce xen_get_kexec_range to wrap xc_kexec_get_range Simon Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1585760237-26924-3-git-send-email-vrd@amazon.de \
--to=vrd@amazon.de \
--cc=dwmw@amazon.co.uk \
--cc=kexec@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox