From: Sasha Levin Date: Thu, 17 Nov 2011 13:53:23 +0000 (+0200) Subject: kvm tools: Add '--no-dhcp' to disable kernel DHCP X-Git-Tag: next-20111121~2^2~3 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=d160d73a7f0d4d6bab795e7f2d44e56880dc13a5;p=karo-tx-linux.git kvm tools: Add '--no-dhcp' to disable kernel DHCP This new option disables the kernel DHCP which runs when starting a custom rootfs. This is useful when we want to start a rootfs but are using a network other than the usermode IP proxy (a network which doesn't provide DHCP). Signed-off-by: Sasha Levin Signed-off-by: Pekka Enberg --- diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c index 3b00bf059ae8..43cf2c448b21 100644 --- a/tools/kvm/builtin-run.c +++ b/tools/kvm/builtin-run.c @@ -91,6 +91,7 @@ static bool balloon; static bool using_rootfs; static bool custom_rootfs; static bool no_net; +static bool no_dhcp; extern bool ioport_debug; extern int active_console; extern int debug_iodelay; @@ -432,6 +433,7 @@ static const struct option options[] = { OPT_CALLBACK_DEFAULT('n', "network", NULL, "network params", "Create a new guest NIC", netdev_parser, NULL), + OPT_BOOLEAN('\0', "no-dhcp", &no_dhcp, "Disable kernel DHCP in rootfs mode"), OPT_GROUP("BIOS options:"), OPT_INTEGER('\0', "vidmode", &vidmode, @@ -861,8 +863,11 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) if (using_rootfs) { strcat(real_cmdline, " root=/dev/root rw rootflags=rw,trans=virtio,version=9p2000.L rootfstype=9p"); - if (custom_rootfs) - strcat(real_cmdline, " init=/virt/init ip=dhcp"); + if (custom_rootfs) { + strcat(real_cmdline, " init=/virt/init"); + if (!no_dhcp) + strcat(real_cmdline, " ip=dhcp"); + } } else if (!strstr(real_cmdline, "root=")) { strlcat(real_cmdline, " root=/dev/vda rw ", sizeof(real_cmdline)); }