set tap0 using virt-manager for bridged wireless

After 3 days I finally have kvm guests working on the network via wireless (link below - thanks!):

My network is 192.168.1.0/24

on the host:

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo tunctl -t tap0
sudo ip link set tap0 up
sudo ip addr add 192.168.1.25/24 dev tap0
sudo route add -host 192.168.1.30 dev tap0
sudo parprouted wlan0 tap0

on the guest:

auto eth0
iface eth0 inet static
  address 192.168.1.30
  netmask 255.255.255.0
  network 192.168.1.0
  broadcast 192.168.1.255
  gateway 192.168.1.25

and start the guest:

sudo kvm /path/to/guest.img -net nic,macaddr=DE:AD:BE:EF:90:26 -net tap,ifname=tap0,script=no

This works great and I can ping the local network and the internet back and forth between the guest.

But how do I add these settings to the guest's xml config so I can start the guest via virt-manager with the same nic settings?

ref:

  • http://www.linuxquestions.org/questions/debian-26/kvm-wireless-bridge-network-691953/

Solution 1:

try to follow this: libwirtwiki - guest tap

and fix /etc/libvirt/qemu/example.xml

<interface type='ethernet'>
  <mac address='26:c7:a9:96:a7:7a'/>
  <target dev='tap0'/>
  <model type='virtio'/>
  <script path='no'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>

in my case it works