Setting up network for KVM guests

2011-05-26 Thread c . monty
Hello!
I have installed KVM/QEMU on my LMDE (Linux Mint Debian Edition) system.

On this webpage I found some instructions howto setup the network:
http://www.linux-kvm.org/page/Networking

My first question is:
For a public bridge, should I configure /etc/network/interfaces in order to 
create the bridge static.
Or should I use a script to create a bridge dynamically when the virtual 
machine starts.

Second question:
I made some tests with this script that is shown in section
public bridge -> Solution 2: manual:

#!/bin/sh
set -x

switch=br0

if [ -n "$1" ];then
    /usr/bin/sudo /usr/sbin/tunctl -u `whoami` -t $1
    /usr/bin/sudo /sbin/ip link set $1 up
    sleep 0.5s
    /usr/bin/sudo /usr/sbin/brctl addif $switch $1
    exit 0
else
    echo "Error: no interface specified"
    exit 1
fi

When I debug this script I can see that it always ends up in "Error: no 
interface specified":
bash -x /usr/local/bin/networkbridge_setup.sh
+ set -x
+ switch=br0
+ '[' -n '' ']'
+ echo 'Error: no interface specified'
Error: no interface specified
+ exit 1


Why is that?

THX
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Using KVM in user mode with public bridge

2011-05-24 Thread c . monty
Hello!
I have installed KVM/QEMU on my LMDE (Linux Mint Debian Edition) system.

The guest should use a public bridge that I have set up with 
/etc/network/interfaces. As you can see the bridge is configured to use a 
static IP:
 s@pc1-lmde ~ $ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

auto eth1
iface eth1 inet manual

auto br1
iface br1 inet static
    address 192.168.178.11      
    netmask 255.255.255.0
    gateway 192.168.178.1
    bridge_ports eth1
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0

Starting a VM with kvm command returns this error:
 s@pc1-lmde ~ $ kvm -hda 
~/.virtualmachines/aqemu/virtualdisk_converted/vm2-windowsxp-HD01-15G.qcow 
-boot c -cdrom /dev/cdrom -m 1024 -smp 1 -net nic,macaddr=00:88:4e:ad:2d:61 
-net tap
kvm: -net tap: could not configure /dev/net/tun (tap%d): Operation not permitted
kvm: -net tap: Device 'tap' could not be initialized

Checking the permissions of file /dev/net/tun:
 s@pc1-lmde ~ $ ls -l /dev/net/tun
crw-rw-rw- 1 root root 10, 200 21. Mai 09:52 /dev/net/tun
 Starting kvm as root by means of using "sudo" works. Then all processes runs 
as root.
Can you advice how to troubleshoot this problem? Why do I have to be root for 
starting KVM?
I thought the group assignment is correct:
 s@pc1-lmde ~ $ groups
sudo kvm libvirt

I would prefer to run kvm in user mode, means not as root.
I assume I have to initiate the TUN/TAP interface before the VM is started.
How can I do this using a script? Is there a Howto available providing 
instructions?

THX
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html