/etc/kvm/kvmtap
kvm-ifupはブリッジを勝手に選んでしまうため、シンボリックリンクでブリッジを指定できるスクリプトを書きました。
#!/bin/bash # /etc/kvm/kvmtap: TAP device wrapper for KVM cmd="`basename "$0"`" spec="${cmd#*-}" iface="${spec#*-}" operation="${spec%-*}" case "$operation" in "up") logger -t kvm "adding interface ($1) to bridge ($iface)" /sbin/ifconfig "$1" up /sbin/brctl addif "$iface" "$1" ;; "down") logger -t kvm "removing interface ($1) to bridge ($iface)" /sbin/ifconfig "$1" down /sbin/brctl delif "$iface" "$1" ;; *) logger -t kvm "invalid arguments ($1, $iface, $operation)" exit 1; esac
下記のようにシンボリックリンクを張ります。
# ll /etc/kvm/ -rwxr-xr-x 1 root root 463 Jul 20 21:44 kvmtap lrwxrwxrwx 1 root root 6 Jul 20 21:33 kvmtap-down-hub0 -> kvmtap lrwxrwxrwx 1 root root 6 Jul 20 21:33 kvmtap-down-hub1 -> kvmtap lrwxrwxrwx 1 root root 6 Jul 20 21:32 kvmtap-up-hub0 -> kvmtap lrwxrwxrwx 1 root root 6 Jul 20 21:32 kvmtap-up-hub1 -> kvmtap
<interface type='ethernet'> <mac address='52:54:00:df:3b:cb'/> <script path='/etc/kvm/kvmtap-up-hub0'/> <downscript path='/etc/kvm/kvmtap-down-hub0'/> <target dev='tap0'/> <model type='virtio'/> </interface>