[Pkg-xen-devel] Bug#588406: xen-utils-common: /etc/xen/scripts/block not driving helper scripts; XEN_SCRIPT_DIR not properly set

James Pfeifer james at pfeifdom.net
Thu Jul 8 04:05:13 UTC 2010


Package: xen-utils-common
Version: 4.0.0-1
Severity: normal


After upgrading xen-utils-common from 3.4.2-4 to 4.0.0-1, I could not create
a guest domain defined with a DRBD file type.  The xm create command would 
fail with "Error: Device 51713 (vbd) could not be connected. Hotplug scripts
not working.".  After some research I realized the /etc/xen/scripts/block-drbd
helper script was not being driven.  My work around was to modify
/etc/xen/scripts/block; I replaced
[ -x ${XEN_SCRIPT_DIR}/block-"$t" ] && \
  ${XEN_SCRIPT_DIR}/block-"$t$" "$command" $node
with
[ -x /etc/xen/scripts/block-"$t" ] && \
  /etc/xen/scripts/block-"$t" "$command" $node
It appears as though XEN_SCRIPT_DIR has not been properly set.

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-xen-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages xen-utils-common depends on:
ii  gawk                      1:3.1.7.dfsg-5 GNU awk, a pattern scanning and pr
ii  lsb-base                  3.2-23.1       Linux Standard Base 3.2 init scrip
ii  udev                      158-1          /dev/ and hotplug management daemo
ii  xenstore-utils            3.4.3-1        Xenstore utilities for Xen

xen-utils-common recommends no packages.

xen-utils-common suggests no packages.

