NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.
Forum Discussion
chirpa
Jul 13, 2009Luminary
Sparc platform development envrionment using Qemu
You can now run a fully emulated Sparc platform development environment on any system capable of running Qemu. Download: readynas_compile_environment.qcow.gz # wget -q http://www.readynas.com/d...
An_Evil_Penguin
Dec 09, 2010Aspirant
I managed to get this running fairly easily in my Ubuntu 10.10 virtual machine (running win 7 pro x64 as a base). What I had real difficulty with was setting up a tap/tun bridge to my external network (for testing updates and patches to the minidlna service more than anything else). The only documentation that QEMU provides (that I was able to find at least) is as follows: http://wiki.qemu.org/Documentation/Networking/Tap Currently this is a bit useless but it may prove useful to people in the future. I managed to get it running in the end using a combination of stuff found through these links:
http://ubuntuforums.org/showthread.php?t=179472
http://compsoc.dur.ac.uk/~djw/qemu.html
http://permalink.gmane.org/gmane.comp.e ... qemu/81839
http://en.wikibooks.org/wiki/QEMU/Networking#qemu-ifup
http://ubuntuforums.org/archive/index.php/t-593577.html <<<<Godsend
As far as I can tell there is no documentation/guides for this on the site so I'm going to document it in this post(if only so I can do it again later when I inevitably forget) and I'm going to try and be as clear as I can about EVERYTHING as most of the tuts I have read in the past tend to assume a base level of knowledge that is (at least in my case) not always there.
To note I am doing this on a virtual machine in Bridge mode and have a router with a DHCP server using Ubuntu 10.10 and Qemu 0.13.0. If you are planing on doing this with static ip addresses you will need to edit your /etc/network/interfaces file (http://compsoc.dur.ac.uk/~djw/qemu.html seems to cover it in at least some depth)
There are some extra packages that need to be installed onto the operating system that do not come with qemu and didn't come with my particular installation of Ubuntu
We need vtun to create our tap interface that Qemu will use to talk to our outside network and bridge-utils to help create the bridge that will allow QEMU to talk to the network rather than just the host.
(Bridges are quite nicely covered here in a qemu context for anyone interested: http://qemu-buch.de/cgi-bin/moin.cgi/Qe ... =%28Tap%29)
Not entirely sure why the uml-utilities are needed, but they are specifically mentioned in one of the tutorials I have read.
Next we have to set up the bridge, set up the tap interface that QEMU will use and then add any connections that we want to use to the bridge
First we set the permissions of the tun device
One of the tutorials has suggested using a new group to manage this but as I am the only person using this VM I couldn't be arsed.
Next we create the bridge and assign a connection to it. The majority will be wanting to use eth0 the usual wired connection but I have done something similar using my laptop and the ath0 wireless interface. You should also note that you will lose network conectivity briefly at this stage
Now we create and enable the tap device that we will be using where dave is the username of the account being used. I used tap0 because it made sense to me and sticks vaguely to existing standards but I believe you can rename it to whatever the hell you want.
The above code either needs to be done every time you wish to use the connection or be put into your /etc/rc.local file to be run at startup. I did the latter because I'm lazy and it doesn't really impact on my system, however if you have programs that are hard coded to rely on the eth0 interface this could cause problems later.
Next we need to create a script to allow qemu to deal with the tap interface (and because it wont let you run the program without it).
This is named qemu-ifup and it exists in the /etc folder (I got this from: http://compsoc.dur.ac.uk/~djw/qemu.html)
and then we need to make sure that this can be executed by all users
Or
if youre just planning to use it yourself
Thats the basics to get things running!
Running Qemu with A tun/tap interface requires root access(sudo) so I've also taken the suggestion of the last link to create a sudoers file, which allows me to run qemu without having to enter my password or switching to a root account. This needs to be done using visudo which is loosely based on vi and isn't particularly user friendly. This can also seriously screw up your instalation if done wrong (as I found out) and require to go back into the recovery mode to fix. In VMware the recovery mode does not seem to be accessible and just dumped me into a standard terminal session without root access so I would highly recomend using snapshots if you aren't doing so already so you can simply revert to an earlier state (also aplies to qemu emulations).
My sudoers file is as follows:
And that is all the preparation I have done to get this running. I can now call the program using the following code and it appears on my local network like any other device:
-m sets the allocated memory to 256MB rather than the default 128
-net nic,vlan=0 -net tap,vlan=0 is the code needed to set qemu to run
As far as I know this is all that is needed to configure to qemu to run in this bridged mode. Any qestions feel free to ask, I only visit infrequently and my knowledge is limited but I will try my best to help.
*Edit: Corrected some typos*
http://ubuntuforums.org/showthread.php?t=179472
http://compsoc.dur.ac.uk/~djw/qemu.html
http://permalink.gmane.org/gmane.comp.e ... qemu/81839
http://en.wikibooks.org/wiki/QEMU/Networking#qemu-ifup
http://ubuntuforums.org/archive/index.php/t-593577.html <<<<Godsend
As far as I can tell there is no documentation/guides for this on the site so I'm going to document it in this post(if only so I can do it again later when I inevitably forget) and I'm going to try and be as clear as I can about EVERYTHING as most of the tuts I have read in the past tend to assume a base level of knowledge that is (at least in my case) not always there.
To note I am doing this on a virtual machine in Bridge mode and have a router with a DHCP server using Ubuntu 10.10 and Qemu 0.13.0. If you are planing on doing this with static ip addresses you will need to edit your /etc/network/interfaces file (http://compsoc.dur.ac.uk/~djw/qemu.html seems to cover it in at least some depth)
There are some extra packages that need to be installed onto the operating system that do not come with qemu and didn't come with my particular installation of Ubuntu
sudo apt-get install vtun
sudo apt-get install bridge-utils
sudo apt-get install uml-utilities
We need vtun to create our tap interface that Qemu will use to talk to our outside network and bridge-utils to help create the bridge that will allow QEMU to talk to the network rather than just the host.
(Bridges are quite nicely covered here in a qemu context for anyone interested: http://qemu-buch.de/cgi-bin/moin.cgi/Qe ... =%28Tap%29)
Not entirely sure why the uml-utilities are needed, but they are specifically mentioned in one of the tutorials I have read.
Next we have to set up the bridge, set up the tap interface that QEMU will use and then add any connections that we want to use to the bridge
First we set the permissions of the tun device
chown root.users /dev/net/tun
chmod g+rw /dev/net/tun
One of the tutorials has suggested using a new group to manage this but as I am the only person using this VM I couldn't be arsed.
Next we create the bridge and assign a connection to it. The majority will be wanting to use eth0 the usual wired connection but I have done something similar using my laptop and the ath0 wireless interface. You should also note that you will lose network conectivity briefly at this stage
brctl addbr br0
ifconfig eth0 0.0.0.0 promisc
brctl addif br0 eth0
dhclient br0
Now we create and enable the tap device that we will be using where dave is the username of the account being used. I used tap0 because it made sense to me and sticks vaguely to existing standards but I believe you can rename it to whatever the hell you want.
tunctl -t tap0 -u dave
brctl addif br0 tap0
ifconfig tap0 up
The above code either needs to be done every time you wish to use the connection or be put into your /etc/rc.local file to be run at startup. I did the latter because I'm lazy and it doesn't really impact on my system, however if you have programs that are hard coded to rely on the eth0 interface this could cause problems later.
Next we need to create a script to allow qemu to deal with the tap interface (and because it wont let you run the program without it).
This is named qemu-ifup and it exists in the /etc folder (I got this from: http://compsoc.dur.ac.uk/~djw/qemu.html)
#!/bin/sh
echo "Executing /etc/qemu-ifup"
echo "Bringing up $1 for Bridged mode..."
sudo /sbin/ifconfig $1 0.0.0.0 promisc up
echo "adding $1 to br0..."
sudo /usr/sbin/brctl addif br0 $1
echo "finished running script"
sleep 2
and then we need to make sure that this can be executed by all users
chmod 755 /etc/qemu-ifup
Or
chmod a+x /etc/qemu-ifup
if youre just planning to use it yourself
Thats the basics to get things running!
Running Qemu with A tun/tap interface requires root access(sudo) so I've also taken the suggestion of the last link to create a sudoers file, which allows me to run qemu without having to enter my password or switching to a root account. This needs to be done using visudo which is loosely based on vi and isn't particularly user friendly. This can also seriously screw up your instalation if done wrong (as I found out) and require to go back into the recovery mode to fix. In VMware the recovery mode does not seem to be accessible and just dumped me into a standard terminal session without root access so I would highly recomend using snapshots if you aren't doing so already so you can simply revert to an earlier state (also aplies to qemu emulations).
My sudoers file is as follows:
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#
# Host alias specification
# User alias specification
# Cmnd alias specification
Cmnd_Alias QEMU=/sbin/ifconfig, \
/sbin/modprobe, \
/usr/sbin/brctl
# User privilege specification
root ALL=(ALL) ALL
dave ALL=NOPASSWD: QEMU
And that is all the preparation I have done to get this running. I can now call the program using the following code and it appears on my local network like any other device:
sudo qemu-system-sparc -hda readynas_compile_environment.qcow -nographic -m 256 -net nic,vlan=0 -net tap,vlan=0
-m sets the allocated memory to 256MB rather than the default 128
-net nic,vlan=0 -net tap,vlan=0 is the code needed to set qemu to run
As far as I know this is all that is needed to configure to qemu to run in this bridged mode. Any qestions feel free to ask, I only visit infrequently and my knowledge is limited but I will try my best to help.
*Edit: Corrected some typos*
Related Content
NETGEAR Academy

Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology!
Join Us!