From: Pekka Enberg Subject: Re: [PATCH] kvm tools: Enable kernel DHCP autoconf by default Date: Wed, 10 Aug 2011 08:00:31 +0300 (EEST) Message-ID: References: <1312912411-9416-1-git-send-email-penberg@kernel.org> <4E41CABC.8090206@gmail.com> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: kvm@vger.kernel.org, Avi Kivity , Cyrill Gorcunov , Ingo Molnar , Linus Torvalds , Prasad Joshi , Sasha Levin To: Asias He Return-path: Received: from mail-bw0-f46.google.com ([209.85.214.46]:33643 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750966Ab1HJFAk (ORCPT ); Wed, 10 Aug 2011 01:00:40 -0400 Received: by bke11 with SMTP id 11so138648bke.19 for ; Tue, 09 Aug 2011 22:00:39 -0700 (PDT) In-Reply-To: <4E41CABC.8090206@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, 10 Aug 2011, Asias He wrote: > On 08/10/2011 01:53 AM, Pekka Enberg wrote: >> As we boot to '/bin/sh' by default, enable kernel DHCP autoconfiguration too. >> The guest kernel needs to be configured with the following configuration >> options: >> >> CONFIG_IP_PNP=y >> CONFIG_IP_PNP_DHCP=y >> >> Cc: Asias He >> Cc: Avi Kivity >> Cc: Cyrill Gorcunov >> Cc: Ingo Molnar >> Cc: Linus Torvalds >> Cc: Prasad Joshi >> Cc: Sasha Levin >> Signed-off-by: Pekka Enberg >> --- >> tools/kvm/README | 3 +++ >> tools/kvm/builtin-run.c | 2 +- >> 2 files changed, 4 insertions(+), 1 deletions(-) >> >> diff --git a/tools/kvm/README b/tools/kvm/README >> index 5b85461..2cf9364 100644 >> --- a/tools/kvm/README >> +++ b/tools/kvm/README >> @@ -70,6 +70,9 @@ linux-0.2.img.bz2 >> - For virtio-rng device (--rng): >> CONFIG_HW_RANDOM_VIRTIO=y >> >> + - For kernel DHCP autoconf (when booting to /bin/sh): >> + CONFIG_IP_PNP=y >> + CONFIG_IP_PNP_DHCP=y >> >> 5. And finally, launch the hypervisor: >> >> diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c >> index fa5de27..af7f59c 100644 >> --- a/tools/kvm/builtin-run.c >> +++ b/tools/kvm/builtin-run.c >> @@ -601,7 +601,7 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) >> using_rootfs = 1; >> >> if (!strstr(real_cmdline, "init=")) >> - strlcat(real_cmdline, " init=/bin/sh ", sizeof(real_cmdline)); >> + strlcat(real_cmdline, " init=/bin/sh ip=dhcp ", sizeof(real_cmdline)); >> } >> >> if (!strstr(real_cmdline, "root=")) > > 'ip=dhcp' makes kernel try to use nfs as root fs which results in a long > time 'wait and fail' and finally fallback to 9p as root fs. > > [ 1.688000] Sending DHCP requests ., OK > [ 1.695000] IP-Config: Got DHCP answer from 192.168.33.1, my address > is 192.168.33.15 > [ 1.699000] IP-Config: Complete: > [ 1.700000] device=eth0, addr=192.168.33.15, mask=255.255.255.0, > gw=192.168.33.1, > [ 1.703000] host=192.168.33.15, domain=stu.buaa.edu.cn, > nis-domain=(none), > [ 1.706000] bootserver=192.168.33.1, rootserver=192.168.33.1, > rootpath= > [ 36.769000] VFS: Unable to mount root fs via NFS, trying floppy. > [ 36.771000] VFS: Mounted root (9p filesystem) on device 0:14. I reverted the patch for now. Thanks, Asias!