Skip to contentSkip to conversation

Is anyone able to load a web page from a guest operating system?

Qemu-devel Programmingkid 5 participants 13 messages Apr 26, 2016 – Apr 28, 2016

lore
Share & tools
lore
#0 lore raw

My three guest operating systems can't load a web page. I think this is a bug with QEMU. Is there anyone who has the latest revision of QEMU that can access the web from a guest? Or are you experiencing the same problem?

#1 lore raw
Quoted 1 line · * Programmingkid ([email protected]) wrote:

My three guest operating systems can't load a web page. I think this is a bug with QEMU. Is there anyone who has the latest revision of QEMU that can access the web from a guest? Or are you experiencing the same problem?

Works here.

Now - how about some basic debug!
Does your guest see a network card?
Does DNS work?
Does ping work?
Does a telnet/ssh from the guest work?
What's the qemu command line you use?

Dave

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#2 lore raw
Quoted 4 lines · Dr. David Alan Gilbert
Quoted 1 line · * Programmingkid ([email protected]) wrote:

My three guest operating systems can't load a web page. I think this is a bug with QEMU. Is there anyone who has the latest revision of QEMU that can access the web from a guest? Or are you experiencing the same problem?

Works here.

So you are using a very recent version of QEMU? Maybe something that was pulled in the last day or so?

Quoted 2 lines

Now - how about some basic debug!
Does your guest see a network card?

yes

Quoted 1 line

Does DNS work?

Doesn't look like it. If I use just an ip address it still doesn't work.

Quoted 1 line

Does ping work?

I can ping the virtual router at 10.0.2.2. Any other ip address fails.

Quoted 1 line

Does a telnet/ssh from the guest work?

telnet www.google.com 80 failed
Didn't have an address to use ssh on.

Quoted 1 line

What's the qemu command line you use?

qemu-system-ppc -hda <hd1> -hdb <hd2> -m 512 -boot c -M mac99 -netdev user,id=mynet0 -device usb-net,netdev=mynet0 -cpu 750 -prom-env boot-args=-v -device ich9-usb-uhci1,id=newusb -device usb-audio,bus=newusb.0

and

qemu-system-ppc -hda <hd1> -hdb <hd2> -m 512 -boot c -M mac99 -netdev user,id=mynet0 -device rtl8139,netdev=mynet0 -cpu 750 -prom-env boot-args=-v -device ich9-usb-uhci1,id=newusb -device usb-audio,bus=newusb.0

This and my other guest did access the internet before.

Thanks for helping.

#3 lore raw
Quoted 11 lines · Programmingkid
Quoted 4 lines · Dr. David Alan Gilbert
Quoted 1 line · * Programmingkid ([email protected]) wrote:

My three guest operating systems can't load a web page. I think this is a bug with QEMU. Is there anyone who has the latest revision of QEMU that can access the web from a guest? Or are you experiencing the same problem?

Works here.

So you are using a very recent version of QEMU? Maybe something that was pulled in the last day or so?

Quoted 2 lines

Now - how about some basic debug!
Does your guest see a network card?

Quoted 7 lines

yes

Quoted 1 line

Does DNS work?

Doesn't look like it. If I use just an ip address it still doesn't work.

Quoted 1 line

Does ping work?

I can ping the virtual router at 10.0.2.2. Any other ip address fails.

That's normal for user-mode / slirp networking. You can't ping external hosts with this mode.

Quoted 10 lines
Quoted 1 line

Does a telnet/ssh from the guest work?

telnet www.google.com 80 failed
Didn't have an address to use ssh on.

Quoted 1 line

What's the qemu command line you use?

qemu-system-ppc -hda <hd1> -hdb <hd2> -m 512 -boot c -M mac99 -netdev user,id=mynet0 -device usb-net,netdev=mynet0 -cpu 750 -prom-env boot-args=-v -device ich9-usb-uhci1,id=newusb -device usb-audio,bus=newusb.0

and

