qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-discuss] need help in setting up tap networking for using qemu vir


From: Chan Kim
Subject: [Qemu-discuss] need help in setting up tap networking for using qemu virtual machine
Date: Thu, 18 Sep 2014 13:00:31 +0000

Hello, everyone!

It's good to have some people to ask this.. I really need a help from you and 
this should be a basic question.
I'm trying to run a virtual machine (using qemu-system-sparc, I added lan9220 
emulation model inside) on my CentOS 6.4 machine.
I've read 
[url]http://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/centos-6-and-kvm-how-to-setup-bridged-networking-in-kvm-in-a-class-b-environment-4175433990/[/url]
 but my case seems different and I am not sure if this previous post is correct 
or not.

My host ip is 129.254.132.47. and I want my virtual machine to be 
129.254.132.48. (it's class B network)

I have /etc/qemu-ifup like this

--------------------- start -------------------------
#!/bin/sh
#
# script to bring up the tun device in QEMU in bridged mode
# first parameter is name of tap device (e.g. tap0)
#
# some constants specific to the local host - change to suit your host
#
# guest 132.48  host 132.47   bridge 132.64
set -x
ETH0IP=129.254.132.47
GATEWAY=129.254.132.1
BROADCAST=129.254.255.255
#
# First take eth0 down, then bring it up with IP address 0.0.0.0
#
/sbin/ifdown eth0
/sbin/ifconfig eth0 0.0.0.0 promisc up
#
# Bring up the tap device (name specified as first argument, by QEMU)
#
/usr/sbin/openvpn --mktun --dev $1 --user `id -un`
/sbin/ifconfig $1 0.0.0.0 promisc up
#
# create the bridge between eth0 and the tap device
#
/usr/sbin/brctl addbr br0
/usr/sbin/brctl addif br0 eth0
/usr/sbin/brctl addif br0 $1
#
# only a single bridge so loops are not possible, turn off spanning tree 
protocol
#
/usr/sbin/brctl stp br0 off
#
# Bring up the bridge with ETH0IP and add the default route
#
/sbin/ifconfig br0 $ETH0IP netmask 255.255.0.0 broadcast $BROADCAST
/sbin/route add default gw $GATEWAY
#
# stop firewall - comment this out if you don't use Firestarter
#
#/sbin/service firestarter stop
--------------------- end -------------------------

and /etc/qemu-ifdown as

------------------- start --------------------------
#!/bin/sh 
# 
# Script to bring down and delete bridge br0 when QEMU exits 
# 
# Bring down eth0 and br0 
#
set -x
/sbin/ifdown eth0
/sbin/ifdown br0
/sbin/ifconfig br0 down
# 
# Delete the bridge
#
/usr/sbin/brctl delbr br0
# 
# bring up eth0 in "normal" mode 
#
/sbin/ifconfig eth0 -promisc
/sbin/ifup eth0
#
# delete the tap device
#
/usr/sbin/openvpn --rmtun --dev $1
#
# start firewall again
# 
#/sbin/service firestarter start 
-------------------- end --------------------------

and I start my virtual machine with this command :

qemu-system-sparc -M ALDEBARAN -serial stdio -kernel 
telnetd/o-optimize/telnetd.exe -net nic -net tap,ifname=tap0
(this makes /etc/qemu-ifup tap0 and /etc/qemu-ifdown tap0 run before and after 
qemu run.)

When I run above command, I can see the virtual machine's code is running. 
(it's RTEMS network-demo program. telnetd.exe)
From outside the host, I can ping to host and the guest. So I thought 
everything is fine But I then I found something is wrong..
When I telnet to 129.254.132.47, it is centOS as expected.
But when I telnet to 129.254.132.48, it takes unusually long (like 10 seonds?) 
then I see the loging prompt coming from CentOS.(the host)
I can log into it, and it's my host machine.
(By the way, both telnetting looked hampered by something, like interfering one 
another by wrong setting..)

I can run the same telnetd program using actual board the qemu emulator is 
emulating, and I can telnet to the board (and of course it's RTEMS). Only, when 
using actual board, I use physical network cable between my host and the board. 
(host 10.10.10.1 and the board 10.10.10.11)

I tried setting ETH0IP to 129.254.132.47 in qemu-ifup script but it didn't 
work. 

Please anyone tell me what the problem is..

Kind regards, 
Chan Kim

reply via email to

[Prev in Thread] Current Thread [Next in Thread]