From 79fafcf1d3eeb598d60d0dfbc973189b07244779 Mon Sep 17 00:00:00 2001 From: David Ahern Date: Tue, 5 Apr 2011 10:04:13 -0600 Subject: [PATCH] kvm tools: do not append root=/dev/vda if passed via command line Hardcoding the root= option prevents an existing qemu-kvm based disk image using LVM from booting. It fails to find the root filesystem. By making the root parameter optional if given on the command line, the image boots correctly. For example, ./kvm --kernel=/tmp/vmlinuz-2.6.38 \ --initrd=/tmp/initramfs-2.6.38.img \ --image=/home/dsa/vm/images/f14/nkvm-f14.img \ --mem=1024 --params="ro root=/dev/mapper/vg_f14vm-lv_root" works now. Signed-off-by: David Ahern Signed-off-by: Pekka Enberg --- main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index d70b446..3165bc7 100644 --- a/main.c +++ b/main.c @@ -148,7 +148,10 @@ int main(int argc, char *argv[]) kvm__setup_cpuid(kvm); - strcpy(real_cmdline, "notsc nolapic nosmp noacpi pci=conf1 console=ttyS0 root=/dev/vda rw "); + strcpy(real_cmdline, "notsc nolapic nosmp noacpi pci=conf1 console=ttyS0 "); + if (!kernel_cmdline || (strstr(kernel_cmdline, "root=") == NULL)) + strlcat(real_cmdline, "root=/dev/vda rw ", sizeof(real_cmdline)); + if (kernel_cmdline) { strlcat(real_cmdline, kernel_cmdline, sizeof(real_cmdline)); real_cmdline[sizeof(real_cmdline)-1] = '\0';