]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Add '--no-dhcp' to disable kernel DHCP
authorSasha Levin <levinsasha928@gmail.com>
Thu, 17 Nov 2011 13:53:23 +0000 (15:53 +0200)
committerPekka Enberg <penberg@kernel.org>
Fri, 18 Nov 2011 06:43:00 +0000 (08:43 +0200)
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 <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/builtin-run.c

index 3b00bf059ae897c2c2774f1e2e41f0e4e88394ec..43cf2c448b210b9a737e40633df82f226e4293ab 100644 (file)
@@ -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));
        }