From: William Dauchy Subject: [PATCH] kvmtool/run: set a default cmdline if not set Date: Sat, 31 Oct 2015 14:11:29 +0100 Message-ID: <1446297089-12689-1-git-send-email-william@gandi.net> Cc: William Dauchy To: will.deacon@arm.com, kvm@vger.kernel.org Return-path: Received: from mail-pa0-f53.google.com ([209.85.220.53]:34940 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753288AbbJaNM0 (ORCPT ); Sat, 31 Oct 2015 09:12:26 -0400 Received: by pasz6 with SMTP id z6so100600973pas.2 for ; Sat, 31 Oct 2015 06:12:25 -0700 (PDT) Sender: kvm-owner@vger.kernel.org List-ID: 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:40 0x00000000004056bf in kvm_cmd_run_init (argc=, argv=) at builtin-run.c:608 0x000000000040639d in kvm_cmd_run (argc=, argv=, prefix=) at builtin-run.c:659 0x0000000000412b8f in handle_command (command=0x62bbc0 , argc=5, argv=0x7fffffffe840) at kvm-cmd.c:84 0x00007ffff7211b45 in __libc_start_main (main=0x403540
, argc=6, argv=0x7fffffffe838, init=, fini=, rtld_fini=, stack_end=0x7fffffffe828) at libc-start.c:287 0x0000000000403962 in _start () this patch suggests to set a minimal cmdline when kernel_cmdline is NULL Signed-off-by: William Dauchy --- builtin-run.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin-run.c b/builtin-run.c index 6e4491c..929114e 100644 --- a/builtin-run.c +++ b/builtin-run.c @@ -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)); } -- 2.6.1