qemu-system-ppc -hda <hd1> -hdb <hd2> -m 512 -boot c -M mac99 -netdev user,id=mynet0 -device rtl8139,netdev=mynet0 -cpu 750 -prom-env boot-args=-v -device ich9-usb-uhci1,id=newusb -device usb-audio,bus=newusb.0

Ok, that means you're using user-mode / slirp networking. I just tried it with a pseries guest, and it seems to be working fine for me with the current git version of QEMU (f419a626c76bcb266).

Now, what kind of host do you use? Mac OS X?
Also can you determine a revision when it was still working fine for you? (and then maybe even bisect the problem?)

Thomas

#4 lore raw
Quoted 30 lines · Thomas Huth
Quoted 11 lines · Programmingkid
Quoted 4 lines · Dr. David Alan Gilbert
Quoted 1 line · * Programmingkid ([email protected]) wrote:

My three guest operating systems can't load a web page. I think this is a bug with QEMU. Is there anyone who has the latest revision of QEMU that can access the web from a guest? Or are you experiencing the same problem?

Works here.

So you are using a very recent version of QEMU? Maybe something that was pulled in the last day or so?

Quoted 2 lines

Now - how about some basic debug!
Does your guest see a network card?

Quoted 7 lines

yes

Quoted 1 line

Does DNS work?

Doesn't look like it. If I use just an ip address it still doesn't work.

Quoted 1 line

Does ping work?

I can ping the virtual router at 10.0.2.2. Any other ip address fails.

That's normal for user-mode / slirp networking. You can't ping external hosts with this mode.

Quoted 7 lines
Quoted 1 line

Does a telnet/ssh from the guest work?

telnet www.google.com 80 failed
Didn't have an address to use ssh on.

Quoted 1 line

What's the qemu command line you use?

qemu-system-ppc -hda <hd1> -hdb <hd2> -m 512 -boot c -M mac99 -netdev user,id=mynet0 -device usb-net,netdev=mynet0 -cpu 750 -prom-env boot-args=-v -device ich9-usb-uhci1,id=newusb -device usb-audio,bus=newusb.0

Quoted 7 lines
Quoted 3 lines

and

qemu-system-ppc -hda <hd1> -hdb <hd2> -m 512 -boot c -M mac99 -netdev user,id=mynet0 -device rtl8139,netdev=mynet0 -cpu 750 -prom-env boot-args=-v -device ich9-usb-uhci1,id=newusb -device usb-audio,bus=newusb.0

Ok, that means you're using user-mode / slirp networking. I just tried it with a pseries guest, and it seems to be working fine for me with the current git version of QEMU (f419a626c76bcb266).

So you are saying you can view web pages on your guest?

Quoted 2 lines

Now, what kind of host do you use? Mac OS X?

Yes. Mac OS 10.6.

Quoted 2 lines

Also can you determine a revision when it was still working fine for you? (and then maybe even bisect the problem?)

I will see what I can find out.

#5 lore raw
Quoted 9 lines · Programmingkid
Quoted 6 lines · Thomas Huth
Quoted 5 lines · Programmingkid
Quoted 2 lines · Dr. David Alan Gilbert
Quoted 1 line · * Programmingkid ([email protected]) wrote:

My three guest operating systems can't load a web page. I think this is a bug with QEMU. Is there anyone who has the latest revision of QEMU that can access the web from a guest? Or are you experiencing the same problem?

...

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

What's the qemu command line you use?

qemu-system-ppc -hda <hd1> -hdb <hd2> -m 512 -boot c -M mac99 -netdev user,id=mynet0 -device usb-net,netdev=mynet0 -cpu 750 -prom-env boot-args=-v -device ich9-usb-uhci1,id=newusb -device usb-audio,bus=newusb.0

and

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

qemu-system-ppc -hda <hd1> -hdb <hd2> -m 512 -boot c -M mac99 -netdev user,id=mynet0 -device rtl8139,netdev=mynet0 -cpu 750 -prom-env boot-args=-v -device ich9-usb-uhci1,id=newusb -device usb-audio,bus=newusb.0

