From: Sasha Levin Subject: [PATCH 2/4] kvm tools: Add '--no-dhcp' to disable kernel DHCP Date: Thu, 17 Nov 2011 15:04:38 +0200 Message-ID: <1321535080-4840-2-git-send-email-levinsasha928@gmail.com> References: <1321535080-4840-1-git-send-email-levinsasha928@gmail.com> Cc: kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, Sasha Levin To: penberg@kernel.org Return-path: Received: from mail-wy0-f174.google.com ([74.125.82.174]:54547 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753520Ab1KQNHH (ORCPT ); Thu, 17 Nov 2011 08:07:07 -0500 Received: by wyh11 with SMTP id 11so1929812wyh.19 for ; Thu, 17 Nov 2011 05:07:06 -0800 (PST) In-Reply-To: <1321535080-4840-1-git-send-email-levinsasha928@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: 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 --- 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