kvmtool/run: set a default cmdline if not set
PATCH 1/1 kvmtool/run: set a default cmdline if not set
when starting with custom kernel and disk options, kernel_cmdline is NULL; it results in a segfault while trying to look for a string using strstr:
__strstr_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strstr-sse2-unaligned.S:400x00000000004056bf in kvm_cmd_run_init (argc=<optimized out>, argv=<optimized out>) at builtin-run.c:608 0x000000000040639d in kvm_cmd_run (argc=<optimized out>, argv=<optimized out>, prefix=<optimized out>) at builtin-run.c:659 0x0000000000412b8f in handle_command (command=0x62bbc0 <kvm_commands>, argc=5, argv=0x7fffffffe840) at kvm-cmd.c:84 0x00007ffff7211b45 in __libc_start_main (main=0x403540 <main>, argc=6, argv=0x7fffffffe838, init=<optimized out>, fini=<optimized out>,
rtld_fini=<optimized out>, stack_end=0x7fffffffe828) at libc-start.c:2870x0000000000403962 in _start ()
this patch suggests to set a minimal cmdline when kernel_cmdline is NULL
--- builtin-run.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
builtin-run.c +2 -1
@@ -605,7 +605,8 @@ static struct kvm *kvm_cmd_run_init(int argc, const char **argv)if (kvm_setup_guest_init (kvm->cfg.custom_rootfs_name))die ("Failed to setup init for guest." ); } - }else if (!strstr (kvm->cfg.kernel_cmdline,"root=" )) { + }else if (!kvm->cfg.kernel_cmdline || + !strstr (kvm->cfg.kernel_cmdline,"root=" )) {strlcat (real_cmdline," root=/dev/vda rw " ,sizeof (real_cmdline)); }
Signature · 1 line
2.6.1