Ok, that means you're using user-mode / slirp networking. I just tried it with a pseries guest, and it seems to be working fine for me with the current git version of QEMU (f419a626c76bcb266).

So you are saying you can view web pages on your guest?

Yes. Linux guest on a Linux host, and I was able to access a web page from the guest.

Quoted 3 lines
Quoted 2 lines

Now, what kind of host do you use? Mac OS X?

Yes. Mac OS 10.6.

Ok, at least not Windows ... because there have been some problems with Windows recently, which could be the culprit otherwise:

http://git.qemu.org/?p=qemu.git;a=commitdiff;h=3424c8a9c89a3bc0d29ad

Quoted 4 lines
Quoted 2 lines

Also can you determine a revision when it was still working fine for you? (and then maybe even bisect the problem?)

I will see what I can find out.

Thanks! Bisecting the problem is likely the best way to deal with this...

Thomas

#6 lore raw
Quoted 34 lines · Thomas Huth
Quoted 9 lines · Programmingkid
Quoted 6 lines · Thomas Huth
Quoted 5 lines · Programmingkid
Quoted 2 lines · Dr. David Alan Gilbert
Quoted 1 line · * Programmingkid ([email protected]) wrote:

My three guest operating systems can't load a web page. I think this is a bug with QEMU. Is there anyone who has the latest revision of QEMU that can access the web from a guest? Or are you experiencing the same problem?

...

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

What's the qemu command line you use?

qemu-system-ppc -hda <hd1> -hdb <hd2> -m 512 -boot c -M mac99 -netdev user,id=mynet0 -device usb-net,netdev=mynet0 -cpu 750 -prom-env boot-args=-v -device ich9-usb-uhci1,id=newusb -device usb-audio,bus=newusb.0

and

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

qemu-system-ppc -hda <hd1> -hdb <hd2> -m 512 -boot c -M mac99 -netdev user,id=mynet0 -device rtl8139,netdev=mynet0 -cpu 750 -prom-env boot-args=-v -device ich9-usb-uhci1,id=newusb -device usb-audio,bus=newusb.0

Ok, that means you're using user-mode / slirp networking. I just tried it with a pseries guest, and it seems to be working fine for me with the current git version of QEMU (f419a626c76bcb266).

So you are saying you can view web pages on your guest?

Yes. Linux guest on a Linux host, and I was able to access a web page from the guest.

Quoted 3 lines
Quoted 2 lines

Now, what kind of host do you use? Mac OS X?

Yes. Mac OS 10.6.

Ok, at least not Windows ... because there have been some problems with Windows recently, which could be the culprit otherwise:

Quoted 8 lines

http://git.qemu.org/?p=qemu.git;a=commitdiff;h=3424c8a9c89a3bc0d29ad

Quoted 4 lines
Quoted 2 lines

Also can you determine a revision when it was still working fine for you? (and then maybe even bisect the problem?)

I will see what I can find out.

Thanks! Bisecting the problem is likely the best way to deal with this...

Found out which patch was causing problems. This one:

commit 5379229a2708df3a1506113315214c3ce5325859

Author: Guillaume Subiron <[email protected]>
Date:   Sat Dec 19 22:24:59 2015 +0100

slirp: Factorizing address translation

This patch factorizes some duplicate code into a new function, sotranslate_out(). This function perform the address translation when a packet is transmitted to the host network. If the packet is destinated to the host, the loopback address is used, and if the packet is destinated to the virtual DNS, the real DNS address is used. This code is just a copy of the existent, but factorized and ready to manage the IPv6 case.

#7 lore raw
Quoted 7 lines · Programmingkid, on Wed 27 Apr 2016 20:25:26 -0400, wrote:

Found out which patch was causing problems. This one:

commit 5379229a2708df3a1506113315214c3ce5325859

Author: Guillaume Subiron <[email protected]>
Date:   Sat Dec 19 22:24:59 2015 +0100

slirp: Factorizing address translation

Thanks!

