mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-08-25 07:26:38 +00:00
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 <levinsasha928@gmail.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
+7
-2
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user