diff options
author | Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> | 2007-08-22 21:13:39 +0900 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2007-10-18 14:36:03 +0900 |
commit | 2e152ffba39a9234dfa984966deba273824e73c1 (patch) | |
tree | 270b9e12e03b1c9461595e4764c8694d9045d82f /kexec/crashdump.c | |
parent | 6282f6f4e662ca7c8fa9c53d31f1e1057c3d6192 (diff) |
Pass vmcoreinfo's address and size
The patch is for kexec-tools-testing-20070330.
(http://www.kernel.org/pub/linux/kernel/people/horms/kexec-tools/)
The kexec command gets the address and size of the vmcoreinfo data from
/sys/kernel/vmcoreinfo, and passes them to the second kernel through
ELF header of /proc/vmcore. When the second kernel is booting, the
kernel gets them from the ELF header and creates vmcoreinfo's PT_NOTE
segment into /proc/vmcore.
Signed-off-by: Dan Aloni <da-x@monatomic.org>
Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/crashdump.c')
-rw-r--r-- | kexec/crashdump.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/kexec/crashdump.c b/kexec/crashdump.c index 1c08606..a35f7a7 100644 --- a/kexec/crashdump.c +++ b/kexec/crashdump.c @@ -108,3 +108,35 @@ int get_crash_notes_per_cpu(int cpu, uint64_t *addr, uint64_t *len) return 0; } + +/* Returns the physical address of start of crash notes buffer for a kernel. */ +int get_kernel_vmcoreinfo(uint64_t *addr, uint64_t *len) +{ + char kdump_info[PATH_MAX]; + char line[MAX_LINE]; + int count; + FILE *fp; + unsigned long long temp, temp2; + + *addr = 0; + *len = 0; + + sprintf(kdump_info, "/sys/kernel/vmcoreinfo"); + fp = fopen(kdump_info, "r"); + if (!fp) { + die("Could not open \"%s\": %s\n", kdump_info, + strerror(errno)); + return -1; + } + + if (!fgets(line, sizeof(line), fp)) + die("Cannot parse %s: %s\n", kdump_info, strerror(errno)); + count = sscanf(line, "%Lx %Lx", &temp, &temp2); + if (count != 2) + die("Cannot parse %s: %s\n", kdump_info, strerror(errno)); + + *addr = (uint64_t) temp; + *len = (uint64_t) temp2; + + return 0; +} |