I managed to get access to a darwin system. It seems that their sendto() doesn't like being passed an addrlen which is greater than required: the patch makes qemu pass sizeof(struct sockaddr_storage) instead of sizeof(struct sockaddr_in). That's quite unexpected, but we'll have to work around that, working on a patch now.

Samuel

#8 lore raw
In reply to Programmingkid
Quoted 7 lines · Programmingkid, on Wed 27 Apr 2016 20:25:26 -0400, wrote:

Found out which patch was causing problems. This one:

commit 5379229a2708df3a1506113315214c3ce5325859

Author: Guillaume Subiron <[email protected]>
Date:   Sat Dec 19 22:24:59 2015 +0100

slirp: Factorizing address translation

Could you try the attached patch?

Samuel

slirp/ip_icmp.c +1 -1
index 590dada..5ffc7a6 100644
@@ -186,7 +186,7 @@ icmp_input(struct mbuf *m, int hlen)
       sotranslate_out(so, &addr);
 
       if(sendto(so->s, icmp_ping_msg, strlen(icmp_ping_msg), 0,
-		(struct sockaddr *)&addr, sizeof(addr)) == -1) {
+		(struct sockaddr *)&addr, sockaddr_size(&addr)) == -1) {
 	DEBUG_MISC((dfd,"icmp_input udp sendto tx errno = %d-%s\n",
 		    errno,strerror(errno)));
 	icmp_send_error(m, ICMP_UNREACH, ICMP_UNREACH_NET, 0, strerror(errno));
slirp/socket.c +1 -1
index bd97b2d..a10eff1 100644
@@ -627,7 +627,7 @@ sosendto(struct socket *so, struct mbuf *m)
 
 	/* Don't care what port we get */
 	ret = sendto(so->s, m->m_data, m->m_len, 0,
-		     (struct sockaddr *)&addr, sizeof(addr));
+		     (struct sockaddr *)&addr, sockaddr_size(&addr));
 	if (ret < 0)
 		return -1;
 
slirp/socket.h +12 -0
index 7dca506..b602e69 100644
@@ -122,6 +122,18 @@ static inline int sockaddr_equal(struct sockaddr_storage *a,
     return 0;
 }
 
+static inline socklen_t sockaddr_size(struct sockaddr_storage *a)
+{
+    switch (a->ss_family) {
+    case AF_INET:
+        return sizeof(struct sockaddr_in);
+    case AF_INET6:
+        return sizeof(struct sockaddr_in6);
+    default:
+        g_assert_not_reached();
+    }
+}
+
 struct socket *solookup(struct socket **, struct socket *,
         struct sockaddr_storage *, struct sockaddr_storage *);
 struct socket *socreate(Slirp *);
slirp/tcp_subr.c +1 -1
index 32ff452..58eaf59 100644
@@ -413,7 +413,7 @@ int tcp_fconnect(struct socket *so, unsigned short af)
     sotranslate_out(so, &addr);
 
     /* We don't care what port we get */
-    ret = connect(s,(struct sockaddr *)&addr,sizeof (addr));
+    ret = connect(s,(struct sockaddr *)&addr, sockaddr_size(&addr));
 
     /*
      * If it's not in progress, it failed, so we just return 0,
author Reviewed-by
#9 lore raw
Quoted 7 lines · Samuel Thibault
Quoted 6 lines · Programmingkid, on Wed 27 Apr 2016 20:25:26 -0400, wrote:

Found out which patch was causing problems. This one:

commit 5379229a2708df3a1506113315214c3ce5325859

Author: Guillaume Subiron <[email protected]>
Date:   Sat Dec 19 22:24:59 2015 +0100
Quoted 6 lines
Quoted 1 line

slirp: Factorizing address translation

Could you try the attached patch?

Samuel
<patch.txt>

Your patch worked.

Thank you.

#10 lore raw
In reply to Thomas Huth
Quoted 8 lines · Thomas Huth
Quoted 4 lines · Programmingkid
Quoted 1 line · Dr. David Alan Gilbert

Does ping work?

I can ping the virtual router at 10.0.2.2. Any other ip address fails.

That's normal for user-mode / slirp networking. You can't ping external hosts with this mode.

Side note: yes, you can.

I do it whenever I want to check network connectivity from within ad-hoc OVMF guests, using the PING command of the UEFI shell. ("Ad-hoc guest" implies user-mode / slirp.)

It can be enabled with the following steps:

(1) Determine the main group ID (or one supplementary group ID) of the user that will run QEMU with slirp.

(2) In /etc/sysctl.conf (or whatever is appropriate for your host distro), make sure that the whitespace separated inclusive group ID range in the "net.ipv4.ping_group_range" sysctl includes the above group ID.

For example,

- you could add a new group called "unpriv_ping":

groupadd unpriv_ping

- set this group for a number of users as another supplementary group:

for U in user1 user2 ... usern; do

    usermod --append --groups unpriv_ping $U

done

(note, they will have to re-login),

- then set both sides of the inclusive range in the above sysctl to the numeric ID of the new group:

  (
    GROUP_ID=$(getent group unpriv_ping | cut -f 3 -d :)
    printf 'net.ipv4.ping_group_range = %u %u\n' $GROUP_ID $GROUP_ID \
      >> /etc/sysctl.conf
  )
  sysctl -p

Thanks
Laszlo

#11 lore raw
Quoted 16 lines · Laszlo Ersek
Quoted 8 lines · Thomas Huth
Quoted 4 lines · Programmingkid
Quoted 1 line · Dr. David Alan Gilbert

Does ping work?

I can ping the virtual router at 10.0.2.2. Any other ip address fails.

That's normal for user-mode / slirp networking. You can't ping external hosts with this mode.

Side note: yes, you can.

I do it whenever I want to check network connectivity from within ad-hoc OVMF guests, using the PING command of the UEFI shell. ("Ad-hoc guest" implies user-mode / slirp.)

Quoted 8 lines

It can be enabled with the following steps:

(1) Determine the main group ID (or one supplementary group ID) of the user that will run QEMU with slirp.

(2) In /etc/sysctl.conf (or whatever is appropriate for your host distro), make sure that the whitespace separated inclusive group ID range in the "net.ipv4.ping_group_range" sysctl includes the above group ID.

Wow, thanks for that hint, I just tried by temporarily enabling it with

sudo sysctl net.ipv4.ping_group_range=...

and indeed it works!

Maybe we should document that somewhere?
For example http://qemu-project.org/Documentation/Networking currently only says: "ICMP traffic does not work (so you cannot use ping within a guest)" ...

Thomas

#12 lore raw
Quoted 28 lines · Thomas Huth
Quoted 16 lines · Laszlo Ersek
Quoted 8 lines · Thomas Huth
Quoted 4 lines · Programmingkid
Quoted 1 line · Dr. David Alan Gilbert

Does ping work?

I can ping the virtual router at 10.0.2.2. Any other ip address fails.

That's normal for user-mode / slirp networking. You can't ping external hosts with this mode.

Side note: yes, you can.

I do it whenever I want to check network connectivity from within ad-hoc OVMF guests, using the PING command of the UEFI shell. ("Ad-hoc guest" implies user-mode / slirp.)

Quoted 8 lines

It can be enabled with the following steps:

(1) Determine the main group ID (or one supplementary group ID) of the user that will run QEMU with slirp.

(2) In /etc/sysctl.conf (or whatever is appropriate for your host distro), make sure that the whitespace separated inclusive group ID range in the "net.ipv4.ping_group_range" sysctl includes the above group ID.

Wow, thanks for that hint, I just tried by temporarily enabling it with

Quoted 8 lines

sudo sysctl net.ipv4.ping_group_range=...

and indeed it works!

Maybe we should document that somewhere?
For example http://qemu-project.org/Documentation/Networking currently only says: "ICMP traffic does not work (so you cannot use ping within a guest)" ...

Done.

Laszlo