[PATCH] kexec: Provide an option to use new kexec system call
Baoquan He
bhe at redhat.com
Wed Aug 13 19:46:29 PDT 2014
On 08/13/14 at 11:06am, Vivek Goyal wrote:
> +/* New file based kexec system call related code */
> +static int do_kexec_file_load(int fileind, int argc, char **argv,
> + unsigned long flags) {
> +
> + char *kernel;
........
> + kernel_fd = open(kernel, O_RDONLY);
> + if (kernel_fd == -1) {
> + fprintf(stderr, "Failed to open file %s:%s\n", kernel,
> + strerror(errno));
> + return -1;
> + }
> +
> + /* slurp in the input kernel */
> + kernel_buf = slurp_decompress_file(kernel, &kernel_size);
> +
> + for (i = 0; i < file_types; i++) {
> + if (file_type[i].probe(kernel_buf, kernel_size) >= 0)
> + break;
> + }
> +
> + if (i == file_types) {
> + fprintf(stderr, "Cannot determine the file type " "of %s\n",
> + kernel);
> + return -1;
> + }
> +
> + ret = file_type[i].load(argc, argv, kernel_buf, kernel_size, &info);
> + if (ret < 0) {
> + fprintf(stderr, "Cannot load %s\n", kernel);
> + return ret;
> + }
> +
> + if (!is_kexec_file_load_implemented()) {
Hi Vivek,
Can we put this check earlier, maybe before kernel file openning? Since
if this syscall is not implemented, we don't have to do the opening or
loading things.
Thanks
Baoquan
> + fprintf(stderr, "syscall kexec_file_load not available.\n");
> + return -1;
> + }
> +
> + /*
> + * If there is no initramfs, set KEXEC_FILE_NO_INITRAMFS flag so that
> + * kernel does not return error with negative initrd_fd.
> + */
> + if (info.initrd_fd == -1)
> + info.kexec_flags |= KEXEC_FILE_NO_INITRAMFS;
> +
> + ret = kexec_file_load(kernel_fd, info.initrd_fd, info.command_line_len,
> + info.command_line, info.kexec_flags);
> + if (ret != 0)
> + fprintf(stderr, "kexec_file_load failed: %s\n",
> + strerror(errno));
> + return ret;
> +}
> +
>
More information about the kexec
mailing list