KVM and VLAN bridging
There are not many articles about how to use VLANs with virtualization using qemu and libvirt on Linux. With wide spreading VLAN capable switches this may come handy to use the VLANs with virtuals too.
Best article I found was probably KVM & BRCTL in Linux – bringing VLANs to the guests that has very nice illustrations. However I wanted as simple setup as forwarding all VLANs coming to host system to guests, but I also needed to have the VLANs available at host. I did not want to use VLANs for guest separation as they are usually used.
The best way to achieve this is to have two ethernet cards on the host. Then the eth0 is used for guests and the eth1 is used for host only. The only trick is, you have to "enable" VLANs on eth0 by activating at least one (unused) VLAN (e.g. vlan 0) on this iface.
The setup on host is like this
vconfig add eth0 0
brctl addbr br0
brctl addif br0 eth0
vconfig add eth1 3000
vconfig add eth1 3001
etc.
The switch the host is connected to is then setup like
interface ethernet 1/1
description host eth0
switchport allowed vlan add 3000-3100 tagged
interface ethernet 1/2
description host eth1
switchport allowed vlan add 3000-3100 tagged
You can not have VLAN 3000 on hosts eth0 and pass it to the guest too. As soon as any VLAN is on the bridged interface it is "consumed" there and is not passed further to the bridge.
Further readings: