kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] kvm tools: Use kernel dhcp for network autoconfiguration
@ 2011-09-14  7:11 Sasha Levin
  2011-09-14  7:11 ` [PATCH 2/2] kvm tools: Don't use i8042 AUX port Sasha Levin
  2011-09-14 11:57 ` [PATCH 1/2] kvm tools: Use kernel dhcp for network autoconfiguration Asias He
  0 siblings, 2 replies; 7+ messages in thread
From: Sasha Levin @ 2011-09-14  7:11 UTC (permalink / raw)
  To: penberg; +Cc: kvm, mingo, asias.hejun, gorcunov, Sasha Levin

This patch removes the manual/usermode dhcp client configuration and instead
uses the DHCP client built within the kernel.

Since this client is tightly integrated with NFS (if NFS config is set), we
will add a specific NFS root addr in our DHCP offer to point it to a non
existent address so that we won't hang trying to poke it for our root.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 tools/kvm/builtin-run.c     |    2 +-
 tools/kvm/guest/init.c      |    4 ----
 tools/kvm/guest/setnet.sh   |   22 ----------------------
 tools/kvm/include/kvm/uip.h |    2 ++
 tools/kvm/net/uip/dhcp.c    |    8 ++++++++
 5 files changed, 11 insertions(+), 27 deletions(-)
 delete mode 100755 tools/kvm/guest/setnet.sh

diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index 591fd77..465bbe7 100644
--- a/tools/kvm/builtin-run.c
+++ b/tools/kvm/builtin-run.c
@@ -764,7 +764,7 @@ 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");
+			strcat(real_cmdline, " init=/virt/init ip=dhcp");
 	} else if (!strstr(real_cmdline, "root=")) {
 		strlcat(real_cmdline, " root=/dev/vda rw ", sizeof(real_cmdline));
 	}
diff --git a/tools/kvm/guest/init.c b/tools/kvm/guest/init.c
index 7733026..837acfb 100644
--- a/tools/kvm/guest/init.c
+++ b/tools/kvm/guest/init.c
@@ -30,10 +30,6 @@ int main(int argc, char *argv[])
 
 	do_mounts();
 
-	puts("Setting up network...");
-
-	system("/bin/sh virt/setnet.sh");
-
 	puts("Starting '/bin/sh'...");
 
 	run_process("/bin/sh");
diff --git a/tools/kvm/guest/setnet.sh b/tools/kvm/guest/setnet.sh
deleted file mode 100755
index 3da9c22..0000000
--- a/tools/kvm/guest/setnet.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-for f in /sys/class/net/*; do
-	type=`cat $f/type`
-	if [ $type -eq 1 ]; then
-		f=${f#/sys/class/net/}
-
-		eval "dhcpcd -A $f 2> /dev/null"
-		if [ $? -eq 0 ]; then
-			exit
-		fi
-
-		eval "dhclient $f 2> /dev/null"
-		if [ $? -eq 0 ]; then
-			exit
-		fi
-
-		ifconfig $f 192.168.33.15
-		route add default 192.168.33.1
-		echo "nameserver 8.8.8.8" >> /etc/resolv.conf
-
-		exit
-	fi
-done
diff --git a/tools/kvm/include/kvm/uip.h b/tools/kvm/include/kvm/uip.h
index 344ec09..3501d36 100644
--- a/tools/kvm/include/kvm/uip.h
+++ b/tools/kvm/include/kvm/uip.h
@@ -58,6 +58,8 @@
 #define UIP_DHCP_TAG_SUBMASK_LEN	4
 #define UIP_DHCP_TAG_ROUTER		3
 #define UIP_DHCP_TAG_ROUTER_LEN		4
+#define UIP_DHCP_TAG_ROOT		17
+#define UIP_DHCP_TAG_ROOT_LEN		4
 #define UIP_DHCP_TAG_DNS_SERVER		6
 #define UIP_DHCP_TAG_DNS_SERVER_LEN	4
 #define UIP_DHCP_TAG_DOMAIN_NAME	15
diff --git a/tools/kvm/net/uip/dhcp.c b/tools/kvm/net/uip/dhcp.c
index bd3c53b..e91a7c7 100644
--- a/tools/kvm/net/uip/dhcp.c
+++ b/tools/kvm/net/uip/dhcp.c
@@ -2,6 +2,8 @@
 
 #include <arpa/inet.h>
 
+#define EMPTY_ADDR "0.0.0.0"
+
 static inline bool uip_dhcp_is_discovery(struct uip_dhcp *dhcp)
 {
 	return (dhcp->option[2] == UIP_DHCP_DISCOVER &&
@@ -127,6 +129,12 @@ static int uip_dhcp_fill_option(struct uip_info *info, struct uip_dhcp *dhcp, in
 	*addr		= htonl(info->host_ip);
 	i		+= UIP_DHCP_TAG_ROUTER_LEN;
 
+	opt[i++]	= UIP_DHCP_TAG_ROOT;
+	opt[i++]	= strlen(EMPTY_ADDR);
+	addr		= (u32 *)&opt[i];
+	strncpy((void *) addr, EMPTY_ADDR, strlen(EMPTY_ADDR));
+	i		+= strlen(EMPTY_ADDR);
+
 	i 		= uip_dhcp_fill_option_name_and_server(info, opt, i);
 
 	opt[i++]	= UIP_DHCP_TAG_END;
-- 
1.7.6.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] kvm tools: Don't use i8042 AUX port
  2011-09-14  7:11 [PATCH 1/2] kvm tools: Use kernel dhcp for network autoconfiguration Sasha Levin
@ 2011-09-14  7:11 ` Sasha Levin
  2011-09-14  7:14   ` Pekka Enberg
  2011-09-14 11:57 ` [PATCH 1/2] kvm tools: Use kernel dhcp for network autoconfiguration Asias He
  1 sibling, 1 reply; 7+ messages in thread
From: Sasha Levin @ 2011-09-14  7:11 UTC (permalink / raw)
  To: penberg; +Cc: kvm, mingo, asias.hejun, gorcunov, Sasha Levin

We currently don't have sufficient support for mouse, this patch disables
it by default to prevent the delay when booting.

It should be removed once sufficient mouse support is added.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 tools/kvm/builtin-run.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index 465bbe7..2795115 100644
--- a/tools/kvm/builtin-run.c
+++ b/tools/kvm/builtin-run.c
@@ -736,7 +736,8 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
 		vidmode = 0;
 
 	memset(real_cmdline, 0, sizeof(real_cmdline));
-	strcpy(real_cmdline, "notsc noapic noacpi pci=conf1 reboot=k panic=1 i8042.direct=1 i8042.dumbkbd=1 i8042.nopnp=1");
+	strcpy(real_cmdline, "notsc noapic noacpi pci=conf1 reboot=k panic=1 i8042.direct=1 "
+				"i8042.dumbkbd=1 i8042.nopnp=1 i8042.noaux=1");
 	if (vnc || sdl) {
 		strcat(real_cmdline, " video=vesafb console=tty0");
 	} else
-- 
1.7.6.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] kvm tools: Don't use i8042 AUX port
  2011-09-14  7:11 ` [PATCH 2/2] kvm tools: Don't use i8042 AUX port Sasha Levin
@ 2011-09-14  7:14   ` Pekka Enberg
  2011-09-14  7:16     ` Sasha Levin
  0 siblings, 1 reply; 7+ messages in thread
From: Pekka Enberg @ 2011-09-14  7:14 UTC (permalink / raw)
  To: Sasha Levin; +Cc: kvm, mingo, asias.hejun, gorcunov

On Wed, Sep 14, 2011 at 10:11 AM, Sasha Levin <levinsasha928@gmail.com> wrote:
> We currently don't have sufficient support for mouse, this patch disables
> it by default to prevent the delay when booting.
>
> It should be removed once sufficient mouse support is added.
>
> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
> ---
>  tools/kvm/builtin-run.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
> index 465bbe7..2795115 100644
> --- a/tools/kvm/builtin-run.c
> +++ b/tools/kvm/builtin-run.c
> @@ -736,7 +736,8 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
>                vidmode = 0;
>
>        memset(real_cmdline, 0, sizeof(real_cmdline));
> -       strcpy(real_cmdline, "notsc noapic noacpi pci=conf1 reboot=k panic=1 i8042.direct=1 i8042.dumbkbd=1 i8042.nopnp=1");
> +       strcpy(real_cmdline, "notsc noapic noacpi pci=conf1 reboot=k panic=1 i8042.direct=1 "
> +                               "i8042.dumbkbd=1 i8042.nopnp=1 i8042.noaux=1");
>        if (vnc || sdl) {
>                strcat(real_cmdline, " video=vesafb console=tty0");
>        } else

What's the problem? IIRC mouse works just fine in VNC mode?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] kvm tools: Don't use i8042 AUX port
  2011-09-14  7:14   ` Pekka Enberg
@ 2011-09-14  7:16     ` Sasha Levin
  2011-09-14  7:21       ` Pekka Enberg
  0 siblings, 1 reply; 7+ messages in thread
From: Sasha Levin @ 2011-09-14  7:16 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: kvm, mingo, asias.hejun, gorcunov

On Wed, 2011-09-14 at 10:14 +0300, Pekka Enberg wrote:
> On Wed, Sep 14, 2011 at 10:11 AM, Sasha Levin <levinsasha928@gmail.com> wrote:
> > We currently don't have sufficient support for mouse, this patch disables
> > it by default to prevent the delay when booting.
> >
> > It should be removed once sufficient mouse support is added.
> >
> > Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
> > ---
> >  tools/kvm/builtin-run.c |    3 ++-
> >  1 files changed, 2 insertions(+), 1 deletions(-)
> >
> > diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
> > index 465bbe7..2795115 100644
> > --- a/tools/kvm/builtin-run.c
> > +++ b/tools/kvm/builtin-run.c
> > @@ -736,7 +736,8 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
> >                vidmode = 0;
> >
> >        memset(real_cmdline, 0, sizeof(real_cmdline));
> > -       strcpy(real_cmdline, "notsc noapic noacpi pci=conf1 reboot=k panic=1 i8042.direct=1 i8042.dumbkbd=1 i8042.nopnp=1");
> > +       strcpy(real_cmdline, "notsc noapic noacpi pci=conf1 reboot=k panic=1 i8042.direct=1 "
> > +                               "i8042.dumbkbd=1 i8042.nopnp=1 i8042.noaux=1");
> >        if (vnc || sdl) {
> >                strcat(real_cmdline, " video=vesafb console=tty0");
> >        } else
> 
> What's the problem? IIRC mouse works just fine in VNC mode?

The problem is that it causes a pretty long delay (~5-6 sec) during
boot.

VNC mouse could use some more love before I'd say it's good, one example
that the host mouse and guest mouse aren't synced.

-- 

Sasha.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] kvm tools: Don't use i8042 AUX port
  2011-09-14  7:16     ` Sasha Levin
@ 2011-09-14  7:21       ` Pekka Enberg
  2011-09-14  7:21         ` Sasha Levin
  0 siblings, 1 reply; 7+ messages in thread
From: Pekka Enberg @ 2011-09-14  7:21 UTC (permalink / raw)
  To: Sasha Levin; +Cc: kvm, mingo, asias.hejun, gorcunov

On 9/14/11 10:16 AM, Sasha Levin wrote:
> The problem is that it causes a pretty long delay (~5-6 sec) during
> boot.
>
> VNC mouse could use some more love before I'd say it's good, one example
> that the host mouse and guest mouse aren't synced.

Maybe but it's likely good enough for the people who are actually using 
it. We can't just disable it silently!

So I think we should enable AUX if user asks for VNC, no?

			Pekka

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] kvm tools: Don't use i8042 AUX port
  2011-09-14  7:21       ` Pekka Enberg
@ 2011-09-14  7:21         ` Sasha Levin
  0 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2011-09-14  7:21 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: kvm, mingo, asias.hejun, gorcunov

On Wed, 2011-09-14 at 10:21 +0300, Pekka Enberg wrote:
> On 9/14/11 10:16 AM, Sasha Levin wrote:
> > The problem is that it causes a pretty long delay (~5-6 sec) during
> > boot.
> >
> > VNC mouse could use some more love before I'd say it's good, one example
> > that the host mouse and guest mouse aren't synced.
> 
> Maybe but it's likely good enough for the people who are actually using 
> it. We can't just disable it silently!
> 
> So I think we should enable AUX if user asks for VNC, no?

Yup, let's make it disabled only when !vnc and !sdl.

-- 

Sasha.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] kvm tools: Use kernel dhcp for network autoconfiguration
  2011-09-14  7:11 [PATCH 1/2] kvm tools: Use kernel dhcp for network autoconfiguration Sasha Levin
  2011-09-14  7:11 ` [PATCH 2/2] kvm tools: Don't use i8042 AUX port Sasha Levin
@ 2011-09-14 11:57 ` Asias He
  1 sibling, 0 replies; 7+ messages in thread
From: Asias He @ 2011-09-14 11:57 UTC (permalink / raw)
  To: Sasha Levin; +Cc: penberg, kvm, mingo, gorcunov

On 09/14/2011 03:11 PM, Sasha Levin wrote:
> This patch removes the manual/usermode dhcp client configuration and instead
> uses the DHCP client built within the kernel.
> 
> Since this client is tightly integrated with NFS (if NFS config is set), we
> will add a specific NFS root addr in our DHCP offer to point it to a non
> existent address so that we won't hang trying to poke it for our root.
> 
> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>

Acked-by: Asias He <asias.hejun@gmail.com>

-- 
Asias He

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-09-14 12:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-14  7:11 [PATCH 1/2] kvm tools: Use kernel dhcp for network autoconfiguration Sasha Levin
2011-09-14  7:11 ` [PATCH 2/2] kvm tools: Don't use i8042 AUX port Sasha Levin
2011-09-14  7:14   ` Pekka Enberg
2011-09-14  7:16     ` Sasha Levin
2011-09-14  7:21       ` Pekka Enberg
2011-09-14  7:21         ` Sasha Levin
2011-09-14 11:57 ` [PATCH 1/2] kvm tools: Use kernel dhcp for network autoconfiguration Asias He

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).