2
# Copyright (c) 2005 XenSource Ltd.
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.
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.
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
20
. "$dir/xen-hotplug-common.sh"
24
if [ "$command" != "add" ] &&
25
[ "$command" != "remove" ]
27
log err "Invalid command: $command"
32
XENBUS_PATH="${XENBUS_PATH:?}"
37
xenstore_write "$XENBUS_PATH/hotplug-error" "$*" \
38
"$XENBUS_PATH/hotplug-status" busy
45
# Print the given device's major and minor numbers, written in hex and
46
# separated by a colon.
54
# Write physical-device = MM,mm to the store, where MM and mm are the major
55
# and minor numbers of device respectively.
57
# @param device The device from which major and minor numbers are read, which
58
# will be written into the store.
63
mm=$(device_major_minor "$1")
67
fatal "Backend device does not exist"
70
xenstore_write "$XENBUS_PATH/physical-device" "$mm"
77
# canonicalise_mode mode
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
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.
90
if ! expr index "$mode" 'w' >/dev/null
93
elif ! expr index "$mode" '!' >/dev/null
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
111
local othervm=$(xenstore_read_default "/local/domain/$otherdom/vm" \
113
local target=$(xenstore_read_default "/local/domain/$FRONTEND_ID/target" \
115
local otarget=$(xenstore_read_default "/local/domain/$otherdom/target" \
117
local otvm=$(xenstore_read_default "/local/domain/$otarget/vm" \
120
othervm=${othervm%-1}
121
local frontend_uuid=${FRONTEND_UUID%-1}
123
[ "$frontend_uuid" = "$othervm" -o "$target" = "$otherdom" -o "$frontend_uuid" = "$otvm" ]