···11+From 4893cc08acc81bfc2f8730ea108574aedae909aa Mon Sep 17 00:00:00 2001
22+From: Fernando Rodrigues <alpha@sigmasquadron.net>
33+Date: Fri, 4 Jul 2025 20:09:06 +0000
44+Subject: [PATCH 2/2] xen/tools/hotplug/Linux: patch external binary calls
55+66+This patch replaces all instances of executable calls and static FHS
77+paths in the hotplug scripts with at-padded variables that can be
88+replaced by replaceVars during a Nix build.
99+1010+Signed-off-by: Fernando Rodrigues <alpha@sigmasquadron.net>
1111+1212+diff --git a/tools/hotplug/Linux/block b/tools/hotplug/Linux/block
1313+index 2691b56951..bd41313bf8 100644
1414+--- a/tools/hotplug/Linux/block
1515++++ b/tools/hotplug/Linux/block
1616+@@ -1,5 +1,5 @@
1717+ #!/bin/bash
1818+1919+-dir=$(dirname "$0")
2020++dir=$(@dirname@ "$0")
2121+ . "$dir/block-common.sh"
2222+2323+@@ -32,5 +32,5 @@ find_free_loopback_helper() {
2424+ find_free_loopback_dev() {
2525+ local loopdev
2626+- loopdev=$(losetup -a | sed -e 's+^/dev/loop++' -e 's/:.*//' | find_free_loopback_helper)
2727++ loopdev=$(@losetup@ -a | @sed@ -e 's+^/dev/loop++' -e 's/:.*//' | find_free_loopback_helper)
2828+ if [ -n "$loopdev" ] && [ -b "$loopdev" ]; then
2929+ echo "$loopdev"
3030+@@ -67,6 +67,6 @@ check_sharing()
3131+ local inode="$4"
3232+3333+- shared_list=$(losetup -a |
3434+- sed -n -e "s@^\([^:]\+\)\(:[[:blank:]]\[0*${dev}\]:${inode}[[:blank:]](.*)\)@\1@p" )
3535++ shared_list=$(@losetup@ -a |
3636++ @sed@ -n -e "s@^\([^:]\+\)\(:[[:blank:]]\[0*${dev}\]:${inode}[[:blank:]](.*)\)@\1@p" )
3737+ for dev in $shared_list
3838+ do
3939+@@ -95,5 +95,5 @@ check_sharing()
4040+ fi
4141+4242+- for file in $(cat /proc/mounts | grep -v "$toskip" | cut -f 1 -d ' ')
4343++ for file in $(@cat@ /proc/mounts | @grep@ -v "$toskip" | @cut@ -f 1 -d ' ')
4444+ do
4545+ if [ -e "$file" ]
4646+@@ -268,5 +268,5 @@ case "$command" in
4747+ if [ -L "$dev" ]
4848+ then
4949+- dev=$(readlink -f "$dev") || fatal "$dev link does not exist."
5050++ dev=$(@readlink@ -f "$dev") || fatal "$dev link does not exist."
5151+ fi
5252+ test -e "$dev" || fatal "$dev does not exist."
5353+@@ -283,5 +283,5 @@ case "$command" in
5454+ # Canonicalise the file, for sharing check comparison, and the mode
5555+ # for ease of use here.
5656+- file=$(readlink -f "$p") || fatal "$p does not exist."
5757++ file=$(@readlink@ -f "$p") || fatal "$p does not exist."
5858+ test -f "$file" || fatal "$file does not exist."
5959+ mode=$(canonicalise_mode "$mode")
6060+@@ -298,5 +298,5 @@ case "$command" in
6161+ fi
6262+6363+- if [ "$mode" = 'w' ] && ! stat "$file" -c %A | grep -q w
6464++ if [ "$mode" = 'w' ] && ! @stat@ "$file" -c %A | @grep@ -q w
6565+ then
6666+ release_lock "block"
6767+@@ -308,6 +308,6 @@ mount it read-write in a guest domain."
6868+ if [ "x$mode" != 'x!' ]
6969+ then
7070+- inode=$(stat -c '%i' "$file")
7171+- dev=$(stat -c '%D' "$file")
7272++ inode=$(@stat@ -c '%i' "$file")
7373++ dev=$(@stat@ -c '%D' "$file")
7474+ if [ -z "$inode" ] || [ -z "$dev" ]
7575+ then
7676+@@ -318,5 +318,5 @@ mount it read-write in a guest domain."
7777+ fi
7878+7979+- loopdev=$(losetup -f 2>/dev/null || find_free_loopback_dev)
8080++ loopdev=$(@losetup@ -f 2>/dev/null || find_free_loopback_dev)
8181+ if [ "$loopdev" = '' ]
8282+ then
8383+@@ -325,5 +325,5 @@ mount it read-write in a guest domain."
8484+ fi
8585+8686+- if LANG=C losetup -h 2>&1 | grep read-only >/dev/null
8787++ if LANG=C @losetup@ -h 2>&1 | @grep@ read-only >/dev/null
8888+ then
8989+ roflag="-$mode"; roflag="${roflag#-w}"; roflag="${roflag#-!}"
9090+@@ -331,5 +331,5 @@ mount it read-write in a guest domain."
9191+ roflag=''
9292+ fi
9393+- do_or_die losetup $roflag "$loopdev" "$file"
9494++ do_or_die @losetup@ $roflag "$loopdev" "$file"
9595+ xenstore_write "$XENBUS_PATH/node" "$loopdev"
9696+ write_dev "$loopdev"
9797+@@ -355,5 +355,5 @@ mount it read-write in a guest domain."
9898+ claim_lock "block"
9999+ node=$(xenstore_read "$XENBUS_PATH/node")
100100+- losetup -d "$node"
101101++ @losetup@ -d "$node"
102102+ release_lock "block"
103103+ exit 0
104104+diff --git a/tools/hotplug/Linux/block-common.sh b/tools/hotplug/Linux/block-common.sh
105105+index 5c80237d99..5e1c350555 100644
106106+--- a/tools/hotplug/Linux/block-common.sh
107107++++ b/tools/hotplug/Linux/block-common.sh
108108+@@ -16,5 +16,5 @@
109109+110110+111111+-dir=$(dirname "$0")
112112++dir=$(@dirname@ "$0")
113113+ . "$dir/xen-hotplug-common.sh"
114114+115115+@@ -46,5 +46,5 @@ ebusy()
116116+ device_major_minor()
117117+ {
118118+- stat -L -c %t:%T "$1"
119119++ @stat@ -L -c %t:%T "$1"
120120+ }
121121+122122+diff --git a/tools/hotplug/Linux/block-drbd-probe b/tools/hotplug/Linux/block-drbd-probe
123123+index 7b2968b6d9..ba246cd132 100755
124124+--- a/tools/hotplug/Linux/block-drbd-probe
125125++++ b/tools/hotplug/Linux/block-drbd-probe
126126+@@ -32,6 +32,6 @@ function get_res_name()
127127+ {
128128+ local drbd_dev=$1
129129+- local drbd_dev_list=($(drbdadm sh-dev all))
130130+- local drbd_res_list=($(drbdadm sh-resource all))
131131++ local drbd_dev_list=($(@drbdadm@ sh-dev all))
132132++ local drbd_res_list=($(@drbdadm@ sh-resource all))
133133+ local temp_drbd_dev temp_drbd_res
134134+ local found=0
135135+@@ -49,5 +49,5 @@ function get_res_name()
136136+137137+ for temp_drbd_res in ${drbd_res_list[@]}; do
138138+- temp_drbd_dev=$(drbdadm sh-dev $temp_drbd_res)
139139++ temp_drbd_dev=$(@drbdadm@ sh-dev $temp_drbd_res)
140140+ if [[ "$temp_drbd_dev" == "$drbd_dev" ]]; then
141141+ drbd_res="$temp_drbd_res"
142142+@@ -67,5 +67,5 @@ fi
143143+144144+ # check protocol
145145+-drbdsetup $1 show | grep -q "protocol D;"
146146++@drbdsetup@ $1 show | @grep@ -q "protocol D;"
147147+ if [[ $? -ne 0 ]]; then
148148+ exit 3
149149+@@ -73,5 +73,5 @@ fi
150150+151151+ # check connect status
152152+-state=$(drbdadm cstate "$drbd_res")
153153++state=$(@drbdadm@ cstate "$drbd_res")
154154+ if [[ "$state" != "Connected" ]]; then
155155+ exit 4
156156+@@ -79,5 +79,5 @@ fi
157157+158158+ # check role
159159+-role=$(drbdadm role "$drbd_res")
160160++role=$(@drbdadm@ role "$drbd_res")
161161+ if [[ "$role" != "Primary/Secondary" ]]; then
162162+ exit 4
163163+diff --git a/tools/hotplug/Linux/block-dummy b/tools/hotplug/Linux/block-dummy
164164+index 57d40b5fce..50bbf09bb6 100644
165165+--- a/tools/hotplug/Linux/block-dummy
166166++++ b/tools/hotplug/Linux/block-dummy
167167+@@ -23,10 +23,10 @@
168168+ # script=block-dummy,vdev=xvda,target=dummy:<file>
169169+170170+-dir=$(dirname "$0")
171171++dir=$(@dirname@ "$0")
172172+ . "$dir/block-common.sh"
173173+174174+ check_tools()
175175+ {
176176+- if ! command -v losetup > /dev/null 2>&1; then
177177++ if ! command -v @losetup@ > /dev/null 2>&1; then
178178+ fatal "Unable to find losetup"
179179+ fi
180180+@@ -56,5 +56,5 @@ add()
181181+ test -f "$file" || fatal "$file does not exist."
182182+183183+- loopdev=$(losetup -f 2>/dev/null || find_free_loopback_dev)
184184++ loopdev=$(@losetup@ -f 2>/dev/null || find_free_loopback_dev)
185185+ if [ "$loopdev" = '' ]
186186+ then
187187+@@ -62,5 +62,5 @@ add()
188188+ fi
189189+190190+- if LANG=C losetup -h 2>&1 | grep read-only >/dev/null
191191++ if LANG=C @losetup@ -h 2>&1 | @grep@ read-only >/dev/null
192192+ then
193193+ roflag="-$mode"; roflag="${roflag#-w}"; roflag="${roflag#-!}"
194194+@@ -69,5 +69,5 @@ add()
195195+ fi
196196+197197+- do_or_die losetup $roflag "$loopdev" "$file"
198198++ do_or_die @losetup@ $roflag "$loopdev" "$file"
199199+ # FIXME Is this OK?
200200+ xenstore_write "$XENBUS_PATH/node" "$loopdev"
201201+@@ -79,5 +79,5 @@ remove()
202202+ {
203203+ node=$(xenstore_read "$XENBUS_PATH/node")
204204+- losetup -d "$node"
205205++ @losetup@ -d "$node"
206206+ }
207207+208208+diff --git a/tools/hotplug/Linux/block-enbd b/tools/hotplug/Linux/block-enbd
209209+index 67faa84268..77599ff6df 100644
210210+--- a/tools/hotplug/Linux/block-enbd
211211++++ b/tools/hotplug/Linux/block-enbd
212212+@@ -8,5 +8,5 @@
213213+ # This assumes you're running a correctly configured server at the other end!
214214+215215+-dir=$(dirname "$0")
216216++dir=$(@dirname@ "$0")
217217+ . "$dir/block-common.sh"
218218+219219+@@ -14,5 +14,5 @@ case "$command" in
220220+ add)
221221+ for dev in /dev/nd*; do
222222+- if nbd-client $2:$3 $dev; then
223223++ if @nbd-client@ $2:$3 $dev; then
224224+ write_dev $dev
225225+ exit 0
226226+@@ -22,5 +22,5 @@ case "$command" in
227227+ ;;
228228+ remove)
229229+- nbd-client -d $2
230230++ @nbd-client@ -d $2
231231+ exit 0
232232+ ;;
233233+diff --git a/tools/hotplug/Linux/block-iscsi b/tools/hotplug/Linux/block-iscsi
234234+index 3615905252..ad45a3685b 100644
235235+--- a/tools/hotplug/Linux/block-iscsi
236236++++ b/tools/hotplug/Linux/block-iscsi
237237+@@ -24,18 +24,18 @@
238238+ #
239239+240240+-dir=$(dirname "$0")
241241++dir=$(@dirname@ "$0")
242242+ . "$dir/block-common.sh"
243243+244244+ remove_label()
245245+ {
246246+- echo $1 | sed "s/^\("$2"\)//"
247247++ echo $1 | @sed@ "s/^\("$2"\)//"
248248+ }
249249+250250+ check_tools()
251251+ {
252252+- if ! command -v iscsiadm > /dev/null 2>&1; then
253253++ if ! command -v @iscsiadm@ > /dev/null 2>&1; then
254254+ fatal "Unable to find iscsiadm tool"
255255+ fi
256256+- if [ "$multipath" = "y" ] && ! command -v multipath > /dev/null 2>&1; then
257257++ if [ "$multipath" = "y" ] && ! command -v @multipath@ > /dev/null 2>&1; then
258258+ fatal "Unable to find multipath"
259259+ fi
260260+@@ -75,5 +75,5 @@ find_device()
261261+ count=0
262262+ while [ ! -e /dev/disk/by-path/*"$iqn"-lun-0 ]; do
263263+- sleep 1
264264++ @sleep@ 1
265265+ count=`expr $count + 1`
266266+ if [ count = 100 ]; then
267267+@@ -82,10 +82,10 @@ find_device()
268268+ fi
269269+ done
270270+- sddev=$(readlink -f /dev/disk/by-path/*"$iqn"-lun-0 || true)
271271++ sddev=$(@readlink@ -f /dev/disk/by-path/*"$iqn"-lun-0 || true)
272272+ if [ ! -b "$sddev" ]; then
273273+ fatal "Unable to find attached device path"
274274+ fi
275275+ if [ "$multipath" = "y" ]; then
276276+- mdev=$(multipath -ll "$sddev" | head -1 | awk '{ print $1}')
277277++ mdev=$(@multipath@ -ll "$sddev" | @head@ -1 | @awk@ '{ print $1}')
278278+ if [ ! -b /dev/mapper/"$mdev" ]; then
279279+ fatal "Unable to find attached device multipath"
280280+@@ -101,5 +101,5 @@ find_device()
281281+ attach()
282282+ {
283283+- do_or_die iscsiadm -m node --targetname "$iqn" -p "$portal" --login > /dev/null
284284++ do_or_die @iscsiadm@ -m node --targetname "$iqn" -p "$portal" --login > /dev/null
285285+ find_device
286286+ }
287287+@@ -110,7 +110,7 @@ prepare()
288288+ {
289289+ # Check if target is already opened
290290+- iscsiadm -m session 2>&1 | grep -q "$iqn" && fatal "Device already opened"
291291++ @iscsiadm@ -m session 2>&1 | @grep@ -q "$iqn" && fatal "Device already opened"
292292+ # Discover portal targets
293293+- iscsiadm -m discovery -t st -p $portal 2>&1 | grep -q "$iqn" || \
294294++ @iscsiadm@ -m discovery -t st -p $portal 2>&1 | @grep@ -q "$iqn" || \
295295+ fatal "No matching target iqn found"
296296+ }
297297+@@ -128,5 +128,5 @@ remove()
298298+ {
299299+ find_device
300300+- do_or_die iscsiadm -m node --targetname "$iqn" -p "$portal" --logout > /dev/null
301301++ do_or_die @iscsiadm@ -m node --targetname "$iqn" -p "$portal" --logout > /dev/null
302302+ }
303303+304304+diff --git a/tools/hotplug/Linux/block-nbd b/tools/hotplug/Linux/block-nbd
305305+index b29b31564a..a98350b121 100644
306306+--- a/tools/hotplug/Linux/block-nbd
307307++++ b/tools/hotplug/Linux/block-nbd
308308+@@ -8,5 +8,5 @@
309309+ # This assumes you're running a correctly configured server at the other end!
310310+311311+-dir=$(dirname "$0")
312312++dir=$(@dirname@ "$0")
313313+ . "$dir/block-common.sh"
314314+315315+@@ -14,5 +14,5 @@ case "$command" in
316316+ add)
317317+ for dev in /dev/nbd*; do
318318+- if nbd-client $2 $3 $dev; then
319319++ if @nbd-client@ $2 $3 $dev; then
320320+ write_dev $dev
321321+ exit 0
322322+@@ -22,5 +22,5 @@ case "$command" in
323323+ ;;
324324+ remove)
325325+- nbd-client -d $2
326326++ @nbd-client@ -d $2
327327+ exit 0
328328+ ;;
329329+diff --git a/tools/hotplug/Linux/block-tap b/tools/hotplug/Linux/block-tap
330330+index 95970a61f6..a03a36f8b6 100755
331331+--- a/tools/hotplug/Linux/block-tap
332332++++ b/tools/hotplug/Linux/block-tap
333333+@@ -29,10 +29,10 @@
334334+ # format/<type> is either "aio" (for raw files), or "vhd"
335335+336336+-dir=$(dirname "$0")
337337++dir=$(@dirname@ "$0")
338338+ . "$dir/block-common.sh"
339339+340340+ remove_label()
341341+ {
342342+- echo $1 | sed "s/^\("$2"\)//"
343343++ echo $1 | @sed@ "s/^\("$2"\)//"
344344+ }
345345+346346+@@ -102,5 +102,5 @@ count_using()
347347+ do
348348+ f=$(xenstore_read_default "$base_path/$dom/$dev/params" "")
349349+- f=$(echo "$f" | cut -d ":" -f 2)
350350++ f=$(echo "$f" | @cut@ -d ":" -f 2)
351351+352352+ if [ -n "$f" ] && [ "$file" = $f ] ; then
353353+@@ -131,5 +131,5 @@ check_tap_sharing()
354354+ for dev in $(xenstore-list "$base_path/$dom") ; do
355355+ local f=$(xenstore_read_default "$base_path/$dom/$dev/params" "")
356356+- f=$(echo "$f" | cut -d ":" -f 2)
357357++ f=$(echo "$f" | @cut@ -d ":" -f 2)
358358+359359+ if [ -n "$f" ] && [ "$file" = "$f" ] ; then
360360+diff --git a/tools/hotplug/Linux/colo-proxy-setup b/tools/hotplug/Linux/colo-proxy-setup
361361+index d709146c47..e0f44364cc 100755
362362+--- a/tools/hotplug/Linux/colo-proxy-setup
363363++++ b/tools/hotplug/Linux/colo-proxy-setup
364364+@@ -1,5 +1,5 @@
365365+ #! /bin/bash
366366+367367+-dir=$(dirname "$0")
368368++dir=$(@dirname@ "$0")
369369+ . "$dir/xen-hotplug-common.sh"
370370+ . "$dir/hotplugpath.sh"
371371+@@ -38,60 +38,60 @@ fi
372372+ function setup_primary()
373373+ {
374374+- do_without_error tc qdisc add dev $vifname root handle 1: prio
375375+- do_without_error tc filter add dev $vifname parent 1: protocol ip prio 10 \
376376++ do_without_error @tc@ qdisc add dev $vifname root handle 1: prio
377377++ do_without_error @tc@ filter add dev $vifname parent 1: protocol ip prio 10 \
378378+ u32 match u32 0 0 flowid 1:2 action mirred egress mirror dev $forwarddev
379379+- do_without_error tc filter add dev $vifname parent 1: protocol arp prio 11 \
380380++ do_without_error @tc@ filter add dev $vifname parent 1: protocol arp prio 11 \
381381+ u32 match u32 0 0 flowid 1:2 action mirred egress mirror dev $forwarddev
382382+- do_without_error tc filter add dev $vifname parent 1: protocol ipv6 prio \
383383++ do_without_error @tc@ filter add dev $vifname parent 1: protocol ipv6 prio \
384384+ 12 u32 match u32 0 0 flowid 1:2 action mirred egress mirror \
385385+ dev $forwarddev
386386+387387+- do_without_error modprobe nf_conntrack_ipv4
388388+- do_without_error modprobe xt_PMYCOLO sec_dev=$forwarddev
389389++ do_without_error @modprobe@ nf_conntrack_ipv4
390390++ do_without_error @modprobe@ xt_PMYCOLO sec_dev=$forwarddev
391391+392392+- iptables -t mangle -I PREROUTING -m physdev --physdev-in \
393393++ @iptables@ -t mangle -I PREROUTING -m physdev --physdev-in \
394394+ $vifname -j PMYCOLO --index $index
395395+- ip6tables -t mangle -I PREROUTING -m physdev --physdev-in \
396396++ @ip6tables@ -t mangle -I PREROUTING -m physdev --physdev-in \
397397+ $vifname -j PMYCOLO --index $index
398398+- do_without_error arptables -I INPUT -i $forwarddev -j MARK --set-mark $index
399399++ do_without_error @arptables@ -I INPUT -i $forwarddev -j MARK --set-mark $index
400400+ }
401401+402402+ function teardown_primary()
403403+ {
404404+- do_without_error tc filter del dev $vifname parent 1: protocol ip prio 10 u32 match u32 \
405405++ do_without_error @tc@ filter del dev $vifname parent 1: protocol ip prio 10 u32 match u32 \
406406+ 0 0 flowid 1:2 action mirred egress mirror dev $forwarddev
407407+- do_without_error tc filter del dev $vifname parent 1: protocol arp prio 11 u32 match u32 \
408408++ do_without_error @tc@ filter del dev $vifname parent 1: protocol arp prio 11 u32 match u32 \
409409+ 0 0 flowid 1:2 action mirred egress mirror dev $forwarddev
410410+- do_without_error tc filter del dev $vifname parent 1: protocol ipv6 prio 12 u32 match u32 \
411411++ do_without_error @tc@ filter del dev $vifname parent 1: protocol ipv6 prio 12 u32 match u32 \
412412+ 0 0 flowid 1:2 action mirred egress mirror dev $forwarddev
413413+- do_without_error tc qdisc del dev $vifname root handle 1: prio
414414++ do_without_error @tc@ qdisc del dev $vifname root handle 1: prio
415415+416416+- do_without_error iptables -t mangle -D PREROUTING -m physdev --physdev-in \
417417++ do_without_error @iptables@ -t mangle -D PREROUTING -m physdev --physdev-in \
418418+ $vifname -j PMYCOLO --index $index
419419+- do_without_error ip6tables -t mangle -D PREROUTING -m physdev --physdev-in \
420420++ do_without_error @ip6tables@ -t mangle -D PREROUTING -m physdev --physdev-in \
421421+ $vifname -j PMYCOLO --index $index
422422+- do_without_error arptables -F
423423+- do_without_error rmmod xt_PMYCOLO
424424++ do_without_error @arptables@ -F
425425++ do_without_error @rmmod@ xt_PMYCOLO
426426+ }
427427+428428+ function setup_secondary()
429429+ {
430430+- if which brctl >&/dev/null; then
431431+- do_without_error brctl delif $bridge $vifname
432432+- do_without_error brctl addbr $forwardbr
433433+- do_without_error brctl addif $forwardbr $vifname
434434+- do_without_error brctl addif $forwardbr $forwarddev
435435++ if @which@ @brctl@ >&/dev/null; then
436436++ do_without_error @brctl@ delif $bridge $vifname
437437++ do_without_error @brctl@ addbr $forwardbr
438438++ do_without_error @brctl@ addif $forwardbr $vifname
439439++ do_without_error @brctl@ addif $forwardbr $forwarddev
440440+ else
441441+- do_without_error ip link set $vifname nomaster
442442+- do_without_error ip link add name $forwardbr type bridge
443443+- do_without_error ip link set $vifname master $forwardbr
444444+- do_without_error ip link set $forwarddev master $forwardbr
445445++ do_without_error @ip@ link set $vifname nomaster
446446++ do_without_error @ip@ link add name $forwardbr type bridge
447447++ do_without_error @ip@ link set $vifname master $forwardbr
448448++ do_without_error @ip@ link set $forwarddev master $forwardbr
449449+ fi
450450+- do_without_error ip link set dev $forwardbr up
451451+- do_without_error modprobe xt_SECCOLO
452452++ do_without_error @ip@ link set dev $forwardbr up
453453++ do_without_error @modprobe@ xt_SECCOLO
454454+455455+- iptables -t mangle -I PREROUTING -m physdev --physdev-in \
456456++ @iptables@ -t mangle -I PREROUTING -m physdev --physdev-in \
457457+ $vifname -j SECCOLO --index $index
458458+- ip6tables -t mangle -I PREROUTING -m physdev --physdev-in \
459459++ @ip6tables@ -t mangle -I PREROUTING -m physdev --physdev-in \
460460+ $vifname -j SECCOLO --index $index
461461+ }
462462+@@ -99,21 +99,21 @@ function setup_secondary()
463463+ function teardown_secondary()
464464+ {
465465+- if which brctl >&/dev/null; then
466466+- do_without_error brctl delif $forwardbr $forwarddev
467467+- do_without_error brctl delif $forwardbr $vifname
468468+- do_without_error brctl delbr $forwardbr
469469+- do_without_error brctl addif $bridge $vifname
470470++ if @which@ @brctl@ >&/dev/null; then
471471++ do_without_error @brctl@ delif $forwardbr $forwarddev
472472++ do_without_error @brctl@ delif $forwardbr $vifname
473473++ do_without_error @brctl@ delbr $forwardbr
474474++ do_without_error @brctl@ addif $bridge $vifname
475475+ else
476476+- do_without_error ip link set $forwarddev nomaster
477477+- do_without_error ip link set $vifname nomaster
478478+- do_without_error ip link delete $forwardbr type bridge
479479+- do_without_error ip link set $vifname master $bridge
480480++ do_without_error @ip@ link set $forwarddev nomaster
481481++ do_without_error @ip@ link set $vifname nomaster
482482++ do_without_error @ip@ link delete $forwardbr type bridge
483483++ do_without_error @ip@ link set $vifname master $bridge
484484+ fi
485485+486486+- do_without_error iptables -t mangle -D PREROUTING -m physdev --physdev-in \
487487++ do_without_error @iptables@ -t mangle -D PREROUTING -m physdev --physdev-in \
488488+ $vifname -j SECCOLO --index $index
489489+- do_without_error ip6tables -t mangle -D PREROUTING -m physdev --physdev-in \
490490++ do_without_error @ip6tables@ -t mangle -D PREROUTING -m physdev --physdev-in \
491491+ $vifname -j SECCOLO --index $index
492492+- do_without_error rmmod xt_SECCOLO
493493++ do_without_error @rmmod@ xt_SECCOLO
494494+ }
495495+496496+diff --git a/tools/hotplug/Linux/external-device-migrate b/tools/hotplug/Linux/external-device-migrate
497497+index f5942a6a95..228917b784 100644
498498+--- a/tools/hotplug/Linux/external-device-migrate
499499++++ b/tools/hotplug/Linux/external-device-migrate
500500+@@ -24,10 +24,10 @@ set -x
501501+ # synchronization
502502+503503+-dir=$(dirname "$0")
504504++dir=$(@dirname@ "$0")
505505+ . "$dir/logging.sh"
506506+507507+508508+ function ext_dev_migrate_usage() {
509509+-cat <<EOF
510510++@cat@ <<EOF
511511+ Pass the following command line parameters to the script:
512512+513513+diff --git a/tools/hotplug/Linux/init.d/xen-watchdog.in b/tools/hotplug/Linux/init.d/xen-watchdog.in
514514+index a0bde199c4..cefa3b81f8 100644
515515+--- a/tools/hotplug/Linux/init.d/xen-watchdog.in
516516++++ b/tools/hotplug/Linux/init.d/xen-watchdog.in
517517+@@ -26,5 +26,5 @@ test -f $xencommons_config/xencommons && . $xencommons_config/xencommons
518518+ test -n "$XENWATCHDOGD_ARGS" || XENWATCHDOGD_ARGS='30 15'
519519+ DAEMON=${sbindir}/xenwatchdogd
520520+-base=$(basename $DAEMON)
521521++base=$(@basename@ $DAEMON)
522522+523523+ # Source function library.
524524+@@ -64,5 +64,5 @@ stop() {
525525+ echo -n $"Stopping domain watchdog daemon: "
526526+527527+- killall -USR1 $base 2>/dev/null
528528++ @killall@ -USR1 $base 2>/dev/null
529529+ r=$?
530530+ [ "$r" -eq 0 ] && success $"$base stop" || failure $"$base stop"
531531+diff --git a/tools/hotplug/Linux/init.d/xencommons.in b/tools/hotplug/Linux/init.d/xencommons.in
532532+index 7fd6903b98..dcc8de631b 100644
533533+--- a/tools/hotplug/Linux/init.d/xencommons.in
534534++++ b/tools/hotplug/Linux/init.d/xencommons.in
535535+@@ -39,5 +39,5 @@ fi
536536+ if test "x$1" = xstart && \
537537+ ! test -f /proc/xen/capabilities && \
538538+- ! grep '^xenfs ' /proc/mounts >/dev/null;
539539++ ! @grep@ '^xenfs ' /proc/mounts >/dev/null;
540540+ then
541541+ mount -t xenfs xenfs /proc/xen
542542+@@ -48,5 +48,5 @@ fi
543543+ # empty capabilities file in pv_ops domU kernel
544544+ if test -f /proc/xen/capabilities && \
545545+- ! grep -q "control_d" /proc/xen/capabilities ; then
546546++ ! @grep@ -q "control_d" /proc/xen/capabilities ; then
547547+ exit 0
548548+ fi
549549+@@ -55,9 +55,9 @@ do_start () {
550550+ local mod
551551+552552+- for mod in $BACKEND_MODULES ; do modprobe "$mod" &>/dev/null ; done
553553++ for mod in $BACKEND_MODULES ; do @modprobe@ "$mod" &>/dev/null ; done
554554+555555+- mkdir -m700 -p ${XEN_RUN_DIR}
556556+- mkdir -m700 -p ${XEN_LOCK_DIR}
557557+- mkdir -p ${XEN_LOG_DIR}
558558++ @mkdir@ -m700 -p ${XEN_RUN_DIR}
559559++ @mkdir@ -m700 -p ${XEN_LOCK_DIR}
560560++ @mkdir@ -p ${XEN_LOG_DIR}
561561+562562+ @XEN_SCRIPT_DIR@/launch-xenstore || exit 1
563563+@@ -79,6 +79,6 @@ do_stop () {
564564+ if read 2>/dev/null <$XENCONSOLED_PIDFILE pid; then
565565+ kill $pid
566566+- while kill -9 $pid >/dev/null 2>&1; do sleep 1; done
567567+- rm -f $XENCONSOLED_PIDFILE
568568++ while kill -9 $pid >/dev/null 2>&1; do @sleep@ 1; done
569569++ @rm@ -f $XENCONSOLED_PIDFILE
570570+ fi
571571+572572+@@ -86,6 +86,6 @@ do_stop () {
573573+ if read 2>/dev/null <$QEMU_PIDFILE pid; then
574574+ kill $pid
575575+- while kill -9 $pid >/dev/null 2>&1; do sleep 1; done
576576+- rm -f $QEMU_PIDFILE
577577++ while kill -9 $pid >/dev/null 2>&1; do @sleep@ 1; done
578578++ @rm@ -f $QEMU_PIDFILE
579579+ fi
580580+581581+diff --git a/tools/hotplug/Linux/init.d/xendriverdomain.in b/tools/hotplug/Linux/init.d/xendriverdomain.in
582582+index 17b381c3dc..064906f027 100644
583583+--- a/tools/hotplug/Linux/init.d/xendriverdomain.in
584584++++ b/tools/hotplug/Linux/init.d/xendriverdomain.in
585585+@@ -35,5 +35,5 @@ fi
586586+ if test "x$1" = xstart && \
587587+ ! test -f /proc/xen/capabilities && \
588588+- ! grep '^xenfs ' /proc/mounts >/dev/null;
589589++ ! @grep@ '^xenfs ' /proc/mounts >/dev/null;
590590+ then
591591+ mount -t xenfs xenfs /proc/xen
592592+@@ -44,5 +44,5 @@ fi
593593+ # empty capabilities file in pv_ops domU kernel
594594+ if ! test -f /proc/xen/capabilities || \
595595+- grep -q "control_d" /proc/xen/capabilities ; then
596596++ @grep@ -q "control_d" /proc/xen/capabilities ; then
597597+ exit 0
598598+ fi
599599+@@ -50,5 +50,5 @@ fi
600600+ do_start () {
601601+ echo Starting xl devd...
602602+- mkdir -p "${XEN_RUN_DIR}"
603603++ @mkdir@ -p "${XEN_RUN_DIR}"
604604+ ${sbindir}/xl devd --pidfile=$XLDEVD_PIDFILE $XLDEVD_ARGS
605605+ }
606606+@@ -57,6 +57,6 @@ do_stop () {
607607+ if read 2>/dev/null <$XLDEVD_PIDFILE pid; then
608608+ kill $pid
609609+- while kill -9 $pid >/dev/null 2>&1; do sleep 1; done
610610+- rm -f $XLDEVD_PIDFILE
611611++ while kill -9 $pid >/dev/null 2>&1; do @sleep@ 1; done
612612++ @rm@ -f $XLDEVD_PIDFILE
613613+ fi
614614+ }
615615+diff --git a/tools/hotplug/Linux/launch-xenstore.in b/tools/hotplug/Linux/launch-xenstore.in
616616+index da4eeca7c5..059036d899 100644
617617+--- a/tools/hotplug/Linux/launch-xenstore.in
618618++++ b/tools/hotplug/Linux/launch-xenstore.in
619619+@@ -32,5 +32,5 @@ timeout_xenstore () {
620620+ echo -n .
621621+ time=$(($time+1))
622622+- sleep 1
623623++ @sleep@ 1
624624+ done
625625+ echo
626626+@@ -51,5 +51,5 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF
627627+ [ "$XENSTORETYPE" = "" ] && XENSTORETYPE=daemon
628628+629629+-/bin/mkdir -p @XEN_RUN_DIR@
630630++@mkdir@ -p @XEN_RUN_DIR@
631631+632632+ [ "$XENSTORETYPE" = "daemon" ] && {
633633+@@ -72,5 +72,5 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF
634634+ }
635635+ [ -r /proc/sys/fs/nr_open ] && {
636636+- MAX_FDS=`cat /proc/sys/fs/nr_open`
637637++ MAX_FDS=`@cat@ /proc/sys/fs/nr_open`
638638+ [ "$XENSTORED_MAX_OPEN_FDS" = "unlimited" ] && XENSTORED_MAX_OPEN_FDS=$MAX_FDS
639639+ [ $XENSTORED_MAX_OPEN_FDS -gt $MAX_FDS ] && {
640640+@@ -81,11 +81,11 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF
641641+ }
642642+643643+- rm -f @XEN_RUN_DIR@/xenstored.pid
644644++ @rm@ -f @XEN_RUN_DIR@/xenstored.pid
645645+646646+ echo -n Starting $XENSTORED...
647647+- prlimit --nofile=$XENSTORED_MAX_OPEN_FDS $XENSTORED --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS
648648++ @prlimit@ --nofile=$XENSTORED_MAX_OPEN_FDS $XENSTORED --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS
649649+650650+- systemd-notify --booted 2>/dev/null || timeout_xenstore $XENSTORED || exit 1
651651+- XS_PID=`cat @XEN_RUN_DIR@/xenstored.pid`
652652++ @systemd-notify@ --booted 2>/dev/null || timeout_xenstore $XENSTORED || exit 1
653653++ XS_PID=`@cat@ @XEN_RUN_DIR@/xenstored.pid`
654654+ echo $XS_OOM_SCORE >/proc/$XS_PID/oom_score_adj
655655+656656+@@ -103,5 +103,5 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF
657657+ echo -n Starting $XENSTORE_DOMAIN_KERNEL...
658658+ ${LIBEXEC_BIN}/init-xenstore-domain $XENSTORE_DOMAIN_ARGS || exit 1
659659+- systemd-notify --ready 2>/dev/null
660660++ @systemd-notify@ --ready 2>/dev/null
661661+662662+ exit 0
663663+diff --git a/tools/hotplug/Linux/locking.sh b/tools/hotplug/Linux/locking.sh
664664+index 2e6fb35f02..5860157657 100644
665665+--- a/tools/hotplug/Linux/locking.sh
666666++++ b/tools/hotplug/Linux/locking.sh
667667+@@ -36,5 +36,5 @@ _setlockfd()
668668+ claim_lock()
669669+ {
670670+- mkdir -p "$LOCK_BASEDIR"
671671++ @mkdir@ -p "$LOCK_BASEDIR"
672672+ _setlockfd $1
673673+ # The locking strategy is identical to that from with-lock-ex(1)
674674+@@ -45,5 +45,5 @@ claim_lock()
675675+ while true; do
676676+ eval "exec $_lockfd<>$_lockfile"
677677+- flock -x $_lockfd || return $?
678678++ @flock@ -x $_lockfd || return $?
679679+ # Although /dev/stdin (i.e. /proc/self/fd/0) looks like a symlink,
680680+ # stat(2) bypasses the synthetic symlink and directly accesses the
681681+@@ -53,5 +53,5 @@ claim_lock()
682682+ # YY.ZZZ
683683+ # which need to be separated and compared.
684684+- if stat=$( stat -L -c '%D.%i' /dev/stdin $_lockfile 0<&$_lockfd 2>/dev/null )
685685++ if stat=$( @stat@ -L -c '%D.%i' /dev/stdin $_lockfile 0<&$_lockfd 2>/dev/null )
686686+ then
687687+ local file_stat
688688+@@ -75,5 +75,5 @@ release_lock()
689689+ {
690690+ _setlockfd $1
691691+- rm "$_lockfile"
692692++ @rm@ "$_lockfile"
693693+ }
694694+695695+diff --git a/tools/hotplug/Linux/logging.sh b/tools/hotplug/Linux/logging.sh
696696+index 3e94df1a9e..fa99d8c4c7 100644
697697+--- a/tools/hotplug/Linux/logging.sh
698698++++ b/tools/hotplug/Linux/logging.sh
699699+@@ -18,4 +18,4 @@ log() {
700700+ local level="$1"
701701+ shift
702702+- logger -p "daemon.$level" -- "$0:" "$@" || echo "$0 $@" >&2
703703++ @logger@ -p "daemon.$level" -- "$0:" "$@" || echo "$0 $@" >&2
704704+ }
705705+diff --git a/tools/hotplug/Linux/remus-netbuf-setup b/tools/hotplug/Linux/remus-netbuf-setup
706706+index 87dfa69778..fe4f7b6e36 100644
707707+--- a/tools/hotplug/Linux/remus-netbuf-setup
708708++++ b/tools/hotplug/Linux/remus-netbuf-setup
709709+@@ -75,5 +75,5 @@
710710+ # Unlike other vif scripts, vif-common is not needed here as it executes vif
711711+ #specific setup code such as renaming.
712712+-dir=$(dirname "$0")
713713++dir=$(@dirname@ "$0")
714714+ . "$dir/xen-hotplug-common.sh"
715715+716716+@@ -93,11 +93,11 @@ evalVariables "$@"
717717+718718+ check_libnl_tools() {
719719+- if ! command -v nl-qdisc-list > /dev/null 2>&1; then
720720++ if ! command -v @nl-qdisc-list@ > /dev/null 2>&1; then
721721+ fatal "Unable to find nl-qdisc-list tool"
722722+ fi
723723+- if ! command -v nl-qdisc-add > /dev/null 2>&1; then
724724++ if ! command -v @nl-qdisc-add@ > /dev/null 2>&1; then
725725+ fatal "Unable to find nl-qdisc-add tool"
726726+ fi
727727+- if ! command -v nl-qdisc-delete > /dev/null 2>&1; then
728728++ if ! command -v @nl-qdisc-delete@ > /dev/null 2>&1; then
729729+ fatal "Unable to find nl-qdisc-delete tool"
730730+ fi
731731+@@ -111,5 +111,5 @@ check_modules() {
732732+ for m in ifb sch_plug sch_ingress act_mirred cls_u32
733733+ do
734734+- if ! modinfo $m > /dev/null 2>&1; then
735735++ if ! @modinfo@ $m > /dev/null 2>&1; then
736736+ fatal "Unable to find $m kernel module"
737737+ fi
738738+@@ -119,5 +119,5 @@ check_modules() {
739739+ #return 0 if the ifb is free
740740+ check_ifb() {
741741+- local installed=`nl-qdisc-list -d $1`
742742++ local installed=`@nl-qdisc-list@ -d $1`
743743+ [ -n "$installed" ] && return 1
744744+745745+@@ -140,5 +140,5 @@ check_ifb() {
746746+ setup_ifb() {
747747+748748+- for ifb in `ifconfig -a -s|egrep ^ifb|cut -d ' ' -f1`
749749++ for ifb in `@ifconfig@ -a -s|@egrep@ ^ifb|@cut@ -d ' ' -f1`
750750+ do
751751+ check_ifb "$ifb" || continue
752752+@@ -155,5 +155,5 @@ setup_ifb() {
753753+ #because we need to cleanup
754754+ xenstore_write "$XENBUS_PATH/ifb" "$REMUS_IFB"
755755+- do_or_die ip link set dev "$REMUS_IFB" up
756756++ do_or_die @ip@ link set dev "$REMUS_IFB" up
757757+ }
758758+759759+@@ -162,12 +162,12 @@ redirect_vif_traffic() {
760760+ local ifb=$2
761761+762762+- do_or_die tc qdisc add dev "$vif" ingress
763763++ do_or_die @tc@ qdisc add dev "$vif" ingress
764764+765765+- tc filter add dev "$vif" parent ffff: proto ip prio 10 \
766766++ @tc@ filter add dev "$vif" parent ffff: proto ip prio 10 \
767767+ u32 match u32 0 0 action mirred egress redirect dev "$ifb" >/dev/null 2>&1
768768+769769+ if [ $? -ne 0 ]
770770+ then
771771+- do_without_error tc qdisc del dev "$vif" ingress
772772++ do_without_error @tc@ qdisc del dev "$vif" ingress
773773+ fatal "Failed to redirect traffic from $vif to $ifb"
774774+ fi
775775+@@ -178,13 +178,13 @@ add_plug_qdisc() {
776776+ local ifb=$2
777777+778778+- nl-qdisc-add --dev="$ifb" --parent root plug >/dev/null 2>&1
779779++ @nl-qdisc-add@ --dev="$ifb" --parent root plug >/dev/null 2>&1
780780+ if [ $? -ne 0 ]
781781+ then
782782+- do_without_error tc qdisc del dev "$vif" ingress
783783++ do_without_error @tc@ qdisc del dev "$vif" ingress
784784+ fatal "Failed to add plug qdisc to $ifb"
785785+ fi
786786+787787+ #set ifb buffering limit in bytes. Its okay if this command fails
788788+- nl-qdisc-add --dev="$ifb" --parent root \
789789++ @nl-qdisc-add@ --dev="$ifb" --parent root \
790790+ --update plug --limit=10000000 >/dev/null 2>&1 || true
791791+ }
792792+@@ -201,9 +201,9 @@ teardown_netbuf() {
793793+794794+ if [[ "$ifb2" && "$ifb2" == "$ifb" ]]; then
795795+- do_without_error ip link set dev "$ifb" down
796796+- do_without_error nl-qdisc-delete --dev="$ifb" --parent root plug >/dev/null 2>&1
797797++ do_without_error @ip@ link set dev "$ifb" down
798798++ do_without_error @nl-qdisc-delete@ --dev="$ifb" --parent root plug >/dev/null 2>&1
799799+ xenstore-rm -t "$XENBUS_PATH/ifb" 2>/dev/null || true
800800+ fi
801801+- do_without_error tc qdisc del dev "$vif" ingress
802802++ do_without_error @tc@ qdisc del dev "$vif" ingress
803803+ xenstore-rm -t "$XENBUS_PATH/hotplug-status" 2>/dev/null || true
804804+ xenstore-rm -t "$XENBUS_PATH/hotplug-error" 2>/dev/null || true
805805+diff --git a/tools/hotplug/Linux/systemd/xen-init-dom0.service.in b/tools/hotplug/Linux/systemd/xen-init-dom0.service.in
806806+index 98779b8507..cc75339377 100644
807807+--- a/tools/hotplug/Linux/systemd/xen-init-dom0.service.in
808808++++ b/tools/hotplug/Linux/systemd/xen-init-dom0.service.in
809809+@@ -9,5 +9,5 @@ Type=oneshot
810810+ RemainAfterExit=true
811811+ EnvironmentFile=-@CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons
812812+-ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
813813++ExecStartPre=@grep@ -q control_d /proc/xen/capabilities
814814+ ExecStart=@LIBEXEC_BIN@/xen-init-dom0 $XEN_DOM0_UUID
815815+816816+diff --git a/tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in b/tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in
817817+index f56775bc87..a9091047da 100644
818818+--- a/tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in
819819++++ b/tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in
820820+@@ -10,6 +10,6 @@ ConditionPathExists=/proc/xen/capabilities
821821+ Type=simple
822822+ PIDFile=@XEN_RUN_DIR@/qemu-dom0.pid
823823+-ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
824824+-ExecStartPre=/bin/mkdir -p @XEN_RUN_DIR@
825825++ExecStartPre=@grep@ -q control_d /proc/xen/capabilities
826826++ExecStartPre=@mkdir@ -p @XEN_RUN_DIR@
827827+ ExecStart=@qemu_xen_systemd@ -xen-domid 0 \
828828+ -xen-attach -name dom0 -nographic -M xenpv -daemonize \
829829+diff --git a/tools/hotplug/Linux/systemd/xenconsoled.service.in b/tools/hotplug/Linux/systemd/xenconsoled.service.in
830830+index d84c09aa9c..68317246ae 100644
831831+--- a/tools/hotplug/Linux/systemd/xenconsoled.service.in
832832++++ b/tools/hotplug/Linux/systemd/xenconsoled.service.in
833833+@@ -11,6 +11,6 @@ Environment=XENCONSOLED_TRACE=none
834834+ Environment=XENCONSOLED_LOG_DIR=@XEN_LOG_DIR@/console
835835+ EnvironmentFile=-@CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons
836836+-ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
837837+-ExecStartPre=/bin/mkdir -p ${XENCONSOLED_LOG_DIR} @XEN_RUN_DIR@
838838++ExecStartPre=@grep@ -q control_d /proc/xen/capabilities
839839++ExecStartPre=@mkdir@ -p ${XENCONSOLED_LOG_DIR} @XEN_RUN_DIR@
840840+ ExecStart=@sbindir@/xenconsoled -i --log=${XENCONSOLED_TRACE} --log-dir=${XENCONSOLED_LOG_DIR} $XENCONSOLED_ARGS
841841+842842+diff --git a/tools/hotplug/Linux/systemd/xendomains.service.in b/tools/hotplug/Linux/systemd/xendomains.service.in
843843+index c7bfb61eb4..314ed9e91a 100644
844844+--- a/tools/hotplug/Linux/systemd/xendomains.service.in
845845++++ b/tools/hotplug/Linux/systemd/xendomains.service.in
846846+@@ -11,5 +11,5 @@ Conflicts=libvirtd.service
847847+ Type=oneshot
848848+ RemainAfterExit=true
849849+-ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
850850++ExecStartPre=@grep@ -q control_d /proc/xen/capabilities
851851+ ExecStart=-@LIBEXEC_BIN@/xendomains start
852852+ ExecStop=@LIBEXEC_BIN@/xendomains stop
853853+diff --git a/tools/hotplug/Linux/systemd/xenstored.service.in b/tools/hotplug/Linux/systemd/xenstored.service.in
854854+index 261077dc92..7daf7369b8 100644
855855+--- a/tools/hotplug/Linux/systemd/xenstored.service.in
856856++++ b/tools/hotplug/Linux/systemd/xenstored.service.in
857857+@@ -11,5 +11,5 @@ Type=notify
858858+ NotifyAccess=all
859859+ RemainAfterExit=true
860860+-ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
861861++ExecStartPre=@grep@ -q control_d /proc/xen/capabilities
862862+ ExecStart=@XEN_SCRIPT_DIR@/launch-xenstore
863863+864864+diff --git a/tools/hotplug/Linux/vif-bridge b/tools/hotplug/Linux/vif-bridge
865865+index 906047e82f..e110013b14 100644
866866+--- a/tools/hotplug/Linux/vif-bridge
867867++++ b/tools/hotplug/Linux/vif-bridge
868868+@@ -26,5 +26,5 @@
869869+ #============================================================================
870870+871871+-dir=$(dirname "$0")
872872++dir=$(@dirname@ "$0")
873873+ . "$dir/vif-common.sh"
874874+875875+@@ -33,8 +33,8 @@ bridge=$(xenstore_read_default "$XENBUS_PATH/bridge" "$bridge")
876876+877877+ if [ -z "$bridge" ]; then
878878+- if which brctl >&/dev/null; then
879879+- bridge=$(brctl show | awk 'NR==2{print$1}')
880880++ if @which@ @brctl@ >&/dev/null; then
881881++ bridge=$(@brctl@ show | @awk@ 'NR==2{print$1}')
882882+ else
883883+- bridge=$(bridge link | cut -d" " -f7)
884884++ bridge=$(@bridge@ link | @cut@ -d" " -f7)
885885+ fi
886886+ if [ -z "$bridge" ]
887887+@@ -71,5 +71,5 @@ fi
888888+889889+ RET=0
890890+-ip link show dev "$bridge" 1>/dev/null 2>&1 || RET=1
891891++@ip@ link show dev "$bridge" 1>/dev/null 2>&1 || RET=1
892892+ if [ "$RET" -eq 1 ]
893893+ then
894894+diff --git a/tools/hotplug/Linux/vif-common.sh b/tools/hotplug/Linux/vif-common.sh
895895+index a8e65178f9..28eb851f94 100644
896896+--- a/tools/hotplug/Linux/vif-common.sh
897897++++ b/tools/hotplug/Linux/vif-common.sh
898898+@@ -16,5 +16,5 @@
899899+900900+901901+-dir=$(dirname "$0")
902902++dir=$(@dirname@ "$0")
903903+ . "$dir/xen-hotplug-common.sh"
904904+ . "$dir/xen-network-common.sh"
905905+@@ -73,9 +73,9 @@ rename_vif() {
906906+ # that interface (e.g. another running domU) because it's likely a
907907+ # configuration error
908908+- if ip link show "$vifname" >&/dev/null
909909++ if @ip@ link show "$vifname" >&/dev/null
910910+ then
911911+ fatal "Cannot rename interface $dev. An interface with name $vifname already exists."
912912+ fi
913913+- do_or_die ip link set "$dev" name "$vifname"
914914++ do_or_die @ip@ link set "$dev" name "$vifname"
915915+ }
916916+917917+@@ -135,10 +135,10 @@ iptables_w()
918918+ {
919919+ if ! $IPTABLES_WAIT_RUNE_CHECKED ; then
920920+- iptables $IPTABLES_WAIT_RUNE -L -n >& /dev/null
921921++ @iptables@ $IPTABLES_WAIT_RUNE -L -n >& /dev/null
922922+ if [[ $? == 0 ]] ; then
923923+ # If we succeed, then -w is supported; don't check again
924924+ IPTABLES_WAIT_RUNE_CHECKED=true
925925+ elif [[ $? == 2 ]] ; then
926926+- iptables -L -n >& /dev/null
927927++ @iptables@ -L -n >& /dev/null
928928+ if [[ $? != 2 ]] ; then
929929+ # If we fail with PARAMETER_PROBLEM (2) with -w and
930930+@@ -150,5 +150,5 @@ iptables_w()
931931+ fi
932932+ fi
933933+- iptables $IPTABLES_WAIT_RUNE "$@"
934934++ @iptables@ $IPTABLES_WAIT_RUNE "$@"
935935+ }
936936+937937+@@ -221,5 +221,5 @@ handle_iptable()
938938+ ip_of()
939939+ {
940940+- ip -4 -o addr show primary dev "$1" | awk '$3 == "inet" {split($4,i,"/"); print i[1]; exit}'
941941++ @ip@ -4 -o addr show primary dev "$1" | @awk@ '$3 == "inet" {split($4,i,"/"); print i[1]; exit}'
942942+ }
943943+944944+diff --git a/tools/hotplug/Linux/vif-nat b/tools/hotplug/Linux/vif-nat
945945+index fd34afbb96..8921de58f3 100644
946946+--- a/tools/hotplug/Linux/vif-nat
947947++++ b/tools/hotplug/Linux/vif-nat
948948+@@ -22,5 +22,5 @@
949949+950950+951951+-dir=$(dirname "$0")
952952++dir=$(@dirname@ "$0")
953953+ . "$dir/vif-common.sh"
954954+955955+@@ -62,5 +62,5 @@ ip_from_dom()
956956+ routing_ip()
957957+ {
958958+- echo $(echo $1 | awk -F. '{print $1"."$2"."$3"."$4 + 127}')
959959++ echo $(echo $1 | @awk@ -F. '{print $1"."$2"."$3"."$4 + 127}')
960960+ }
961961+962962+@@ -84,5 +84,5 @@ router_ip=$(routing_ip "$ip")
963963+964964+ # Split the given IP/bits pair.
965965+-vif_ip=`echo ${ip} | awk -F/ '{print $1}'`
966966++vif_ip=`echo ${ip} | @awk@ -F/ '{print $1}'`
967967+968968+ hostname=dom$domid
969969+@@ -94,11 +94,11 @@ fi
970970+ dhcparg_remove_entry()
971971+ {
972972+- local tmpfile=$(mktemp)
973973+- sed -e "s/${dev} //" "$dhcpd_arg_file" >"$tmpfile"
974974+- if ! diff "$tmpfile" "$dhcpd_arg_file" >/dev/null
975975++ local tmpfile=$(@mktemp@)
976976++ @sed@ -e "s/${dev} //" "$dhcpd_arg_file" >"$tmpfile"
977977++ if ! @diff@ "$tmpfile" "$dhcpd_arg_file" >/dev/null
978978+ then
979979+- cp "$tmpfile" "$dhcpd_arg_file"
980980++ @cp@ "$tmpfile" "$dhcpd_arg_file"
981981+ fi
982982+- rm "$tmpfile"
983983++ @rm@ "$tmpfile"
984984+ }
985985+986986+@@ -106,24 +106,24 @@ dhcparg_add_entry()
987987+ {
988988+ dhcparg_remove_entry
989989+- local tmpfile=$(mktemp)
990990++ local tmpfile=$(@mktemp@)
991991+ # handle Red Hat, SUSE, and Debian styles, with or without quotes
992992+- sed -e 's/^DHCPDARGS="*\([^"]*\)"*/DHCPDARGS="\1'"${dev} "'"/' \
993993+- "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file"
994994+- sed -e 's/^DHCPD_INTERFACE="*\([^"]*\)"*/DHCPD_INTERFACE="\1'"${dev} "'"/' \
995995+- "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file"
996996+- sed -e 's/^INTERFACES="*\([^"]*\)"*/INTERFACES="\1'"${dev} "'"/' \
997997+- "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file"
998998+- rm -f "$tmpfile"
999999++ @sed@ -e 's/^DHCPDARGS="*\([^"]*\)"*/DHCPDARGS="\1'"${dev} "'"/' \
10001000++ "$dhcpd_arg_file" >"$tmpfile" && @cp@ "$tmpfile" "$dhcpd_arg_file"
10011001++ @sed@ -e 's/^DHCPD_INTERFACE="*\([^"]*\)"*/DHCPD_INTERFACE="\1'"${dev} "'"/' \
10021002++ "$dhcpd_arg_file" >"$tmpfile" && @cp@ "$tmpfile" "$dhcpd_arg_file"
10031003++ @sed@ -e 's/^INTERFACES="*\([^"]*\)"*/INTERFACES="\1'"${dev} "'"/' \
10041004++ "$dhcpd_arg_file" >"$tmpfile" && @cp@ "$tmpfile" "$dhcpd_arg_file"
10051005++ @rm@ -f "$tmpfile"
10061006+ }
10071007+10081008+ dhcp_remove_entry()
10091009+ {
10101010+- local tmpfile=$(mktemp)
10111011+- grep -v "host $hostname" "$dhcpd_conf_file" >"$tmpfile"
10121012+- if ! diff "$tmpfile" "$dhcpd_conf_file" >/dev/null
10131013++ local tmpfile=$(@mktemp@)
10141014++ @grep@ -v "host $hostname" "$dhcpd_conf_file" >"$tmpfile"
10151015++ if ! @diff@ "$tmpfile" "$dhcpd_conf_file" >/dev/null
10161016+ then
10171017+- cp "$tmpfile" "$dhcpd_conf_file"
10181018++ @cp@ "$tmpfile" "$dhcpd_conf_file"
10191019+ fi
10201020+- rm "$tmpfile"
10211021++ @rm@ "$tmpfile"
10221022+ dhcparg_remove_entry
10231023+ }
10241024+@@ -159,5 +159,5 @@ dhcp_down()
10251025+ case "$command" in
10261026+ online)
10271027+- if ip route | grep -q "dev ${dev}"
10281028++ if @ip@ route | @grep@ -q "dev ${dev}"
10291029+ then
10301030+ log debug "${dev} already up"
10311031+@@ -165,7 +165,7 @@ case "$command" in
10321032+ fi
10331033+10341034+- do_or_die ip link set dev "${dev}" up arp on
10351035+- do_or_die ip addr add "$router_ip" dev "${dev}"
10361036+- do_or_die ip route add "$vif_ip" dev "${dev}" src "$router_ip"
10371037++ do_or_die @ip@ link set dev "${dev}" up arp on
10381038++ do_or_die @ip@ addr add "$router_ip" dev "${dev}"
10391039++ do_or_die @ip@ route add "$vif_ip" dev "${dev}" src "$router_ip"
10401040+ echo 1 >/proc/sys/net/ipv4/conf/${dev}/proxy_arp
10411041+ [ "$dhcp" != 'no' ] && dhcp_up
10421042+@@ -173,5 +173,5 @@ case "$command" in
10431043+ offline)
10441044+ [ "$dhcp" != 'no' ] && dhcp_down
10451045+- do_without_error ifconfig "${dev}" down
10461046++ do_without_error @ifconfig@ "${dev}" down
10471047+ ;;
10481048+ esac
10491049+diff --git a/tools/hotplug/Linux/vif-openvswitch b/tools/hotplug/Linux/vif-openvswitch
10501050+index 18bfb6cefb..ea983481a3 100644
10511051+--- a/tools/hotplug/Linux/vif-openvswitch
10521052++++ b/tools/hotplug/Linux/vif-openvswitch
10531053+@@ -25,13 +25,13 @@
10541054+ #============================================================================
10551055+10561056+-dir=$(dirname "$0")
10571057++dir=$(@dirname@ "$0")
10581058+ . "$dir/vif-common.sh"
10591059+10601060+ check_tools()
10611061+ {
10621062+- if ! command -v ovs-vsctl > /dev/null 2>&1; then
10631063++ if ! command -v @ovs-vsctl@ > /dev/null 2>&1; then
10641064+ fatal "Unable to find ovs-vsctl tool"
10651065+ fi
10661066+- if ! command -v ip > /dev/null 2>&1; then
10671067++ if ! command -v @ip@ > /dev/null 2>&1; then
10681068+ fatal "Unable to find ip tool"
10691069+ fi
10701070+@@ -80,8 +80,8 @@ add_to_openvswitch () {
10711071+ local vif_details="$(openvswitch_external_id_all $dev)"
10721072+10731073+- do_or_die ovs-vsctl --timeout=30 \
10741074++ do_or_die @ovs-vsctl@ --timeout=30 \
10751075+ -- --if-exists del-port $dev \
10761076+ -- add-port "$bridge" $dev $tag_arg $trunk_arg $vif_details
10771077+- do_or_die ip link set $dev up
10781078++ do_or_die @ip@ link set $dev up
10791079+ }
10801080+10811081+@@ -94,7 +94,7 @@ case "$command" in
10821082+10831083+ remove|offline)
10841084+- do_without_error ovs-vsctl --timeout=30 \
10851085++ do_without_error @ovs-vsctl@ --timeout=30 \
10861086+ -- --if-exists del-port $dev
10871087+- do_without_error ip link set $dev down
10881088++ do_without_error @ip@ link set $dev down
10891089+ ;;
10901090+ esac
10911091+diff --git a/tools/hotplug/Linux/vif-route b/tools/hotplug/Linux/vif-route
10921092+index 9cd417a005..98d67a8659 100755
10931093+--- a/tools/hotplug/Linux/vif-route
10941094++++ b/tools/hotplug/Linux/vif-route
10951095+@@ -17,5 +17,5 @@
10961096+ #============================================================================
10971097+10981098+-dir=$(dirname "$0")
10991099++dir=$(@dirname@ "$0")
11001100+ . "${dir}/vif-common.sh"
11011101+11021102+@@ -24,5 +24,5 @@ main_ip=$(dom0_ip)
11031103+ case "${command}" in
11041104+ add|online)
11051105+- ifconfig ${dev} ${main_ip} netmask 255.255.255.255 up
11061106++ @ifconfig@ ${dev} ${main_ip} netmask 255.255.255.255 up
11071107+ echo 1 >/proc/sys/net/ipv4/conf/${dev}/proxy_arp
11081108+ ipcmd='add'
11091109+@@ -51,5 +51,5 @@ esac
11101110+ # the guest using those addresses.
11111111+ for addr in ${ip} ; do
11121112+- ${cmdprefix} ip route ${ipcmd} ${addr} dev ${dev} src ${main_ip} metric ${metric}
11131113++ ${cmdprefix} @ip@ route ${ipcmd} ${addr} dev ${dev} src ${main_ip} metric ${metric}
11141114+ done
11151115+11161116+diff --git a/tools/hotplug/Linux/vscsi b/tools/hotplug/Linux/vscsi
11171117+index 5ac26147ec..8f297e05df 100644
11181118+--- a/tools/hotplug/Linux/vscsi
11191119++++ b/tools/hotplug/Linux/vscsi
11201120+@@ -5,5 +5,5 @@
11211121+ #
11221122+11231123+-dir=$(dirname "$0")
11241124++dir=$(@dirname@ "$0")
11251125+ . "$dir/xen-hotplug-common.sh"
11261126+11271127+diff --git a/tools/hotplug/Linux/xen-hotplug-common.sh.in b/tools/hotplug/Linux/xen-hotplug-common.sh.in
11281128+index 8c2cb9e25a..e9c64efcb0 100644
11291129+--- a/tools/hotplug/Linux/xen-hotplug-common.sh.in
11301130++++ b/tools/hotplug/Linux/xen-hotplug-common.sh.in
11311131+@@ -15,5 +15,5 @@
11321132+ #
11331133+11341134+-dir=$(dirname "$0")
11351135++dir=$(@dirname@ "$0")
11361136+ . "$dir/hotplugpath.sh"
11371137+ . "$dir/logging.sh"
11381138+@@ -26,5 +26,5 @@ export PATH="${bindir}:${sbindir}:${LIBEXEC_BIN}:/sbin:/bin:/usr/bin:/usr/sbin:$
11391139+ export LD_LIBRARY_PATH="${libdir}${LD_LIBRARY_PATH+:}$LD_LIBRARY_PATH"
11401140+ export LANG="POSIX"
11411141+-unset $(set | grep ^LC_ | cut -d= -f1)
11421142++unset $(set | @grep@ ^LC_ | @cut@ -d= -f1)
11431143+11441144+ fatal() {
11451145+diff --git a/tools/hotplug/Linux/xen-network-common.sh b/tools/hotplug/Linux/xen-network-common.sh
11461146+index 42fa704e8d..f6cf1b11c0 100644
11471147+--- a/tools/hotplug/Linux/xen-network-common.sh
11481148++++ b/tools/hotplug/Linux/xen-network-common.sh
11491149+@@ -27,5 +27,5 @@
11501150+ # been renamed.
11511151+11521152+-if ! which ifup >/dev/null 2>/dev/null
11531153++if ! @which@ ifup >/dev/null 2>/dev/null
11541154+ then
11551155+ preiftransfer()
11561156+@@ -85,5 +85,5 @@ _setup_bridge_port() {
11571157+11581158+ # take interface down ...
11591159+- ip link set dev ${dev} down
11601160++ @ip@ link set dev ${dev} down
11611161+11621162+ if [ $virtual -ne 0 ] ; then
11631163+@@ -92,9 +92,9 @@ _setup_bridge_port() {
11641164+ # stolen by an Ethernet bridge for STP purposes.
11651165+ # (FE:FF:FF:FF:FF:FF)
11661166+- ip link set dev ${dev} address fe:ff:ff:ff:ff:ff || true
11671167++ @ip@ link set dev ${dev} address fe:ff:ff:ff:ff:ff || true
11681168+ fi
11691169+11701170+ # ... and configure it
11711171+- ip address flush dev ${dev}
11721172++ @ip@ address flush dev ${dev}
11731173+ }
11741174+11751175+@@ -112,10 +112,10 @@ create_bridge () {
11761176+ # Don't create the bridge if it already exists.
11771177+ if [ ! -e "/sys/class/net/${bridge}/bridge" ]; then
11781178+- if which brctl >&/dev/null; then
11791179+- brctl addbr ${bridge}
11801180+- brctl stp ${bridge} off
11811181+- brctl setfd ${bridge} 0
11821182++ if @which@ @brctl@ >&/dev/null; then
11831183++ @brctl@ addbr ${bridge}
11841184++ @brctl@ stp ${bridge} off
11851185++ @brctl@ setfd ${bridge} 0
11861186+ else
11871187+- ip link add name ${bridge} type bridge stp_state 0 forward_delay 0
11881188++ @ip@ link add name ${bridge} type bridge stp_state 0 forward_delay 0
11891189+ fi
11901190+ fi
11911191+@@ -130,8 +130,8 @@ add_to_bridge () {
11921192+ if [ ! -e "/sys/class/net/${bridge}/brif/${dev}" ]; then
11931193+ log debug "adding $dev to bridge $bridge"
11941194+- if which brctl >&/dev/null; then
11951195+- brctl addif ${bridge} ${dev}
11961196++ if @which@ @brctl@ >&/dev/null; then
11971197++ @brctl@ addif ${bridge} ${dev}
11981198+ else
11991199+- ip link set ${dev} master ${bridge}
12001200++ @ip@ link set ${dev} master ${bridge}
12011201+ fi
12021202+ else
12031203+@@ -139,5 +139,5 @@ add_to_bridge () {
12041204+ fi
12051205+12061206+- ip link set dev ${dev} up
12071207++ @ip@ link set dev ${dev} up
12081208+ }
12091209+12101210+@@ -146,13 +146,13 @@ remove_from_bridge () {
12111211+ local dev=$2
12121212+12131213+- do_without_error ip link set dev ${dev} down
12141214++ do_without_error @ip@ link set dev ${dev} down
12151215+12161216+ # Don't remove $dev from $bridge if it's not on the bridge.
12171217+ if [ -e "/sys/class/net/${bridge}/brif/${dev}" ]; then
12181218+ log debug "removing $dev from bridge $bridge"
12191219+- if which brctl >&/dev/null; then
12201220+- do_without_error brctl delif ${bridge} ${dev}
12211221++ if @which@ @brctl@ >&/dev/null; then
12221222++ do_without_error @brctl@ delif ${bridge} ${dev}
12231223+ else
12241224+- do_without_error ip link set ${dev} nomaster
12251225++ do_without_error @ip@ link set ${dev} nomaster
12261226+ fi
12271227+ else
12281228+@@ -172,5 +172,5 @@ set_mtu () {
12291229+ if [ -z "$mtu" ]
12301230+ then
12311231+- mtu="`ip link show dev ${bridge}| awk '/mtu/ { print $5 }'`"
12321232++ mtu="`@ip@ link show dev ${bridge}| @awk@ '/mtu/ { print $5 }'`"
12331233+ if [ -n "$mtu" ]
12341234+ then
12351235+@@ -181,5 +181,5 @@ set_mtu () {
12361236+ then
12371237+ log debug "setting $dev MTU to $mtu"
12381238+- ip link set dev ${dev} mtu ${mtu} || :
12391239++ @ip@ link set dev ${dev} mtu ${mtu} || :
12401240+12411241+ if [ ${type_if} = vif ]
12421242+diff --git a/tools/hotplug/Linux/xendomains.in b/tools/hotplug/Linux/xendomains.in
12431243+index 70f4129ef4..b066404b0d 100644
12441244+--- a/tools/hotplug/Linux/xendomains.in
12451245++++ b/tools/hotplug/Linux/xendomains.in
12461246+@@ -151,5 +151,5 @@ else
12471247+ fi
12481248+12491249+-if ! which usleep >&/dev/null
12501250++if ! @which@ usleep >&/dev/null
12511251+ then
12521252+ usleep()
12531253+@@ -157,5 +157,5 @@ then
12541254+ if [ -n "$1" ]
12551255+ then
12561256+- sleep $(( $1 / 1000000 ))
12571257++ @sleep@ $(( $1 / 1000000 ))
12581258+ fi
12591259+ }
12601260+@@ -171,5 +171,5 @@ rc_reset
12611261+ contains_something()
12621262+ {
12631263+- if [ -d "$1" ] && [ `/bin/ls $1 | wc -l` -gt 0 ]
12641264++ if [ -d "$1" ] && [ `@ls@ $1 | wc -l` -gt 0 ]
12651265+ then
12661266+ return 0
12671267+@@ -183,5 +183,5 @@ rdname()
12681268+ {
12691269+ NM=$($CMD create --quiet --dryrun --defconfig "$1" |
12701270+- sed -n 's/^.*(name \(.*\))$/\1/p;s/^.*"name": "\(.*\)",$/\1/p')
12711271++ @sed@ -n 's/^.*(name \(.*\))$/\1/p;s/^.*"name": "\(.*\)",$/\1/p')
12721272+ }
12731273+12741274+@@ -218,11 +218,11 @@ parseln()
12751275+ name=;id=
12761276+ elif [[ "$1" =~ '(name' ]]; then
12771277+- name=$(echo $1 | sed -e 's/^.*(name \(.*\))$/\1/')
12781278++ name=$(echo $1 | @sed@ -e 's/^.*(name \(.*\))$/\1/')
12791279+ elif [[ "$1" =~ '(domid' ]]; then
12801280+- id=$(echo $1 | sed -e 's/^.*(domid \(.*\))$/\1/')
12811281++ id=$(echo $1 | @sed@ -e 's/^.*(domid \(.*\))$/\1/')
12821282+ elif [[ "$1" =~ '"name":' ]]; then
12831283+- name=$(echo $1 | sed -e 's/^.*"name": "\(.*\)",$/\1/')
12841284++ name=$(echo $1 | @sed@ -e 's/^.*"name": "\(.*\)",$/\1/')
12851285+ elif [[ "$1" =~ '"domid":' ]]; then
12861286+- id=$(echo $1 | sed -e 's/^.*"domid": \(.*\),$/\1/')
12871287++ id=$(echo $1 | @sed@ -e 's/^.*"domid": \(.*\),$/\1/')
12881288+ fi
12891289+12901290+@@ -245,5 +245,5 @@ is_running()
12911291+ ;;
12921292+ esac
12931293+- done < <($CMD list -l | grep "$LIST_GREP")
12941294++ done < <($CMD list -l | @grep@ "$LIST_GREP")
12951295+ return $RC
12961296+ }
12971297+@@ -256,5 +256,5 @@ start()
12981298+ fi
12991299+13001300+- mkdir -p $(dirname "$LOCKFILE")
13011301++ @mkdir@ -p $(@dirname@ "$LOCKFILE")
13021302+ touch $LOCKFILE
13031303+13041304+@@ -267,5 +267,5 @@ start()
13051305+ for dom in $XENDOMAINS_SAVE/*; do
13061306+ if [ -f $dom ] ; then
13071307+- HEADER=`head -c 16 $dom | head -n 1 2> /dev/null`
13081308++ HEADER=`@head@ -c 16 $dom | @head@ -n 1 2> /dev/null`
13091309+ if [ "$HEADER" = "$HEADCOMP" ]; then
13101310+ echo -n " ${dom##*/}"
13111311+@@ -278,5 +278,5 @@ start()
13121312+ else
13131313+ # mv $dom ${dom%/*}/.${dom##*/}
13141314+- rm $dom
13151315++ @rm@ $dom
13161316+ fi
13171317+ fi
13181318+@@ -300,6 +300,6 @@ start()
13191319+ for dom in $XENDOMAINS_AUTO/*; do
13201320+ echo -n " ${dom##*/}"
13211321+- shortdom=$(echo $dom | sed -n 's/^.*\/\(.*\)$/\1/p')
13221322+- echo $saved_domains | grep -w $shortdom > /dev/null
13231323++ shortdom=$(echo $dom | @sed@ -n 's/^.*\/\(.*\)$/\1/p')
13241324++ echo $saved_domains | @grep@ -w $shortdom > /dev/null
13251325+ if [ $? -eq 0 ] || is_running $dom; then
13261326+ echo -n "(skip)"
13271327+@@ -329,5 +329,5 @@ all_zombies()
13281328+ return 1;
13291329+ fi
13301330+- done < <($CMD list -l | grep "$LIST_GREP")
13311331++ done < <($CMD list -l | @grep@ "$LIST_GREP")
13321332+ return 0
13331333+ }
13341334+@@ -346,14 +346,14 @@ watchdog_xencmd()
13351335+13361336+ usleep 20000
13371337+- for no in `seq 0 $XENDOMAINS_STOP_MAXWAIT`; do
13381338++ for no in `@seq@ 0 $XENDOMAINS_STOP_MAXWAIT`; do
13391339+ # exit if $CMD save/migrate/shutdown is finished
13401340+- PSAX=`ps axlw | grep "$CMD $1" | grep -v grep`
13411341++ PSAX=`ps axlw | @grep@ "$CMD $1" | @grep@ -v grep`
13421342+ if test -z "$PSAX"; then exit; fi
13431343+ if ! test -n "$3"; then echo -n '.'; fi
13441344+- sleep 1
13451345++ @sleep@ 1
13461346+ # go to kill immediately if there's only zombies left
13471347+ if all_zombies && test -n "$2"; then break; fi
13481348+ done
13491349+- sleep 1
13501350++ @sleep@ 1
13511351+ read PSF PSUID PSPID PSPPID < <(echo "$PSAX")
13521352+ # kill $CMD $1
13531353+@@ -435,5 +435,5 @@ stop()
13541354+ watchdog_xencmd save &
13551355+ WDOG_PID=$!
13561356+- mkdir -p "$XENDOMAINS_SAVE"
13571357++ @mkdir@ -p "$XENDOMAINS_SAVE"
13581358+ XMR=`$CMD save $id $XENDOMAINS_SAVE/$name 2>&1 1>/dev/null`
13591359+ if test $? -ne 0; then
13601360+@@ -462,5 +462,5 @@ stop()
13611361+ kill $WDOG_PID >/dev/null 2>&1
13621362+ fi
13631363+- done < <($CMD list -l | grep "$LIST_GREP")
13641364++ done < <($CMD list -l | @grep@ "$LIST_GREP")
13651365+13661366+ # NB. this shuts down ALL Xen domains (politely), not just the ones in
13671367+@@ -483,5 +483,5 @@ stop()
13681368+13691369+ # Unconditionally delete lock file
13701370+- rm -f $LOCKFILE
13711371++ @rm@ -f $LOCKFILE
13721372+13731373+ exec 2>&3
13741374+@@ -499,5 +499,5 @@ check_domain_up()
13751375+ ;;
13761376+ esac
13771377+- done < <($CMD list -l | grep "$LIST_GREP")
13781378++ done < <($CMD list -l | @grep@ "$LIST_GREP")
13791379+ return 1
13801380+ }
13811381+@@ -532,5 +532,5 @@ check_all_saved_domains_up()
13821382+ return 0
13831383+ fi
13841384+- missing=`/bin/ls $XENDOMAINS_SAVE`
13851385++ missing=`@ls@ $XENDOMAINS_SAVE`
13861386+ echo -n " MISS SAVED: " $missing
13871387+ return 1
13881388+--
13891389+2.49.0
13901390+
+401-6
pkgs/by-name/xe/xen/package.nix
···11{
22- buildXenPackage,
22+ lib,
33+ stdenv,
44+ testers,
55+ fetchgit,
66+ fetchpatch,
77+ replaceVars,
88+99+ # Xen
1010+ acpica-tools,
1111+ autoPatchelfHook,
1212+ binutils-unwrapped-all-targets,
1313+ bison,
1414+ bzip2,
1515+ cmake,
1616+ dev86,
1717+ e2fsprogs,
1818+ flex,
1919+ libnl,
2020+ libuuid,
2121+ lzo,
2222+ ncurses,
2323+ ocamlPackages,
2424+ perl,
2525+ pkg-config,
326 python3Packages,
44- fetchpatch,
2727+ systemd,
2828+ xz,
2929+ yajl,
3030+ zlib,
3131+ zstd,
3232+3333+ # Optional Components
3434+ withFlask ? false,
3535+ checkpolicy,
3636+ withIPXE ? true,
3737+ ipxe,
3838+ withOVMF ? true,
3939+ OVMF,
4040+ withSeaBIOS ? true,
4141+ seabios-qemu,
4242+4343+ # Documentation
4444+ pandoc,
4545+4646+ # Scripts
4747+ bridge-utils,
4848+ coreutils,
4949+ diffutils,
5050+ drbd,
5151+ gawk,
5252+ gnugrep,
5353+ gnused,
5454+ inetutils,
5555+ iproute2,
5656+ iptables,
5757+ kmod,
5858+ multipath-tools,
5959+ nbd,
6060+ openiscsi,
6161+ openvswitch,
6262+ psmisc,
6363+ util-linux,
6464+ which,
565}:
66677-buildXenPackage.override { inherit python3Packages; } {
6767+let
6868+ inherit (lib)
6969+ enableFeature
7070+ genAttrs
7171+ getExe
7272+ getExe'
7373+ licenses
7474+ optionalString
7575+ optionals
7676+ systems
7777+ teams
7878+ versionOlder
7979+ versions
8080+ warn
8181+ ;
8282+ inherit (systems.inspect.patterns) isLinux isAarch64;
8383+ inherit (licenses)
8484+ cc-by-40
8585+ gpl2Only
8686+ lgpl21Only
8787+ mit
8888+ ;
8989+9090+ # Mark versions older than minSupportedVersion as EOL.
9191+ minSupportedVersion = "4.17";
9292+9393+ scriptDeps =
9494+ let
9595+ mkTools = pkg: tools: genAttrs tools (tool: getExe' pkg tool);
9696+ in
9797+ (genAttrs [
9898+ "CONFIG_DIR"
9999+ "CONFIG_LEAF_DIR"
100100+ "LIBEXEC_BIN"
101101+ "XEN_LOG_DIR"
102102+ "XEN_RUN_DIR"
103103+ "XEN_SCRIPT_DIR"
104104+ "qemu_xen_systemd"
105105+ "sbindir"
106106+ ] (_: null))
107107+ // (mkTools coreutils [
108108+ "basename"
109109+ "cat"
110110+ "cp"
111111+ "cut"
112112+ "dirname"
113113+ "head"
114114+ "ls"
115115+ "mkdir"
116116+ "mktemp"
117117+ "readlink"
118118+ "rm"
119119+ "seq"
120120+ "sleep"
121121+ "stat"
122122+ ])
123123+ // (mkTools drbd [
124124+ "drbdadm"
125125+ "drbdsetup"
126126+ ])
127127+ // (mkTools gnugrep [
128128+ "egrep"
129129+ "grep"
130130+ ])
131131+ // (mkTools iproute2 [
132132+ "bridge"
133133+ "ip"
134134+ "tc"
135135+ ])
136136+ // (mkTools iptables [
137137+ "arptables"
138138+ "ip6tables"
139139+ "iptables"
140140+ ])
141141+ // (mkTools kmod [
142142+ "modinfo"
143143+ "modprobe"
144144+ "rmmod"
145145+ ])
146146+ // (mkTools libnl [
147147+ "nl-qdisc-add"
148148+ "nl-qdisc-delete"
149149+ "nl-qdisc-list"
150150+ ])
151151+ // (mkTools util-linux [
152152+ "flock"
153153+ "logger"
154154+ "losetup"
155155+ "prlimit"
156156+ ])
157157+ // {
158158+ awk = getExe' gawk "awk";
159159+ brctl = getExe bridge-utils;
160160+ diff = getExe' diffutils "diff";
161161+ ifconfig = getExe' inetutils "ifconfig";
162162+ iscsiadm = getExe' openiscsi "iscsiadm";
163163+ killall = getExe' psmisc "killall";
164164+ multipath = getExe' multipath-tools "multipath";
165165+ nbd-client = getExe' nbd "nbd-client";
166166+ ovs-vsctl = getExe' openvswitch "ovs-vsctl";
167167+ sed = getExe gnused;
168168+ systemd-notify = getExe' systemd "systemd-notify";
169169+ which = getExe which;
170170+ };
171171+in
172172+173173+stdenv.mkDerivation (finalAttrs: {
8174 pname = "xen";
9175 version = "4.20.0";
176176+177177+ # This attribute can be overriden to correct the file paths in
178178+ # `passthru` when building an unstable Xen.
179179+ upstreamVersion = finalAttrs.version;
180180+ # Useful for further identifying downstream Xen variants. (i.e. Qubes)
181181+ vendor = "nixos";
182182+10183 patches = [
184184+ ./0001-makefile-efi-output-directory.patch
185185+186186+ (replaceVars ./0002-scripts-external-executable-calls.patch scriptDeps)
187187+188188+ # XSA #469
11189 (fetchpatch {
12190 url = "https://xenbits.xenproject.org/xsa/xsa469/xsa469-4.20-01.patch";
13191 hash = "sha256-go743oBhYDuxsK0Xc6nK/WxutQQwc2ERtLKhCU9Dnng=";
···36214 url = "https://xenbits.xenproject.org/xsa/xsa469/xsa469-4.20-07.patch";
37215 hash = "sha256-+BsCJa01R2lrbu7tEluGrYSAqu2jJcrpFNUoLMY466c=";
38216 })
217217+218218+ # XSA #470
39219 (fetchpatch {
40220 url = "https://xenbits.xenproject.org/xsa/xsa470.patch";
41221 hash = "sha256-zhMZ6pCZtt0ocgsMFVqthMaof46lMMTaYmlepMXVJqM=";
42222 })
43223 ];
4444- rev = "3ad5d648cda5add395f49fc3704b2552aae734f7";
4545- hash = "sha256-v2DRJv+1bym8zAgU74lo1HQ/9rUcyK3qc4Eec4RpcEY=";
4646-}
224224+225225+ outputs = [
226226+ "out"
227227+ "man"
228228+ "doc"
229229+ "dev"
230230+ "boot"
231231+ ];
232232+233233+ src = fetchgit {
234234+ url = "https://xenbits.xenproject.org/git-http/xen.git";
235235+ rev = "3ad5d648cda5add395f49fc3704b2552aae734f7";
236236+ hash = "sha256-v2DRJv+1bym8zAgU74lo1HQ/9rUcyK3qc4Eec4RpcEY=";
237237+ };
238238+239239+ strictDeps = true;
240240+241241+ nativeBuildInputs =
242242+ [
243243+ acpica-tools
244244+ autoPatchelfHook
245245+ bison
246246+ cmake
247247+ dev86
248248+ flex
249249+ pandoc
250250+ perl
251251+ pkg-config
252252+253253+ # oxenstored
254254+ ocamlPackages.findlib
255255+ ocamlPackages.ocaml
256256+ ]
257257+ ++ (with python3Packages; [
258258+ python
259259+ setuptools
260260+ wrapPython
261261+ ]);
262262+263263+ buildInputs =
264264+ [
265265+ bzip2
266266+ e2fsprogs.dev
267267+ libnl
268268+ libuuid
269269+ lzo
270270+ ncurses
271271+ xz
272272+ yajl
273273+ zlib
274274+ zstd
275275+ ]
276276+ ++ optionals withFlask [ checkpolicy ]
277277+ ++ optionals (versionOlder finalAttrs.version "4.19") [ systemd ];
278278+279279+ configureFlags = [
280280+ "--enable-systemd"
281281+ "--disable-qemu-traditional"
282282+ "--with-system-qemu"
283283+ (if withSeaBIOS then "--with-system-seabios=${seabios-qemu.firmware}" else "--disable-seabios")
284284+ (if withOVMF then "--with-system-ovmf=${OVMF.mergedFirmware}" else "--disable-ovmf")
285285+ (if withIPXE then "--with-system-ipxe=${ipxe.firmware}" else "--disable-ipxe")
286286+ (enableFeature withFlask "xsmpolicy")
287287+ ];
288288+289289+ makeFlags =
290290+ [
291291+ "SUBSYSTEMS=${toString finalAttrs.buildFlags}"
292292+293293+ "PREFIX=$(out)"
294294+ "BASH_COMPLETION_DIR=$(PREFIX)/share/bash-completion/completions"
295295+296296+ "XEN_WHOAMI=${finalAttrs.pname}"
297297+ "XEN_DOMAIN=${finalAttrs.vendor}"
298298+299299+ "GIT=${getExe' coreutils "false"}"
300300+ "WGET=${getExe' coreutils "false"}"
301301+ "EFI_VENDOR=${finalAttrs.vendor}"
302302+ "INSTALL_EFI_STRIP=1"
303303+ "LD=${getExe' binutils-unwrapped-all-targets "ld"}"
304304+ ]
305305+ # These flags set the CONFIG_* options in /boot/xen.config
306306+ # and define if the default policy file is built. However,
307307+ # the Flask binaries always get compiled by default.
308308+ ++ optionals withFlask [
309309+ "XSM_ENABLE=y"
310310+ "FLASK_ENABLE=y"
311311+ ];
312312+313313+ buildFlags = [
314314+ "xen"
315315+ "tools"
316316+ "docs"
317317+ ];
318318+319319+ enableParallelBuilding = true;
320320+321321+ env.NIX_CFLAGS_COMPILE = toString [
322322+ "-Wno-error=maybe-uninitialized"
323323+ "-Wno-error=array-bounds"
324324+ ];
325325+326326+ dontUseCmakeConfigure = true;
327327+328328+ # Remove in-tree QEMU sources, we don't need them in any circumstance.
329329+ prePatch = "rm -rf tools/qemu-xen tools/qemu-xen-traditional";
330330+331331+ installPhase = ''
332332+ runHook preInstall
333333+334334+ mkdir -p $out $out/share $boot
335335+ cp -prvd dist/install/nix/store/*/* $out/
336336+ cp -prvd dist/install/etc $out
337337+ cp -prvd dist/install/boot $boot
338338+339339+ runHook postInstall
340340+ '';
341341+342342+ postInstall =
343343+ # Wrap xencov_split, xenmon and xentrace_format.
344344+ # We also need to wrap pygrub, which lies in $out/libexec/xen/bin.
345345+ ''
346346+ wrapPythonPrograms
347347+ wrapPythonProgramsIn "$out/libexec/xen/bin" "$out $pythonPath"
348348+ '';
349349+350350+ postFixup =
351351+ ''
352352+ addAutoPatchelfSearchPath $out/lib
353353+ autoPatchelf $out/libexec/xen/bin
354354+ ''
355355+ # Flask is particularly hard to disable. Even after
356356+ # setting the make flags to `n`, it still gets compiled.
357357+ # If withFlask is disabled, delete the extra binaries.
358358+ + optionalString (!withFlask) ''
359359+ rm -f $out/bin/flask-*
360360+ '';
361361+362362+ passthru = {
363363+ efi = "boot/xen-${finalAttrs.upstreamVersion}.efi";
364364+ flaskPolicy =
365365+ if withFlask then
366366+ warn "This Xen was compiled with FLASK support, but the FLASK file may not match the Xen version number. Please hardcode the path to the FLASK file instead." "boot/xenpolicy-${finalAttrs.upstreamVersion}"
367367+ else
368368+ throw "This Xen was compiled without FLASK support.";
369369+ # This test suite is very simple, as Xen's userspace
370370+ # utilities require the hypervisor to be booted.
371371+ tests = {
372372+ pkg-config = testers.hasPkgConfigModules {
373373+ package = finalAttrs.finalPackage;
374374+ moduleNames = [
375375+ "xencall"
376376+ "xencontrol"
377377+ "xendevicemodel"
378378+ "xenevtchn"
379379+ "xenforeignmemory"
380380+ "xengnttab"
381381+ "xenguest"
382382+ "xenhypfs"
383383+ "xenlight"
384384+ "xenstat"
385385+ "xenstore"
386386+ "xentoolcore"
387387+ "xentoollog"
388388+ "xenvchan"
389389+ "xlutil"
390390+ ];
391391+ };
392392+ };
393393+ };
394394+395395+ meta = {
396396+ branch = versions.majorMinor finalAttrs.version;
397397+398398+ description = "Type-1 hypervisor intended for embedded and hyperscale use cases";
399399+ longDescription =
400400+ ''
401401+ The Xen Project Hypervisor is a virtualisation technology defined as a *type-1
402402+ hypervisor*, which allows multiple virtual machines, known as domains, to run
403403+ concurrently with the host on the physical machine. On a typical *type-2
404404+ hypervisor*, the virtual machines run as applications on top of the
405405+ host. NixOS runs as the privileged **Domain 0**, and can paravirtualise or fully
406406+ virtualise **Unprivileged Domains**.
407407+408408+ Use with the `qemu_xen` package.
409409+ ''
410410+ + "\nIncludes:\n* `xen.efi`: The Xen Project's [EFI binary](https://xenbits.xenproject.org/docs/${finalAttrs.meta.branch}-testing/misc/efi.html), available on the `boot` output of this package."
411411+ + optionalString withFlask "\n* `xsm-flask`: The [FLASK Xen Security Module](https://wiki.xenproject.org/wiki/Xen_Security_Modules_:_XSM-FLASK). The `xenpolicy` file is available on the `boot` output of this package."
412412+ + optionalString withSeaBIOS "\n* `seabios`: Support for the SeaBIOS boot firmware on HVM domains."
413413+ + optionalString withOVMF "\n* `ovmf`: Support for the OVMF UEFI boot firmware on HVM domains."
414414+ + optionalString withIPXE "\n* `ipxe`: Support for the iPXE boot firmware on HVM domains.";
415415+416416+ homepage = "https://xenproject.org/";
417417+ downloadPage = "https://downloads.xenproject.org/release/xen/${finalAttrs.version}/";
418418+ changelog = "https://wiki.xenproject.org/wiki/Xen_Project_${finalAttrs.meta.branch}_Release_Notes";
419419+420420+ license = [
421421+ # Documentation.
422422+ cc-by-40
423423+ # Most of Xen is licensed under the GPL v2.0.
424424+ gpl2Only
425425+ # Xen Libraries and the `xl` command-line utility.
426426+ lgpl21Only
427427+ # Development headers in $dev/include.
428428+ mit
429429+ ];
430430+431431+ teams = [ teams.xen ];
432432+ knownVulnerabilities = optionals (versionOlder finalAttrs.version minSupportedVersion) [
433433+ "The Xen Project Hypervisor version ${finalAttrs.version} is no longer supported by the Xen Project Security Team. See https://xenbits.xenproject.org/docs/unstable/support-matrix.html"
434434+ ];
435435+436436+ mainProgram = "xl";
437437+438438+ platforms = [ isLinux ];
439439+ badPlatforms = [ isAarch64 ];
440440+ };
441441+})
+1
pkgs/top-level/aliases.nix
···373373 buildBarebox = throw "buildBarebox has been removed due to lack of interest in maintaining it in nixpkgs"; # Added 2025-04-19
374374 buildGo122Module = throw "Go 1.22 is end-of-life, and 'buildGo122Module' has been removed. Please use a newer builder version."; # Added 2025-03-28
375375 buildGoPackage = throw "`buildGoPackage` has been deprecated and removed, see the Go section in the nixpkgs manual for details"; # Added 2024-11-18
376376+ buildXenPackage = throw "'buildXenPackage' has been removed as a custom Xen build can now be achieved by simply overriding 'xen'."; # Added 2025-05-12
376377377378 inherit (libsForQt5.mauiPackages) buho; # added 2022-05-17
378379 bwidget = tclPackages.bwidget; # Added 2024-10-02