LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   qemu tun/tap problem running from qemu on slackware 14.2 64bit (https://www.linuxquestions.org/questions/slackware-14/qemu-tun-tap-problem-running-from-qemu-on-slackware-14-2-64bit-4175590042/)

timsoft 09-23-2016 04:28 PM

qemu tun/tap problem running from qemu on slackware 14.2 64bit
 
running on slackware 14.2 64bit
Hi all, I have created a bridge (editing rc.inet1.conf ) giving it the ip that the eth0 used to have, and the host machine networks ok.
running
Code:

qemu-system-x86_64 -cpu qemu64 -m 4G -drive /data/images/slack14.2_64bit_base.qcow2 -boot c -net nic,vlan=0,model=i82551 -net tap,vlan=0,ifname=tap0 -enable-kvm -display gtk
with the following for /etc/qemu-ifup and /etc/qemu-ifdown
Code:

#!/bin/sh
echo "create $1"
/usr/sbin/openvpn --mktun --dev $1 --user `id -un`
/sbin/ifconfig $1 0.0.0.0 promisc up
echo "add $1 to br0"
/usr/sbin/brctl addif br0 $1

and

Code:

#!/bin/sh
echo "remove $1 from bridge br0"
brctl delif br0 $1
echo "remove device $1"
/usr/sbin/openvpn --rmtun --dev $1

i get the error message
Quote:

cannot ioctl tunsetiff tap0 device or resource busy (errno=16)
on creation of the tap device.

if I manually run
Code:

/etc/qemu-ifup
then
Code:

/etc/qemu-ifdown
I get no error messages at all.

I should say that the scripts are executable and I am running everything as root.

I can't see why the script doesn't work when called by qemu-system-x86_64 yet works fine when called directly. The echo statements just allow me to witness the script being called from either method, ie. are just for debugging.
Has anyone got any ideas how to sort this?
I should also say that the rest of the virtual machine appears to run just fine.

atelszewski 09-23-2016 04:57 PM

Hi,

Instead of using OpenVPN to create the tun device, you might try the tool that is made specifically for that purpose: tunctl, although I have no idea if it's gonna solve your problem.

My blind guess would be that openvpn command somehow interferes, but that's only a guess.

BTW, maybe this would be of help? It's another method for doing what you want; the helper program is installed under: /usr/libexec/qemu-bridge-helper

--
Best regards,
Andrzej Telszewski

slacker1337 09-23-2016 06:13 PM

I avoid the ifup/down scripts and just use the qemu-bridge-helper to create my qemu VM network devices. Just
Code:

chmod u+s /usr/libexec/qemu-bridge-helper
and add "allow br0" to /etc/qemu/bridge.conf.
Code:

qemu-system-x86_64 -m 512 -net nic -net bridge,br=br0

timsoft 09-24-2016 03:29 AM

thanks guys, I'll give it a go and report back; ( although it would be nice to know why one method seems broken.)
I installed qemu using sbopkg, just for reference.
The main objective is to have the vm's on the same lan as the real lan, with the same ip4 mask, so to all intents and purposes, they are just local pc's.

timsoft 09-24-2016 12:50 PM

the -net bridge,br=br0 works just fine, thanks slacker1337 and atelszewski
I had to create the /etc/qemu directory as it didn't exist, and then add the
Code:

allow br0
to bridge.conf as mentioned.

slacker1337 09-25-2016 07:46 PM

Glad to hear you got it working! Enjoy!


All times are GMT -5. The time now is 02:18 AM.