You are not logged in.

#1 2012-07-16 18:46:10

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,252
Website

QEMU networking/wiki out-of-date

Seems as though the QEMU networking article is out-of-date consisting of info based on the deprecated net-tools package.  I'm having a tough time setting up a bridge to give my qemu VM networking abilities.  Would be very pleased if someone with knowledge could update the wiki.

Thanks!

Last edited by graysky (2012-07-16 18:52:11)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#2 2012-08-03 15:11:45

nixIT
Member
Registered: 2010-01-13
Posts: 448

Re: QEMU networking/wiki out-of-date

@graysky,

I'm with you, I'm not sure how to set up a network bridge for QEMU/KVM either.  Any help with this is appreciated.

--nixIT


ASRock 970 Extreme4  | AMD FX 8350 | 32GB G.SKILL Ripjaw X  | 180GB Corsair Force Series GS SSD | MSI GeForce GTX 960 GTX Gaming 4G 4GB

Offline

#3 2012-08-04 06:10:06

neilzium
Member
Registered: 2011-12-17
Posts: 41

Re: QEMU networking/wiki out-of-date

I've recently successfully set up bridged networking using the information in the wiki.
The only part of the script which seems to use net-tools and is depreciated is the qemu-ifup script, which uses ifconfig. This could be replaced using ip link.
I've replaced this with the following line, which works for me:

ip link set $1 up promisc on

I'm not a networking expert, so I don't know if this is completely correct.
The bigger issue I think is that both the wiki and the QEMU manual is out of date reguarding tap networking. As far as I know, using -netdev tap instead of -net tap is now the preffered method.
Using vhosts with tap networking is also not mentioned, which further increases performance.
Using these techniques, I get practically full thoughtput on my VM using iperf on a gigabit LAN.
Despite all of this, the setup on the wiki should work but if you're still having problems, post some more info.

Last edited by neilzium (2012-08-04 06:11:02)

Offline

#4 2012-08-05 21:58:36

nixIT
Member
Registered: 2010-01-13
Posts: 448

Re: QEMU networking/wiki out-of-date

@neilzium,

I am following the script, and I get to this point:

6. Install the script that QEMU uses to bring up the tap adapter in /etc/qemu-ifup with root:kvm 750 permissions:

I'm not sure what to do from this point on. 

--nixIT


ASRock 970 Extreme4  | AMD FX 8350 | 32GB G.SKILL Ripjaw X  | 180GB Corsair Force Series GS SSD | MSI GeForce GTX 960 GTX Gaming 4G 4GB

Offline

#5 2012-08-06 08:43:38

neilzium
Member
Registered: 2011-12-17
Posts: 41

Re: QEMU networking/wiki out-of-date

It sounds like the wording of the instructions may be throwing you off. You don't really have to "install" anything, you simply copy and paste the shell script in that step into /etc/qemu-ifup, and give the file appropriate execute permissions.
If you're running QEMU as a user which is part of the KVM group, I would do the following:

chown root:kvm /etc/qemu-ifup
chmod g+x /etc/qemu-ifup

qemu will then automatically run this script when you start it in order to bring up the tap device before it connects it to the emulated device.

Offline

#6 2012-08-06 18:47:45

nixIT
Member
Registered: 2010-01-13
Posts: 448

Re: QEMU networking/wiki out-of-date

@neilzium,

Thanks I will give that a shot when I get home.  will QEMU also bring down the tap device when it exits?

--nixIT


ASRock 970 Extreme4  | AMD FX 8350 | 32GB G.SKILL Ripjaw X  | 180GB Corsair Force Series GS SSD | MSI GeForce GTX 960 GTX Gaming 4G 4GB

Offline

#7 2012-08-07 02:10:08

neilzium
Member
Registered: 2011-12-17
Posts: 41

Re: QEMU networking/wiki out-of-date

QEMU will try to run a script at /etc/qemu-ifdown on exit to remove the tap device. the main script in the wiki uses a tunctl -d line at the end to do the same.
I would recommend to remove that line and use the ifdown method instead. My ifdown script simply looks like

