diff options
author | David Vrabel <david.vrabel@citrix.com> | 2013-11-06 14:55:22 +0000 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2013-11-19 10:20:53 +0900 |
commit | c0b4a3f95dd80256cc6d7084436235e69b4933fb (patch) | |
tree | 225478b34f2a0d893fd99afd854495e45a37ba5c /kexec/kexec.c | |
parent | ccd6099112f38eab768d1ce481e9fe3000ba7fda (diff) |
kexec/xen: directly load images images into Xen
Xen 4.4 has an improvided kexec hypercall ABI that allows images to be
loaded and executed without any kernel involvement. Use the API
provided by libxc to load images when running in a Xen guest.
Support for loading images via the kexec_load syscall in non-upstream
("classic") Xen kernels is no longer supported.
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/kexec.c')
-rw-r--r-- | kexec/kexec.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/kexec/kexec.c b/kexec/kexec.c index 2ce570f..9dc3fa4 100644 --- a/kexec/kexec.c +++ b/kexec/kexec.c @@ -764,8 +764,12 @@ static int my_load(const char *type, int fileind, int argc, char **argv, if (kexec_debug) print_segments(stderr, &info); - result = kexec_load( - info.entry, info.nr_segments, info.segment, info.kexec_flags); + if (xen_present()) + result = xen_kexec_load(&info); + else + result = kexec_load(info.entry, + info.nr_segments, info.segment, + info.kexec_flags); if (result != 0) { /* The load failed, print some debugging information */ fprintf(stderr, "kexec_load failed: %s\n", @@ -789,10 +793,13 @@ static int k_unload (unsigned long kexec_flags) } kexec_flags |= native_arch; - result = kexec_load(NULL, 0, NULL, kexec_flags); + if (xen_present()) + result = xen_kexec_unload(kexec_flags); + else + result = kexec_load(NULL, 0, NULL, kexec_flags); if (result != 0) { /* The unload failed, print some debugging information */ - fprintf(stderr, "kexec_load (0 segments) failed: %s\n", + fprintf(stderr, "kexec unload failed: %s\n", strerror(errno)); } return result; @@ -823,7 +830,10 @@ static int my_shutdown(void) */ static int my_exec(void) { - reboot(LINUX_REBOOT_CMD_KEXEC); + if (xen_present()) + xen_kexec_exec(); + else + reboot(LINUX_REBOOT_CMD_KEXEC); /* I have failed if I make it here */ fprintf(stderr, "kexec failed: %s\n", strerror(errno)); @@ -928,6 +938,10 @@ static int kexec_loaded(void) char *p; char line[3]; + /* No way to tell if an image is loaded under Xen, assume it is. */ + if (xen_present()) + return 1; + fp = fopen("/sys/kernel/kexec_loaded", "r"); if (fp == NULL) return -1; |