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 <dsahern@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
David Ahern
2015-06-01 16:39:41 +01:00
committed by Will Deacon
parent f4b1697a22
commit 79fafcf1d3
+4 -1
View File
@@ -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';