#!/bin/sh
/sbin/ip link set $1 down
/usr/sbin/brctl delif br0 $1
/sbin/ip link delete dev $1

I could never get tunctl -d to work in the ifdown script for some reason, so I used ip link delete instead.
Note that if you do not run QEMU as root, you will have to run each line with sudo and edit your sudoers file accordingly

Offline

#8 2012-08-07 14:19:40

nixIT
Member
Registered: 2010-01-13
Posts: 448

Re: QEMU networking/wiki out-of-date

@neilzium,

Thanx, worked on this last night but didn't get a chance to test.  I do have a question, and this may be an install issue, so here goes:

How bit of an issue is the visudo step in the wiki?  During install I never installed visudo, since it was optional.  Do I Need to go back and install it?  or can I just skip this step in the QEMU wiki?

--nixIT


ASRock 970 Extreme4  | AMD FX 8350 | 32GB G.SKILL Ripjaw X  | 180GB Corsair Force Series GS SSD | MSI GeForce GTX 960 GTX Gaming 4G 4GB

Offline

#9 2012-08-08 01:37:44

neilzium
Member
Registered: 2011-12-17
Posts: 41

Re: QEMU networking/wiki out-of-date

You will need to install sudo only if you want to run QEMU as a non root user. This user must also be in the KVM group. This is the recommended way to do it and is more secure, but is not necessary if you want to run as root.

Offline

#10 2012-08-08 18:50:14

nixIT
Member
Registered: 2010-01-13
Posts: 448

Re: QEMU networking/wiki out-of-date

neilzium wrote:

You will need to install sudo only if you want to run QEMU as a non root user. This user must also be in the KVM group. This is the recommended way to do it and is more secure, but is not necessary if you want to run as root.

gotcha, understand that, so I will go back to the install guide and get that done.

hmmm, the message I posted last night isn't here. 

Anyway, I followed the steps for the qemu-ifup and -ifdown.

When I rebooted my system for the networking changes in rc.conf to take effect I did not have a network connection.

Here is what I had in rc.conf

MODULES=(kvm kvm-amd bridge tun)

eth0="eth0 192.168.0.2"
br0="br0 192.168.0.3 netmask 255.255.255.0 broadcast 192.168.0.255"
INTERFACES=(eth0 br0)
gateway="default gw 192.168.0.1"
netmask=255.255.255.0
broadcast=192.168.0.255
ROUTES=(gateway)

not sure why I had no network. 

I would love to get this troubleshot/shooted??  what info can I provide you that will help solve this issue?

--nixIT


ASRock 970 Extreme4  | AMD FX 8350 | 32GB G.SKILL Ripjaw X  | 180GB Corsair Force Series GS SSD | MSI GeForce GTX 960 GTX Gaming 4G 4GB

Offline

#11 2012-08-09 01:42:25

neilzium
Member
Registered: 2011-12-17
Posts: 41

Re: QEMU networking/wiki out-of-date

The way that I understand it, all traffic to the host will pass through the bridge as well,  therefore eth0 does not have a set IP address on your LAN (in other words it should just be set to 0.0.0.0).
The bridge should have the IP that your host used to have. My network setup in rc.conf is:

eth0="eth0 0.0.0.0"
br0="br0 192.168.1.20 netmask 255.255.255.0 broadcast 192.168.1.255"
INTERFACES=(eth0 br0)
gateway="default gw 192.168.1.1"
ROUTES=(gateway)

NETWORK_PERSIST="no"

I'm not sure if it matters, but the kvm_amd module in your modules list has an underscore instead of a hyphen.
Just make a backup of rc.conf, and in order to test your network setup just run:

rc.d restart network

If you want to set a fixed IP for your VM as well, you will need to configure that once the VM is running and/or set a DHCP lease on your router based on a fixed MAC address that you give the VM when running QEMU.

Offline

#12 2012-08-10 20:11:04