-- Configuration Files:
/etc/xen/scripts/block changed:
dir=$(dirname "$0")
. "$dir/block-common.sh"
expand_dev() {
  local dev
  case $1 in
  /*)
    dev=$1
    ;;
  *)
    dev=/dev/$1
    ;;
  esac
  echo -n $dev
}
find_free_loopback_helper() {
  local next_devnum=0
  local busy_devnum
  while read busy_devnum; do
    if [ "$next_devnum" != "$busy_devnum" ]; then
      break
    fi
    let next_devnum=$next_devnum+1
  done
  echo "/dev/loop${next_devnum}"
}
find_free_loopback_dev() {
  local loopdev
  loopdev=$(losetup -a | sed -e 's+^/dev/loop++' -e 's/:.*//' | find_free_loopback_helper)
  if [ -n "$loopdev" ] && [ -b "$loopdev" ]; then
    echo "$loopdev"
  fi
}
check_sharing()
{
  local dev="$1"
  local mode="$2"
  local devmm=$(device_major_minor "$dev")
  local file
  if [ "$mode" = 'w' ]
  then
    toskip="^$"
  else
    toskip="^[^ ]* [^ ]* [^ ]* ro[, ]"
  fi
  for file in $(cat /proc/mounts | grep -v "$toskip" | cut -f 1 -d ' ')
  do
    if [ -e "$file" ]
    then
      local d=$(device_major_minor "$file")
      if [ "$d" = "$devmm" ]
      then
        echo 'local'
        return
      fi
    fi
  done
  local base_path="$XENBUS_BASE_PATH/$XENBUS_TYPE"
  for dom in $(xenstore-list "$base_path")
  do
    for dev in $(xenstore-list "$base_path/$dom")
    do
      d=$(xenstore_read_default "$base_path/$dom/$dev/physical-device" "")
      if [ "$d" = "$devmm" ]
      then
        if [ "$mode" = 'w' ]
        then
          if ! same_vm $dom
          then
            echo 'guest'
            return
          fi
        else
          local m=$(xenstore_read_default "$base_path/$dom/$dev/mode" "")
          m=$(canonicalise_mode "$m")
          if [ "$m" = 'w' ]
          then
            if ! same_vm $dom
            then
              echo 'guest'
              return
            fi
          fi
        fi
      fi
    done
  done
  echo 'ok'
}
check_device_sharing()
{
  local dev="$1"
  local mode=$(canonicalise_mode "$2")
  local result
  if [ "x$mode" = 'x!' ]
  then
    return 0
  fi
  result=$(check_sharing "$dev" "$mode")
  if [ "$result" != 'ok' ]
  then
    do_ebusy "Device $dev is mounted " "$mode" "$result"
  fi
}
check_file_sharing()
{
  local file="$1"
  local dev="$2"
  local mode="$3"
  result=$(check_sharing "$dev" "$mode")
  if [ "$result" != 'ok' ]
  then
    do_ebusy "File $file is loopback-mounted through $dev,
which is mounted " "$mode" "$result"
  fi
}
do_ebusy()
{
  local prefix="$1"
  local mode="$2"
  local result="$3"
  if [ "$result" = 'guest' ]
  then
    dom='a guest '
    when='now'
  else
    dom='the privileged '
    when='by a guest'
  fi
  if [ "$mode" = 'w' ]
  then
    m1=''
    m2=''
  else
    m1='read-write '
    m2='read-only '
  fi
  release_lock "block"
  ebusy \
"${prefix}${m1}in ${dom}domain,
and so cannot be mounted ${m2}${when}."
}
t=$(xenstore_read_default "$XENBUS_PATH/type" 'MISSING')
case "$command" in
  add)
    phys=$(xenstore_read_default "$XENBUS_PATH/physical-device" 'MISSING')
    if [ "$phys" != 'MISSING' ]
    then
      # Depending upon the hotplug configuration, it is possible for this
      # script to be called twice, so just bail.
      exit 0
    fi
    if [ -n "$t" ]
    then
      p=$(xenstore_read "$XENBUS_PATH/params")
      mode=$(xenstore_read "$XENBUS_PATH/mode")
    fi
    FRONTEND_ID=$(xenstore_read "$XENBUS_PATH/frontend-id")
    FRONTEND_UUID=$(xenstore_read_default \
            "/local/domain/$FRONTEND_ID/vm" 'unknown')
    case $t in 
      phy)
        dev=$(expand_dev $p)
        if [ -L "$dev" ]
        then
          dev=$(readlink -f "$dev") || fatal "$dev link does not exist."
        fi
        test -e "$dev" || fatal "$dev does not exist."
        test -b "$dev" || fatal "$dev is not a block device."
        claim_lock "block"
        check_device_sharing "$dev" "$mode"
	write_dev "$dev"
        release_lock "block"
	exit 0
	;;
      file)
        # Canonicalise the file, for sharing check comparison, and the mode
        # for ease of use here.
        file=$(readlink -f "$p") || fatal "$p does not exist."
        test -f "$file" || fatal "$file does not exist."
        mode=$(canonicalise_mode "$mode")
        claim_lock "block"
        # Avoid a race with the remove if the path has been deleted, or
	# otherwise changed from "InitWait" state e.g. due to a timeout
        xenbus_state=$(xenstore_read_default "$XENBUS_PATH/state" 'unknown')
        if [ "$xenbus_state" != '2' ]
        then
          release_lock "block"
          fatal "Path closed or removed during hotplug add: $XENBUS_PATH state: $xenbus_state"
        fi
        if [ "$mode" = 'w' ] && ! stat "$file" -c %A | grep -q w
        then
          release_lock "block"
          ebusy \
