[PATCH] i386:kexec-bzImage: Use "\0" as command line instead of empty command line

Zhang Yanfei zhangyanfei.yes at gmail.com
Sat Apr 6 01:52:09 EDT 2013


于 2013年04月03日 17:43, Wang YanQing 写道:
> I get garbage output of /proc/cmdline and in dmesg when I
> use kexec to load new kernel bzImage without append command
> line like below:
> 
> kexec -l bzImage --initrd=initramfs.

Hello Wang

I tried this:

./build/sbin/kexec -l /boot/vmlinuz-2.6.32-279.el6.i686 --initrd=/boot/initramfs-2.6.32-279.el6.i686.img 

But nothing happened and it seemed the command loaded the kernel successfully.
Can you describe your situation more concretely, please?

Thanks
Zhang

> This patch fix it.
> 
> Signed-off-by: Wang YanQing <udknight at gmail.com>
> ---
>  kexec/arch/i386/kexec-bzImage.c | 3 +++
>  kexec/arch/i386/kexec-elf-x86.c | 3 +++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/kexec/arch/i386/kexec-bzImage.c b/kexec/arch/i386/kexec-bzImage.c
> index 99fd790..29f280d 100644
> --- a/kexec/arch/i386/kexec-bzImage.c
> +++ b/kexec/arch/i386/kexec-bzImage.c
> @@ -435,6 +435,9 @@ int bzImage_load(int argc, char **argv, const char *buf, off_t len,
>  	command_line_len = 0;
>  	if (command_line) {
>  		command_line_len = strlen(command_line) +1;
> +	} else {
> +	    command_line = strdup("\0");
> +	    command_line_len = 1;
>  	}
>  	ramdisk_buf = 0;
>  	if (ramdisk) {
> diff --git a/kexec/arch/i386/kexec-elf-x86.c b/kexec/arch/i386/kexec-elf-x86.c
> index e62ebcb..788a209 100644
> --- a/kexec/arch/i386/kexec-elf-x86.c
> +++ b/kexec/arch/i386/kexec-elf-x86.c
> @@ -161,6 +161,9 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
>  	command_line_len = 0;
>  	if (command_line) {
>  		command_line_len = strlen(command_line) +1;
> +	} else {
> +	    command_line = strdup("\0");
> +	    command_line_len = 1;
>  	}
>  
>  	/* Need to append some command line parameters internally in case of




More information about the kexec mailing list