On qemu-kvm, qemu-ifup script not found on Slackware 13
Linux - Virtualization and CloudThis forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
On qemu-kvm, qemu-ifup script not found on Slackware 13
I have successfully installed qemu-kvm from Slackbuild.org on a Slackware 13 and created two Win xp virtual machines and one with Gentoo, however i'm not able to conect my Guest OS network with my host.
and create a qemu-ifup script and place it under /etc with the permissions an all, however it doesn't seen to be found by qemu, so where does qemu searches for qemu-ifup on Slackware?
IMHO the best way to do this is to install the tunctl package from Slackbuilds and use tap interfaces with brctl to gain access to your LAN. Then your guest and hosts will be able to see each other.
Thanks for answering, i already downloaded the tun package, loaded the tun module and created a bridge, but my problem is with the qemu-ifup script which is not found by qemu, what i want to know is where does qemu search the qemu-ifup script by default (on Slackware 13) since it is certainly that is not looking for it on the /etc folder.
I have also try with the -net tap "script" option, but couldn't set the network connection, this option also mess up the internet connection of my host and guest, just in case this is my qemu-ifup script
#!/bin/sh
set -x
switch=br0
echo "entre"
if [ -n "$1" ];then
tunctl -u 'whoami' -t $1
ip link set $1 up
sleep 0.5s
brctl addif $switch $1
exit 0
else
echo "Error: no interface specified"
exit 1
fi
I wrote my own network script to start and stop the bridge and tap interfaces. I use it with both 32 & 64 bit Slackware 13 installations. I use dhclient instead of dhcpcd so you'll need to reset your rc.inet1.conf so USE_DHCP[0]="" and dhcpcd doesn't start up.
look at the man page for qemu-kvm to find out where the qemu-ifup script should go, for example on debian
Code:
$ man kvm
...
FILES
/etc/kvm/kvm-ifup, called at startup to configure the host-side network
/usr/share/kvm/, BIOS files are by default loaded from this directory
/usr/share/kvm/keymaps, keymap files
...
However there is still an error in your script.
Can you monitor the output of dmesg while you setup your tap device and add it the bridge and post the contents here? The output should look like this:
Code:
[61795.121139] device tap1 entered promiscuous mode
[61795.121145] br0: port 3(tap1) entering learning state
[61804.505539] br0: topology change detected, propagating
[61804.505543] br0: port 3(tap1) entering forwarding state
[61806.052285] tap1: no IPv6 routers present
Does qemu/qemu-kvm/kvm --help give you the default location for the script.
Example:
Code:
hostname 'host' to DHCP clients
-net tap[,vlan=n][,fd=h][,ifname=name][,script=file][,downscript=dfile]
connect the host TAP network interface to VLAN 'n' and use the
network scripts 'file' (default=/etc/kvm/kvm-ifup)
OK, well let's leave the default location until someone with slackware comes along, or I can engage my backside long enough to get a slackware vm going.
Can you elaborate more on this please:
Code:
I have also try with the -net tap "script" option, but couldn't set the network connection, this option also mess up the internet connection of my host and guest, just in case this is my qemu-ifup script
Your script looks ok to me, however most scripts prefer to use ifconfig rather than ip.
the script option simply overrides the default so we need to face the second issue regardless of whether we can find the default location.
I installed slackware 13, a full install with the exception of kde, kdei and emacs, I also installed tunctl and qemu-kvm from slackbuild.org. So hopefully I have a setup pretty similar to yours.
From `qemu --help`:
Quote:
-net tap[,vlan=n][,name=str][,fd=h][,ifname=name][,script=file][,downscript=dfile][,sndbuf=nbytes][,vnet_hdr=on|off]
connect the host TAP network interface to VLAN 'n' and use the
network scripts 'file' (default=/etc/qemu-ifup)
and 'dfile' (default=/etc/qemu-ifdown);
ok, so I made a file /etc/qemu-ifup and added your script, from that tutorial you linked to, and made the file executable. I then created a bridge and added my physical device to it and got a new ip for the bridge. The commands are as follows:
Code:
# cat << eof > /etc/qemu-ifup
> #!/bin/sh
> set -x
>
> switch=br0
>
> if [ -n "$1" ];then
> tunctl -u 'whoami' -t $1
> ip link set $1 up
> sleep 0.5s
> brctl addif $switch $1
> exit 0
> else
> echo "Error: no interface specified"
> exit 1
> fi
> eof
# chmod +x /etc/qemu-ifup
# ifconfig eth0 0.0.0.0
# brctl addbr br0
# brctl addif br0 eth0
# dhclient br0
# qemu -net nic -net tap -cdrom /tmp/dsl-4.4.10.iso -vnc :0
Now that gave an error saying the tap device is busy, and the reason is because qemu creates the tap device for you and passes the name of that to the script, so your script needs to be modified to look like this:
Code:
#!/bin/sh
set -x
switch=br0
if [ -n "$1" ];then
ip link set $1 up
sleep 0.5s
brctl addif $switch $1
exit 0
else
echo "Error: no interface specified"
exit 1
fi
After that change, everything works perfectly. Here is the output from running qemu with the new script:
Code:
# qemu -net nic -net tap -cdrom /tmp/dsl-4.4.10.iso -vnc :0
open /dev/kvm: No such file or directory
Could not initialize KVM, will disable KVM support
+ switch=br0
+ '[' -n tap0 ']'
+ ip link set tap0 up
+ sleep 0.5s
+ brctl addif br0 tap0
+ exit 0
Please disregard the errors about KVM, that won't change anything. The reason kvm support doesn't work here is because I'm running Slackware in a vm.
I installed slackware 13, a full install with the exception of kde, kdei and emacs, I also installed tunctl and qemu-kvm from slackbuild.org. So hopefully I have a setup pretty similar to yours.
Above and beyond! Nicely done Phil.
I learned a bit more about KVM tap networking with your post.
It's not as impressive as it sounds. All this was done in a virtual machine, less than an hours work all in. Plus it was worth it from my pov to see how Slackware had changed from 9 or 10 when I last used it.
Just a few more notes:
The above assumes your running qemu as root, something I don't actually do in practice. However the qemu-ifup script quoted by the OP assumes qemu is running as root. When run as root, qemu doesn't actually require tunctl as it creates and destroys the tap devices.
However, if you want to run qemu as a normal user then you'll need tunctl and the ability to run that as root, normally via sudo. You will need to use tunctl before you run qemu and pass the tap device to qemu, then destroy it once qemu exits. For example
#!/bin/sh
set -x
switch=br0
if [ -n "$1" ];then
sudo ip link set $1 up
sleep 0.5s
sudo brctl addif $switch $1
exit 0
else
echo "Error: no interface specified"
exit 1
fi
However I prefer to do everything in a wrapper/manager script, create the tap device, add it the bridge launch qemu, then cleanup after. In this case qemu is run somewhat like this:
Code:
qemu -net nic -net tap,ifname=$tap,script=no,downscript=no ...
I'll post the script if there is any interest, but it doesn't accomplish anything something like libvirt doesn't, and libvirt does much more. However, it doesn't require a daemon to be running all the time, and a vm config file is much simpler.
Happy new year!!!
I followed your instructions and they work marvelously.
About:
Quote:
Originally Posted by phil.d.g
OK, well let's leave the default location until someone with slackware comes along, or I can engage my backside long enough to get a slackware vm going.
Can you elaborate more on this please:
I though that qemu could search for a qemu-ifup script by default in /etc simply by using
Code:
qemu-system-x86_64 vdisk.img
Thanks to your reply I realize i was wrong since it need the -net tap option to search for the ifup script, the script option i was talking about is the the one that change the qemu-ifup path.
Quote:
Originally Posted by phil.d.g
Please disregard the errors about KVM, that won't change anything. The reason kvm support doesn't work here is because I'm running Slackware in a vm.
After the installation of tuncl and qemu-kvm, slackware doesn't load their modules by default so you have to load then manually, in my case i add then on the /etc/rc.d/rc.modules
Code:
/sbin/modprobe kvm
/sbin/modprobe kvm-intel
/sbin/modprobe tun
After loading these modules the folder /dev/kvm is created
Of course, this is not your case since you are using a vm, but if you got this error on a slackware host this might be the reason.
In case anyone need then later this are my qemu-ifup script
Code:
#!/bin/sh
set -x
switch=br0
sudo ifconfig eth0 0.0.0.0
sudo brctl addbr $switch
brctl addif $switch eth0
sudo dhclient $switch
echo "entre"
if [ -n "$1" ];then
sudo ip link set $1 up
sleep 0.5s
sudo brctl addif $switch $1
exit 0
else
echo "Error: no interface specified"
exit 1
fi
and my qemu-ifdown script
Code:
#!/bin/sh
echo "entre"
ETHX=eth0
sudo ifconfig ${ETHX} down
sudo ifconfig br0 down
# Delete the bridge
sudo brctl delbr br0
# bring up eth0 in "normal" mode
sudo ifconfig ${ETHX} 0.0.0.0
sudo dhclient
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.