Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BxMCK-00081p-Ob for qemu-devel@nongnu.org; Wed, 18 Aug 2004 04:53:32 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BxMCI-00081L-ON for qemu-devel@nongnu.org; Wed, 18 Aug 2004 04:53:31 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BxMCI-000816-Fg for qemu-devel@nongnu.org; Wed, 18 Aug 2004 04:53:30 -0400 Received: from [217.162.225.166] (helo=mungo.pingu.priv) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BxM7y-0006Qu-B1 for qemu-devel@nongnu.org; Wed, 18 Aug 2004 04:49:02 -0400 Received: from localhost (localhost [127.0.0.1]) by mungo.pingu.priv (Postfix) with ESMTP id E1BB2D082 for ; Wed, 18 Aug 2004 10:48:59 +0200 (CEST) Received: from mungo.pingu.priv ([127.0.0.1]) by localhost (mungo [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 05044-06 for ; Wed, 18 Aug 2004 10:48:57 +0200 (CEST) Received: from localhost (mungo.pingu.priv [192.168.100.5]) by mungo.pingu.priv (Postfix) with ESMTP id AFBC4D05B for ; Wed, 18 Aug 2004 10:48:56 +0200 (CEST) From: "Till R. Dierkesmann" Date: Wed, 18 Aug 2004 10:48:56 +0200 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_4fxIB6Zhl87iv+Z" Message-Id: <200408181048.57147.t.dierkesmann@freesurf.ch> Subject: [Qemu-devel] QEMU TUN error with SuSE Linux howto fix Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --Boundary-00=_4fxIB6Zhl87iv+Z Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi together I've tested the QEMU 0.6 software - it works great. With a workaround I even could install OS/2. For installing Windows 95/98 I needed disks, the startup from CD didn't work. Is that normal or did I do something wrong? Windows 95 - Boot from floppy - Windows 95 does not recognize the network card automatically. Where can I get a driver for the NE2000 card (or Realtek 8029 chip)? Windows 98 - Boot from floppy, Installation ok. How to install OS/2 Warp: - Booting from CDRom is not possible. Use the three floppy disks (or copy them as image). - Sometimes the steps passing through the disks has to be repeated, because the QEMU system hung after the start of the third disk. - The sound card SB16 has to be selected manually. The screen resolution can't be changed to anything else except 640x480, because the system denies using another driver except VGA. Additionally after the beginning of the installation a crash box appeared within OS/2, but it can be closed and the installation goes on. - "-localtime" must be supplied for having correct time settings (I use UTC on my Linux boxes) Windows 2000: - Installation completed successful without interruption, but it lasted a very long time (3 hours on 1.6Ghz machine). I had to prepare a file in the correct size before the installation succeeded without storage trouble. For being able to use other stuff on the machine I had to renice the qemu process down to 19. Some testing resumed in the theory, that the renice did not interfere with the Windows performance too much. Windows XP - The installation proceeded successful, but very slow (3.5 hours). Even here I reniced the process to 19. The main issue seems to be that some stuff is executed so slow that the program seems to consume nearly no cpu time, the renice is not responsible for the slowlyness. When closing the final black window the curious registration key error occurs after restarting. SuSE Linux 8.1/9.0 - Installation ok. SuSE Linux 9.1 - Installation hangs before the startup of YaST, when trying on QEMU for windows (with the japanese patch) - ok, probably I was too unpatient. On Linux ok. The two original scripts which I got for tun are added for comparison issues. 1) Networking with TUN The tun network stuff has a the information within the script, that /dev/net/ tun should be writable by the user. The quickest solution to solve the seemed to grant _write_ access to /dev/net/tun to all local users. By adding the following commands at the beginning of qemu-ifup-sudo.sh it is done automatically: chgrp users /dev/net/tun chmod g+w /dev/net/tun 2) DHCP DHCP didn't start properly. When analyzing I found that the problem seems to be that the script works for older dhcp daemons, but not for the daemons supplied with SuSE 8.1 and 9.0. They need an additional line like: ddns-update-style ad-hoc; So I changed the script (lines with "a>" added and with "c>" changed): a> echo "ddns-update-style ad-hoc;" > /tmp/qemu-dhcpd-$$.conf for N in `seq 40 50` ; do T_NET=192.168.$N.0 T_HOST=192.168.$N.1 T_RANGE="192.168.$N.2 192.168.$N.100" echo "subnet $T_NET netmask 255.255.255.0 {" echo " option domain-name-servers $T_HOST;" echo " option routers $T_HOST;" echo " range $T_RANGE;" echo "}" c> done >> /tmp/qemu-dhcpd-$$.conf 3) second session Additionally, when starting a second qemu session, it doesn't get an IP. The main issue is, that it tries to connect to a further tunX card, but didn't give it an ip. The tun parameter hadn't provided in the sudo script "sudo_qemu-ifup-sudo.sh". The parameter has to be forwarded: sudo /usr/local/bin/qemu-ifup-sudo.sh $* The path /etc had been used for the scripts, but imho within /etc there should be no programs/procedures, so I have moved them to /usr/local/bin) Again - thank you, Fabrice, very much for your great work! Friendly regards, Till -- .--. |o_o | |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=(___/ --Boundary-00=_4fxIB6Zhl87iv+Z Content-Type: application/x-shellscript; name="qemu-ifup-sudo.sh" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="qemu-ifup-sudo.sh" #!/bin/bash # ########################################################################### # Configuration of the tunN devices for usage with QEMU. # # Based on the tunconfig script from MOL. # # This script should be named /etc/qemu-ifup-sudo # # To use this script you must have... # # 0) kernel support for TUN devices # # 1) the device node /dev/net/tun with read/write permissions # # 2) invoked qemu with TUN support (this is the default) # # 3) configured /etc/sudoers to let you run this script # # An example /etc/sudoers entry for (3) would be: # # myself ALL=/etc/qemu-ifup-sudo # # If your linux box is configured as a firewall or a DHCP server or a # router then you don't want to be running this script. # # Fabrice is working on a user-net implementation that will eventually # obsolete this script. # ############################################################################# PROVIDE_DHCP=yes DNS_REDIRECT=yes IFCONFIG=/sbin/ifconfig IPTABLES=/usr/sbin/iptables DHCPD=/usr/sbin/dhcpd # uncomment to override nameserver autodetection # NAMESERVER=10.0.0.1 #################################################################### TUN_DEV=${1:-tun0} ACTION=${2:-up} TUN_NUM=`echo $TUN_DEV | sed s/[^0-9]//g` NET_NUM=`expr 40 + $TUN_NUM` TUN_NET=192.168.$NET_NUM.0 TUN_HOST=192.168.$NET_NUM.1 chgrp users /dev/net/tun chmod g+w /dev/net/tun ######################################################### # Misc Checks ######################################################### [ -x $IFCONFIG ] || { echo "---> fatal: $IFCONFIG not installed" 1>&2 exit 1 } [ -x $DHCPD ] || { echo "---> warning: $DHCPD not installed" 1>&2 PROVIDE_DHCP=no } [ -x $IPTABLES ] || { echo "---> fatal: $IPTABLES not installed" 1>&2 exit 1 } $IPTABLES -L -n -t nat > /dev/null || { echo "---> fatal: $IPTABLES indicates no NAT support" 1>&2 exit 1 } [ -e /proc/sys/net/ipv4/ip_forward ] || { echo "---> fatal: you don't have /proc/sys/net/ipv4/ip_forward" 1>&2 exit 1 } ######################################################### # Remove old (possibly stale) ruleset ######################################################### { $IPTABLES -t nat -D POSTROUTING -s $TUN_NET/24 -d ! $TUN_NET/24 -j MASQUERADE $IPTABLES -t nat -D PREROUTING -p tcp -i $TUN_DEV -d $TUN_HOST --dport 53 -j qemu-dns $IPTABLES -t nat -D PREROUTING -p udp -i $TUN_DEV -d $TUN_HOST --dport 53 -j qemu-dns $IPTABLES -t nat -F qemu-dns } >& /dev/null ######################################################### # Bring down interface ######################################################### [ "$ACTION" = down ] && { $IFCONFIG $TUN_DEV down } ######################################################### # Configure interface ######################################################### [ "$ACTION" = up ] && { # the dhcpd server can get stuck if the QEMU side of the # tun device is shutdown uncleanly [ -f /var/run/dhcpd.pid -a "$PROVIDE_DHCP" = yes ] && { echo "kill -9 stale dhcpd server" kill -9 `cat /var/run/dhcpd.pid` > /dev/null 2>&1 } # configure the interface $IFCONFIG $TUN_DEV $TUN_HOST # masquerade the tun network $IPTABLES -t nat -A POSTROUTING -s $TUN_NET/24 -d ! $TUN_NET/24 -j MASQUERADE # DNS redirection [ "$DNS_REDIRECT" = yes ] && { [ ! "$NAMESERVER" ] && { NAMESERVER=`grep ^nameserver /etc/resolv.conf | awk -- '{ print $2 ; exit 0; }'` [ ! "$NAMESERVER" ] && { echo "Could not determine the nameserver (localhost is used)." NAMESERVER=$TUN_HOST } } # create a table for DNS redirection $IPTABLES -t nat -N qemu-dns 2> /dev/null $IPTABLES -t nat -A qemu-dns -j DNAT --to $NAMESERVER # redirect tcp/udp port 53 (nameserver queries) $IPTABLES -t nat -A PREROUTING -p tcp -i $TUN_DEV -d $TUN_HOST --dport 53 -j qemu-dns $IPTABLES -t nat -A PREROUTING -p udp -i $TUN_DEV -d $TUN_HOST --dport 53 -j qemu-dns } } ######################################################### # Generate DHCP configuration file ######################################################### echo "ddns-update-style ad-hoc;" > /tmp/qemu-dhcpd-$$.conf for N in `seq 40 50` ; do T_NET=192.168.$N.0 T_HOST=192.168.$N.1 T_RANGE="192.168.$N.2 192.168.$N.100" echo "subnet $T_NET netmask 255.255.255.0 {" echo " option domain-name-servers $T_HOST;" echo " option routers $T_HOST;" echo " range $T_RANGE;" echo "}" done >> /tmp/qemu-dhcpd-$$.conf ######################################################### # Start the DHCP and IP forwarding ######################################################### IFACES=`netstat -i | sed -n -e 's/^\(tun[0-9]\).*/\1/gp'` if [ "$IFACES" ] ; then [ "$PROVIDE_DHCP" = yes ] && $DHCPD -q -cf /tmp/qemu-dhcpd-$$.conf $IFACES echo 1 > /proc/sys/net/ipv4/ip_forward else $IPTABLES -t nat -X qemu-dns >& /dev/null echo 0 > /proc/sys/net/ipv4/ip_forward fi exit 0 --Boundary-00=_4fxIB6Zhl87iv+Z Content-Type: application/x-shellscript; name="sudo_qemu-ifup-sudo.sh" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="sudo_qemu-ifup-sudo.sh" #!/bin/sh sudo /usr/local/bin/qemu-ifup-sudo.sh $* --Boundary-00=_4fxIB6Zhl87iv+Z--