nixIT
Member
Registered: 2010-01-13
Posts: 448

Re: QEMU networking/wiki out-of-date

@Neilzium,

Thanx.  Will give this a try when i get home.


ASRock 970 Extreme4  | AMD FX 8350 | 32GB G.SKILL Ripjaw X  | 180GB Corsair Force Series GS SSD | MSI GeForce GTX 960 GTX Gaming 4G 4GB

Offline

#13 2012-08-12 05:17:38

nixIT
Member
Registered: 2010-01-13
Posts: 448

Re: QEMU networking/wiki out-of-date

@Neilzium,

Here is what happened when I changed my rc.conf to match yours:

# rc.d restart network
Warning: Your network settings are deprecated.
  Please refer to 'man 5 rc.conf' on how to define a single wired
  connection, or use a utility such as netcfg.
:: Stopping network                                                      [BUSY] /etc/rc.d/network: line 149: route: command not found
can't delete bridge br0: Package not installed
                                                                         [FAIL] 
Warning: Your network settings are deprecated.
  Please refer to 'man 5 rc.conf' on how to define a single wired
  connection, or use a utility such as netcfg.
:: Starting network                                                      [BUSY] add bridge failed: Package not installed
bridge br0 does not exist!
/etc/rc.d/network: line 66: ifconfig: command not found
/etc/rc.d/network: line 76: ifconfig: command not found
/etc/rc.d/network: line 66: ifconfig: command not found
/etc/rc.d/network: line 76: ifconfig: command not found
/etc/rc.d/network: line 134: route: command not found
                                                                         [FAIL] 

I am at a loss at what's going on.

--nixIT


ASRock 970 Extreme4  | AMD FX 8350 | 32GB G.SKILL Ripjaw X  | 180GB Corsair Force Series GS SSD | MSI GeForce GTX 960 GTX Gaming 4G 4GB

Offline

#14 2012-08-13 01:51:33

neilzium
Member
Registered: 2011-12-17
Posts: 41

Re: QEMU networking/wiki out-of-date

The output there suggests to me that its failing because bridge-utils and net-tools aren't installed. what I have just learned from this info is that INTERFACES causes the network init script to fall back on ifconfig. Maybe this was what graysky was referring to?
From a quick glance at /etc/rc.d/network it seems that the script has to use net-tools (i.e. ifconfig) when using profiles, which seems to be the only way to set up a bridge through rc.conf. Maybe someone with some initscripts experience could confirm this?
Installing bridge-utils and net-tools should fix your problem, however if you want to setup your network the new way with iproute2, then you will probably need to use netcfg.

Offline

#15 2012-08-13 13:15:52

nixIT
Member
Registered: 2010-01-13
Posts: 448

Re: QEMU networking/wiki out-of-date

@neilzium,

I appreciate your help in this.

I was digging round in /etc/rc.d/network and also noticed that there were many of calls to ifconfig. 

I would love to set up my network/bridge with iproute2, but, I'm not sure how to do that. 

I am currently at a loss with this, since it's over my head.  I guess I will give up on the bridge network for right now, and just live with my VM not being on my internal lan.  sad

--nixIT


ASRock 970 Extreme4  | AMD FX 8350 | 32GB G.SKILL Ripjaw X  | 180GB Corsair Force Series GS SSD | MSI GeForce GTX 960 GTX Gaming 4G 4GB

Offline

#16 2012-08-15 19:50:08

nixIT
Member
Registered: 2010-01-13
Posts: 448

Re: QEMU networking/wiki out-of-date

I have moved my post and issue to this thread:

https://bbs.archlinux.org/viewtopic.php?id=147134

@Graysky, I apologize for hijacking your thread, this was not my intention.

--nixIT


ASRock 970 Extreme4  | AMD FX 8350 | 32GB G.SKILL Ripjaw X  | 180GB Corsair Force Series GS SSD | MSI GeForce GTX 960 GTX Gaming 4G 4GB

Offline

Board footer

Powered by FluxBB