5

I'm trying to test some software on a big endian system to ensure compatibility. My plan is to use qemu on Ubuntu 12.04 to emulate a MIPS system. So far I've been able to create the quest system successfully, but I haven't been able to network it with the host system. I can access the outside world from the guest system (e.g. wget or apt-get), but my attempts at setting up samba have failed.

According to this, in QEmu 1.1 and newer the network bridge helper can set tun/tap up for you without the need for additional scripting. I'm trying to use that since I've seen different versions of the scripts. Right now qemu-system-mips -version reports the following:

QEMU emulator version 1.0.50 (Debian 1.0.50-2012.03-0ubuntu2.1), Copyright (c) 2003-2008 Fabrice Bellard

I've compiled from the 1.4.1 source and used the version from apt-get. Both report the same thing. I'm working under the assumption that I have version 1.1 or later despite what -version is telling me. Anyway, the next instruction was to turn on the setuid attribute for the default network helper:

sudo chmod u+s /usr/local/libexec/qemu-bridge-helper

Next I created a bridge.conf file in /etc/qemu/ and /usr/local/etc/qemu with -rw-r--r-- for permissions. The contents of the file are:

allow br0

If I start QEmu with the following command:

qemu-system-mips -M malta -kernel vmlinux-2.6.32-5-4kc-malta -hda disk.img -append "root=/dev/sda1 console=ttyS0" -nographic -net nic -net bridge,br=br0 -smb /home/uli/samba

or with

qemu-system-mips -M malta -kernel vmlinux-2.6.32-5-4kc-malta -hda disk.img -append "root=/dev/sda1 console=ttyS0" -nographic -netdev bridge,id=hn0 -device virtio-net-pci,netdev=hn0,id=nic1

or with

qemu-system-mips -M malta -kernel vmlinux-2.6.32-5-4kc-malta -hda disk.img -append "root=/dev/sda1 console=ttyS0" -nographic  -netdev tap,helper=/usr/local/libexec/qemu-bridge-helper,id=hn0 -device virtio-net-pci,netdev=hn0,id=nic1

I get the following error:

failed to get mtu of bridge `br0': No such device
failed to launch bridge helper
qemu-system-mips: -net bridge,br=br0: Device 'bridge' could not be initialized

Fair enough, I didn't create the br0 bridge. I've tried creating one with a script I don't understand, but then my quest MIPS QEmu system no longer connects to anything. It sees br0, but it doesn't get an IP address. Clearly I'm doing something wrong here:

ifconfig br0 down
brctl delbr br0

ifconfig eth2 0.0.0.0 promisc up

brctl addbr br0
brctl setfd br0 0
brctl addif br0 eth2

echo 1 > /proc/sys/net/ipv4/conf/br0/proxy_arp
echo 1 > /proc/sys/net/ipv4/conf/eth2/proxy_arp
echo 1 > /proc/sys/net/ipv4/ip_forward

dhclient br0
ifconfig br0 up

Is there an easier way to do this? Personally, I would be fine just using the SMB server on \10.0.2.4\qemu that's described here, but that hasn't worked for me either (115 errors when I try to mount the share, presumably because of networking trouble).

Update

Once I create the bridge, I see the following output from ifconfig on the host machine:

br0       Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX  
          inet addr:10.2.32.101  Bcast:10.2.32.255  Mask:255.255.255.0          
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:85 errors:0 dropped:0 overruns:0 frame:0
          TX packets:51 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:8235 (8.2 KB)  TX bytes:9227 (9.2 KB)

eth2      Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX  
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:196581 errors:0 dropped:0 overruns:0 frame:0
          TX packets:44205 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:139517339 (139.5 MB)  TX bytes:3365206 (3.3 MB)

Checking the brctl show output, I see the following:

bridge name     bridge id           STP enabled     interfaces
br0             8000.XXXXXXXXXXXX       no              eth2

Now I start the quest system in QEmu. If I run ifconfig, I see the following:

eth0      Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:536 errors:1 dropped:51 overruns:0 frame:0
          TX packets:13 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:55083 (53.7 KiB)  TX bytes:2862 (2.7 KiB)
          Interrupt:10 Base address:0x1020

And the bridge looks like this:

bridge name     bridge id           STP enabled     interfaces
br0             8000.XXXXXXXXXXXX   no      eth2
                                                        tap0

Unfortunately with this setup, the quest system has lost the limited "user mode" networking it once had (i.e. wget and apt-get no longer work). The only IP address I see is for the bridge, so I'm not sure how the quest will appear on the network. The host still appears, at the same IP address as br0.

Update

Here is the output from iptables -L

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination   
7
  • To clarify, you're host with the br0 device can access the internet, however the QEmu guest's eth0 device doesn't have an IP and can't access the internet, right?
    – slm
    May 3, 2013 at 4:35
  • Actually, both can access the internet. I don't see how to share files between the guest and the host. How can I check if there is an iptables firewall in the mix? I'm sorry, but I'm not familiar with that. May 3, 2013 at 16:48
  • Run the command iptables -L. So you can ping www.google.com from both the Host and the Guest? I would attempt to setup samba on either the Host or the Guest, depending on which way you want to push/pull the files.
    – slm
    May 3, 2013 at 16:53
  • The Host can ping www.google.com. Ping isn't supported by the "User Mode" networking available to the Guest, but the Guest can reach the outside world. For example, the Guest could check out/check in code from SVN. That's actually how I ended up moving files back and forth. Finally, I have Samba setup on the Host and I am accessing it from another Host. May 3, 2013 at 19:49
  • OK so networking is functioning within the Guest. How are you trying to connect to the Samba server on the Host server? What client are you attempting to use?
    – slm
    May 3, 2013 at 20:00

1 Answer 1

0

When you're running a bridge the members in the bridge (eth2) no longer should have an IP address assigned to them. br0 should be getting the IP now.

Example

This is output from a system that uses KVM. It uses qemu-kvm under the hood so it should be similar in setup to what you're trying to do.

$ ifconfig -a
br0       Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2929289877 errors:0 dropped:0 overruns:0 frame:0
          TX packets:842023980 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1992305504701 (1.8 TiB)  TX bytes:3609403664141 (3.2 TiB)

eth0      Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3737819958 errors:0 dropped:168 overruns:0 frame:0
          TX packets:1233468235 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2735097151685 (2.4 TiB)  TX bytes:4313257594064 (3.9 TiB)
          Interrupt:177 

See how eth0 doesn't have an IP address? Also here's what my br0 device looks like:

$ brctl show
bridge name bridge id               STP enabled     interfaces
br0         8000.XXXXXXXXXXXX       no              vnet2
                                                    vnet1
                                                    vnet0
                                                    eth0

I've got 3 VMs that are sitting on top of the br0 device, so they can fully participate in my network just like a true physical system. This means they can provide services like run Samba etc. I don't believe you can serve Samba from behind the NAT networking.

3
  • How do the VMs participate on the network without visible IP addresses? May 1, 2013 at 14:33
  • The do have visible IPs. They get them from a DHCP server just like any normal server would. That's what a bridge device allows you to do. The vnetX interfaces on the KVM host tie back to a ethX device within the KVM guests.
    – slm
    May 1, 2013 at 14:35
  • I'll update my question with output from my machine. So far I don't see visible IPs. As for samba, I'm trying to follow the documentation for just linking the emulated quest to the host. May 1, 2013 at 14:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .