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=<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:287
0x0000000000403962 in _start ()

this patch suggests to set a minimal cmdline when kernel_cmdline is NULL

Signed-off-by: William Dauchy <will...@gandi.net>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to