ia64/xen-unstable

view tools/hotplug/Linux/block-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 c1340cda65fb
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/xen-hotplug-common.sh"
22 findCommand "$@"
24 if [ "$command" != "add" ] &&
25 [ "$command" != "remove" ]
26 then
27 log err "Invalid command: $command"
28 exit 1
29 fi
32 XENBUS_PATH="${XENBUS_PATH:?}"
35 ebusy()
36 {
37 xenstore_write "$XENBUS_PATH/hotplug-error" "$*" \
38 "$XENBUS_PATH/hotplug-status" busy
39 log err "$@"
40 exit 1
41 }
44 ##
45 # Print the given device's major and minor numbers, written in hex and
46 # separated by a colon.
47 device_major_minor()
48 {
49 stat -L -c %t:%T "$1"
50 }
53 ##
54 # Write physical-device = MM,mm to the store, where MM and mm are the major
55 # and minor numbers of device respectively.
56 #
57 # @param device The device from which major and minor numbers are read, which
58 # will be written into the store.
59 #
60 write_dev() {
61 local mm
63 mm=$(device_major_minor "$1")
65 if [ -z $mm ]
66 then
67 fatal "Backend device does not exist"
68 fi
70 xenstore_write "$XENBUS_PATH/physical-device" "$mm"
72 success
73 }
76 ##
77 # canonicalise_mode mode
78 #
79 # Takes the given mode, which may be r, w, ro, rw, w!, or rw!, or variations
80 # thereof, and canonicalises them to one of
81 #
82 # 'r': perform checks for a new read-only mount;
83 # 'w': perform checks for a read-write mount; or
84 # '!': perform no checks at all.
85 #
86 canonicalise_mode()
87 {
88 local mode="$1"
90 if ! expr index "$mode" 'w' >/dev/null
91 then
92 echo 'r'
93 elif ! expr index "$mode" '!' >/dev/null
94 then
95 echo 'w'
96 else
97 echo '!'
98 fi
99 }
102 same_vm()
103 {
104 local otherdom="$1"
105 # Note that othervm can be MISSING here, because Xend will be racing with
106 # the hotplug scripts -- the entries in /local/domain can be removed by
107 # Xend before the hotplug scripts have removed the entry in
108 # /local/domain/0/backend/. In this case, we want to pretend that the
109 # VM is the same as FRONTEND_UUID, because that way the 'sharing' will be
110 # allowed.
111 local othervm=$(xenstore_read_default "/local/domain/$otherdom/vm" \
112 "$FRONTEND_UUID")
114 [ "$FRONTEND_UUID" = "$othervm" ]
115 }