[PATCH v2 1/4] kvm tools: Add '--no-dhcp' to disable kernel DHCP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 tools/kvm/builtin-run.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index 3b00bf0..43cf2c4 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));
 	}
-- 
1.7.8.rc1

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


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux