pkgsrc/sysutils/xentools3/files/vif-bridge-nbsd
jym 6a17885159 Add support for "vifname" keys inside XenStore. Its value is the
interface name for the vif, e.g. xvif(4) for dom0, and xennet(4)
for domU.

This allows querying the XenStore for the vif names, rather than
hardcoding their syntax in vif-* scripts.

Add a xen-subr shell script that can contain customized functions, and
include it in the vif-ip/vif-bridge scripts.
Introduce xenstore_read_default that returns the value of a specific
key from XenStore, or the default specified value when key is absent.

Bump revision.

ok bouyer@.

See http://mail-index.netbsd.org/port-xen/2011/01/11/msg006405.html
2011-01-12 00:11:19 +00:00

38 lines
794 B
Bash

#!/bin/sh -e
# $NetBSD: vif-bridge-nbsd,v 1.2 2011/01/12 00:11:19 jym Exp $
# Called by xenbackendd
# Usage: vif-bridge xsdir_backend_path state
dir=$(dirname $0)
. "$dir/xen-subr"
PATH=/bin:/usr/bin:@PREFIX@/bin:/sbin:/usr/sbin:@PREFIX@/sbin
export PATH
xpath=$1
xstatus=$2
case $xstatus in
6)
# device removed
xenstore-rm $xpath
exit 0
;;
2)
xbridge=$(xenstore-read "$xpath/bridge")
xfid=$(xenstore-read "$xpath/frontend-id")
xhandle=$(xenstore-read "$xpath/handle")
iface=$(xenstore_read_default "$xpath/vifname" "xvif$xfid.$xhandle")
echo ifconfig $iface up
ifconfig $iface up
brconfig $xbridge add $iface
echo brconfig $xbridge add $iface
xenstore-write $xpath/hotplug-status connected
echo xenstore-write $xpath/hotplug-status connected
exit 0
;;
*)
exit 0
;;
esac