Wednesday, April 16, 2008

Qemu networking

I have been fretting over this issue for a while now. Have finally worked out how to give qemu a network connection that joins with a bridge and thereby a connection to the host.

Qemu can create a tap interface that does all this magic networky stuff. It does work... :)

Write 2 network scripts as below: ( don't forget the chmod +x on each file. )

[root@sitedesign ~]# cat /etc/qemu-ifdown
/sbin/ifconfig virbr0 down
/sbin/ifconfig down $1
/sbin/ifup eth0

[root@sitedesign ~]# cat /etc/qemu-ifup
/sbin/ifconfig $1 promisc up
/usr/sbin/brctl addif virbr0 $1

Then to start the VM:

as root:
#~> qemu-kvm -net nic,vlan=0 -net,tap,vlan=0 -hda winxp.img -hdb winxp_disk2.img -usb -usbdevice tablet -localtime -daemonize

That should start you up with a connection to the default virbr that gets made by fedora at boot time.