ia64/xen-unstable

view tools/hotplug/Linux/xen-hotplug-common.sh @ 19497:2f6ed9318c03

network-bridge: Fix do_ifup in the case of ${bridge} != ${netdev}

On RHEL5.2, ifup ${bridge} fails if ${bridge} != ${netdev},
because RHEL5.2's ifup ${bridge} runs the following sequence:

1. Search CONFIG that has the same mac address of ${bridge}.=20
ifcfg-${netdev} is found.
2. Run "ip link set dev ${netdev} up".
# ${bridge} is expected.
3. Output "Failed to bring up ${netdev}."
Because ${netdev} does not exist.

Thus, do_ifup() should not use ifup if ${bridge} != ${netdev}.

Signed-off-by: KUWAMURA Shin'ya <kuwa@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Apr 02 11:48:10 2009 +0100 (2009-04-02)
parents 4bfc67b09e9c
children 415505139333
line source
1 #
2 # Copyright (c) 2005 XenSource Ltd.
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of version 2.1 of the GNU Lesser General Public
6 # License as published by the Free Software Foundation.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 #
19 dir=$(dirname "$0")
20 . "$dir/logging.sh"
21 . "$dir/xen-script-common.sh"
22 . "$dir/locking.sh"
24 exec 2>>/var/log/xen/xen-hotplug.log
26 export PATH="/sbin:/bin:/usr/bin:/usr/sbin:$PATH"
27 export LANG="POSIX"
28 unset $(set | grep ^LC_ | cut -d= -f1)
30 fatal() {
31 xenstore_write "$XENBUS_PATH/hotplug-error" "$*" \
32 "$XENBUS_PATH/hotplug-status" error
33 log err "$@"
34 exit 1
35 }
37 success() {
38 # Tell DevController that backend is "connected"
39 xenstore_write "$XENBUS_PATH/hotplug-status" connected
40 }
42 do_or_die() {
43 "$@" || fatal "$@ failed"
44 }
46 do_without_error() {
47 "$@" 2>/dev/null || log debug "$@ failed"
48 }
50 sigerr() {
51 fatal "$0 failed; error detected."
52 }
54 trap sigerr ERR
57 ##
58 # xenstore_read <path>+
59 #
60 # Read each of the given paths, returning each result on a separate line, or
61 # exit this script if any of the paths is missing.
62 #
63 xenstore_read() {
64 local v=$(xenstore-read "$@" || true)
65 [ "$v" != "" ] || fatal "xenstore-read $@ failed."
66 echo "$v"
67 }
70 ##
71 # xenstore_read_default <path> <default>
72 #
73 # Read the given path, returning the value there or the given default if the
74 # path is not present.
75 #
76 xenstore_read_default() {
77 xenstore-read "$1" 2>/dev/null || echo "$2"
78 }
81 ##
82 # xenstore_write (<path> <value>)+
83 #
84 # Write each of the key/value pairs to the store, and exit this script if any
85 # such writing fails.
86 #
87 xenstore_write() {
88 log debug "Writing $@ to xenstore."
89 xenstore-write "$@" || fatal "Writing $@ to xenstore failed."
90 }
93 log debug "$@" "XENBUS_PATH=$XENBUS_PATH"