libvirt 钩子 qemu suse12

libvirt 钩子 qemu suse12

我们有这个 qemu 钩子。在 suse 11 中运行良好,但在 suse 12 中却无法正常工作。钩子正在设置 openvswitch native-untagged 中的端口。您是否知道 suse 12 中是否缺少一些 libvirt 配置才能使钩子正常工作?我们使用的是这个版本的 libvirt:libvirtd (libvirt) 1.2.5

谢谢,BR/ Cristina

#!/bin/bash

#/etc/libvirt/hooks/qemu
domain_name="$1"
domain_task="$2"

# Create temporary file to hold the configuration.
guest_cfg=`mktemp`

function cleanup() {
  if [ -n "$guest_cfg" ]; then
   rm -f $guest_cfg
  fi
}

trap cleanup EXIT

function ovs_untag_port() {
  # Read XML configuration on stdin.
  cat - > $guest_cfg
  ifaces=`xpath $guest_cfg         

"count(//devices/interface[@type='network']/target[@dev])" 2>/dev/null`
 for i in `seq 1 $ifaces`; do
 interface=`xpath $guest_cfg "//devices/interface[$i]  

[@type='network']/target[@dev]" 2>/dev/null | cut -d \" -f2`
echo ${interface}
ovs-vsctl set port ${interface} vlan_mode=native-untagged
 done
 cleanup

}


case "${domain_task}" in
  prepare)
    ovs_untag_port
    ;;
  start)
    ;;
  started)
    ovs_untag_port
    ;;
  stopped)
    ;;
  release)
    ;;
  migrate)
    ;;
  restore)
    ;;
  reconnect)
    ;;
  attach)
    ;;
  *)
    exit 0
    echo "qemu hook called with unexpected options $*" >&2
    ;;
esac

exit 0

相关内容