"File $file is read-only, and so I will not
mount it read-write in a guest domain."
        fi
        if [ "x$mode" != 'x!' ]
        then
          inode=$(stat -c '%i' $file)
          dev=$(stat -c '%D' $file)
          if [ -z "$inode" ] || [ -z "$dev" ]
          then
            fatal "Unable to lookup $file: dev: $dev inode: $inode"
          fi
          shared_list=$(losetup -a | grep ' \[0*'${dev}'\]:'${inode} |
                cut -d : -f 1)
          for dev in "$shared_list"
          do
            if [ -n "$dev" ]
            then
              check_file_sharing "$file" "$dev" "$mode"
            fi
          done
        fi
        loopdev=$(losetup -f 2>/dev/null || find_free_loopback_dev)
        if [ "$loopdev" = '' ]
        then
          release_lock "block"
          fatal 'Failed to find an unused loop device'
        fi
        if LANG=C losetup -h 2>&1 | grep read-only >/dev/null
        then
          roflag="-$mode"; roflag="${roflag#-w}"; roflag="${roflag#-!}"
        else
          roflag=''
        fi
        do_or_die losetup $roflag "$loopdev" "$file"
        xenstore_write "$XENBUS_PATH/node" "$loopdev"
        write_dev "$loopdev"
        release_lock "block"
        exit 0
	;;
      "")
        claim_lock "block"
        success
        release_lock "block"
	;;
    esac
    ;;
  remove)
    case $t in 
      phy)
	exit 0
	;;
      file)
        claim_lock "block"
        node=$(xenstore_read "$XENBUS_PATH/node")
	losetup -d "$node"
        release_lock "block"
	exit 0
	;;
      "")
        exit 0
	;;
    esac
    ;;
esac
[ -x /etc/xen/scripts/block-"$t" ] && \
  /etc/xen/scripts/block-"$t" "$command" $node

/etc/xen/scripts/vif-bridge changed:
dir=$(dirname "$0")
. "$dir/vif-common.sh"
bridge=${bridge:-}
bridge=$(xenstore_read_default "$XENBUS_PATH/bridge" "$bridge")
if [ -z "$bridge" ]
then
  bridge=$(brctl show | cut -d "
" -f 2 | cut -f 1)
  if [ -z "$bridge" ]
  then
     fatal "Could not find bridge, and none was specified"
  fi
else
  #
  # Old style bridge setup with netloop, used to have a bridge name
  # of xenbrX, enslaving pethX and vif0.X, and then configuring
  # eth0.
  #
  # New style bridge setup does not use netloop, so the bridge name
  # is ethX and the physical device is enslaved pethX
  #
  # So if...
  #
  #   - User asks for xenbrX
  #   - AND xenbrX doesn't exist
  #   - AND there is a ethX device which is a bridge
  #
  # ..then we translate xenbrX to ethX
  #
  # This lets old config files work without modification
  #
  if [ ! -e "/sys/class/net/$bridge" ] && [ -z "${bridge##xenbr*}" ]
  then
     if [ -e "/sys/class/net/eth${bridge#xenbr}/bridge" ]
     then
        bridge="eth${bridge#xenbr}"
     fi
  fi
fi
RET=0
ip link show $bridge 1>/dev/null 2>&1 || RET=1
if [ "$RET" -eq 1 ]
then
    fatal "Could not find bridge device $bridge"
fi
case "$command" in
    online)
	setup_bridge_port "$vif"
	add_to_bridge "$bridge" "$vif"
	if [ ${bridge} = "eth1" ]; then
        	do_without_error ifconfig "$vif" mtu 9000
		(sleep 10; ifconfig "$vif" mtu 9000) &
		(sleep 30; ifconfig "$vif" mtu 9000) &
		(sleep 300; ifconfig "$vif" mtu 9000) &
	fi
        ;;
    offline)
        do_without_error brctl delif "$bridge" "$vif"
        do_without_error ifconfig "$vif" down
        ;;
esac
handle_iptable
log debug "Successful vif-bridge $command for $vif, bridge $bridge."
if [ "$command" == "online" ]
then
  success
fi

/etc/xen/xend-config.sxp changed:
(xend-relocation-server yes)
(network-script my-network-bridges)
(vif-script vif-bridge)
(dom0-min-mem 512)
(enable-dom0-ballooning yes)
(total_available_memory 0) 
(dom0-cpus 0)
(vncpasswd '')


-- no debconf information





More information about the Pkg-xen-devel mailing list