I need interpratation of messages [solved]

QEMU running on Linux as a host OS

I need interpratation of messages [solved]

Postby kb2qzv on Tue Jan 30, 2007 4:22 am

Hi,
I am using gentoo, kernel 2.6.19-vs2.3.0.6.
I am trying to start qemu as a non-root user with the following option: qemu-system-x86_64 -net nic -net tap,script=/etc/qemu-ifup.

Unfortunately this fails.
Let me show you what I do:

Code: Select all
kb2qzv@localhost ~ $ sudo /sbin/modprobe tun
kb2qzv@localhost ~ $ sudo tunctl -t tap0
Set 'tap0' persistent and owned by uid 0
kb2qzv@localhost ~ $ win2k-qemu
warning: could not open /dev/net/tun: no virtual network emulation
Could not initialize device 'tap'


win2k-qemu is just a script to launch qemu.

The above suggests that /dev/net/tun is either not present or the non-root user has no permission, right? OK lets do this as root:
Code: Select all
localhost ~ # ls /dev/net/tun -l
crw------- 1 root root 10, 200 sty 29 20:08 /dev/net/tun


Well, we will now change this into:
Code: Select all
localhost ~ # chmod 0666 /dev/net/tun -v
permissions changed `/dev/net/tun'  to 0666 (rw-rw-rw-)


And now can we start qemu as a regular user?

Code: Select all
kb2qzv@localhost ~ $ win2k-qemu
warning: could not configure /dev/net/tun: no virtual network emulation
Could not initialize device 'tap'


How am I to tackle this issue, please?
Last edited by kb2qzv on Tue Jan 30, 2007 7:34 pm, edited 1 time in total.
regards,
Benedict
kb2qzv
 
Posts: 11
Joined: Fri Sep 30, 2005 7:55 am

Postby dignome on Tue Jan 30, 2007 5:06 am

When you use tunctl you have to specify the userid. Notice that it spits out UID '0' (root) - which won't work when qemu is launched as an ordinary user.

http://kidsquid.com/cgi-bin/moin.cgi/Fr ... b5113aa2a3
User avatar
dignome
helper
 
Posts: 786
Joined: Thu Jan 12, 2006 5:09 am

Postby kb2qzv on Tue Jan 30, 2007 7:58 am

dignome wrote:When you use tunctl you have to specify the userid. Notice that it spits out UID '0' (root) - which won't work when qemu is launched as an ordinary user.

http://kidsquid.com/cgi-bin/moin.cgi/Fr ... b5113aa2a3


I seem to follow everything but the thing refuses to work as described.

Code: Select all
tunctl -b -u kb2qzv -t tap0
Failed to open '/dev/net/tun' : Permission denied

OK, So I chmod to 0666 as root and repeat:

kb2qzv@localhost ~ $ tunctl -b -u kb2qzv -t tap0
TUNSETIFF: Operation not permitted


It beats me.
Do you have any other hints, please?

I include my script with which I start qemu for your reference:
Code: Select all
#!/bin/bash
# Variables
set -e
SAMBA="-smb /home/kb2qzv"
SOUND="-soundhw es1370"
MEMORY="-m 256"
KEYB="-k pl"
USB="-usb -usbdevice host:043d:0085"
TIME="-localtime"
BOOT="-boot c" # a - floppy, c - hd, d = cdrom
IMGPATH="/home/kb2qzv/Qemu"
IMG="-hda $IMGPATH/hd.img"
NETPRINT="-redir tcp:9100::9100"

# Create tap interface so that the script /etc/qemu-ifup can bridge it
# before qemu starts
USERID=`whoami`
IFACE=`sudo tunctl -b -u $USERID`

NET="-net nic -net tap,script=/etc/qemu-ifup"


# qemu start
qemu-system-x86_64 ${SAMBA} ${SOUND} ${TIME} ${MEMORY} ${KEYB} ${USB} ${BOOT} ${IMG} ${NETPRINT} ${NET}

# qemu has stopped - no longer using tap interface
sudo tunctl -d $IFACE &> /dev/null



and my qemu-ifup:
Code: Select all

if test $(/sbin/ifconfig | grep -c $1) -gt 0; then
        /sbin/brctl delif br0 $1
        /sbin/ifconfig $1 down
fi

/sbin/ifconfig $1 0.0.0.0 promisc up
/sbin/brctl addif br0 $1


Thanks for any hints
regards,
Benedict
kb2qzv
 
Posts: 11
Joined: Fri Sep 30, 2005 7:55 am

Postby dignome on Tue Jan 30, 2007 3:20 pm

Like that link says you have to be root to make a tap interface present on the host (it is a restriction in the linux kernel >=2.6.18). Use the sudo tool:

sudo tunctl ...
User avatar
dignome
helper
 
Posts: 786
Joined: Thu Jan 12, 2006 5:09 am

Postby Tibors on Tue Jan 30, 2007 5:14 pm

Your script uses the right command to create a usable tun interface:
Code: Select all
IFACE=`sudo tunctl -b -u $USERID`
But next you forget to tell QEMU to use that interface:
Code: Select all
NET="-net nic -net tap,script=/etc/qemu-ifup"
(No: ifname=$IFACE)

Compare that with the example in the wiki:
Code: Select all
iface=`sudo tunctl -b -u $USERID`
Code: Select all
[...] -net tap,vlan=0,ifname=$iface
Tibors
helper
 
Posts: 39
Joined: Sat Aug 12, 2006 1:01 pm
Location: Utrecht, The Netherlands

Postby kb2qzv on Tue Jan 30, 2007 6:54 pm

In your previous post you mention that my script misses ifname command line parameter for qemu.
I tried that already but forgot to report it here on the forum. Here is the updated NET variable which includes ifname:
Code: Select all

NET="-net nic,vlan=0 -net tap,vlan=0,ifname=$IFACE,script=/etc/qemu-ifup"


And the script spits out errors again:

Code: Select all
win2k-qemu
warning: could not open /dev/net/tun: no virtual network emulation
Could not initialize device 'tap'


The above is true before I change permissions on the /dev/net/tun interface. Here is what happens after permissions I changed into 0666:

Code: Select all
win2k-qemu
SIOCSIFADDR: Brak dostępu
SIOCSIFFLAGS: Brak dostępu
SIOCSIFFLAGS: Brak dostępu
SIOCSIFFLAGS: Brak dostępu
can't add tap1 to bridge br0: Operation not permitted
/etc/qemu-ifup: could not launch network script
Could not initialize device 'tap'


"Brak dostepu" means: Access denied.
Well, that is something new. Maybe I should be using "sudo" in the /etc/qemu-ifup script?


Ok, Hurrey!! It works. The addition of "sudo" in the /etc/qemu-ifup script helped.
Thank you guys for having helped me all the way.
I've got more questions but I'll open another thread for that.

Thanks again.
regards,
Benedict
kb2qzv
 
Posts: 11
Joined: Fri Sep 30, 2005 7:55 am


Return to QEMU for Linux

Who is online

Users browsing this forum: No registered users and 1 guest