debuggers.hg

changeset 20003:534d3716bbbe

Revert part of c/s 19349: fixes qcow for HVM guests
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jul 21 12:06:52 2009 +0100 (2009-07-21)
parents 3341850938ac
children 261f4a127616
files tools/hotplug/Linux/Makefile tools/hotplug/Linux/blktap tools/hotplug/Linux/xen-backend.rules
line diff
     1.1 --- a/tools/hotplug/Linux/Makefile	Mon Jul 20 15:51:14 2009 +0100
     1.2 +++ b/tools/hotplug/Linux/Makefile	Tue Jul 21 12:06:52 2009 +0100
     1.3 @@ -12,6 +12,7 @@ XEN_SCRIPTS += network-route vif-route
     1.4  XEN_SCRIPTS += network-nat vif-nat
     1.5  XEN_SCRIPTS += block
     1.6  XEN_SCRIPTS += block-enbd block-nbd
     1.7 +XEN_SCRIPTS += blktap
     1.8  XEN_SCRIPTS += vtpm vtpm-delete
     1.9  XEN_SCRIPTS += xen-hotplug-cleanup
    1.10  XEN_SCRIPTS += external-device-migrate
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tools/hotplug/Linux/blktap	Tue Jul 21 12:06:52 2009 +0100
     2.3 @@ -0,0 +1,93 @@
     2.4 +#!/bin/bash
     2.5 +
     2.6 +# Copyright (c) 2005, XenSource Ltd.
     2.7 +
     2.8 +dir=$(dirname "$0")
     2.9 +. "$dir/xen-hotplug-common.sh"
    2.10 +. "$dir/block-common.sh"
    2.11 +
    2.12 +findCommand "$@"
    2.13 +
    2.14 +##
    2.15 +# check_blktap_sharing file mode
    2.16 +#
    2.17 +# Perform the sharing check for the given blktap and mode.
    2.18 +#
    2.19 +check_blktap_sharing()
    2.20 +{
    2.21 +    local file="$1"
    2.22 +    local mode="$2"
    2.23 +
    2.24 +    local base_path="$XENBUS_BASE_PATH/$XENBUS_TYPE"
    2.25 +    for dom in $(xenstore-list "$base_path")
    2.26 +    do
    2.27 +        for dev in $(xenstore-list "$base_path/$dom")
    2.28 +        do
    2.29 +            params=$(xenstore_read "$base_path/$dom/$dev/params" | cut -d: -f2)
    2.30 +            if [ "$file" = "$params" ]
    2.31 +            then
    2.32 +
    2.33 +                if [ "$mode" = 'w' ]
    2.34 +                then
    2.35 +                    if ! same_vm "$dom" 
    2.36 +                    then
    2.37 +                        echo 'guest'
    2.38 +                        return
    2.39 +                    fi
    2.40 +                else 
    2.41 +                    local m=$(xenstore_read "$base_path/$dom/$dev/mode")
    2.42 +                    m=$(canonicalise_mode "$m")
    2.43 +
    2.44 +                    if [ "$m" = 'w' ] 
    2.45 +                    then
    2.46 +                        if ! same_vm "$dom"
    2.47 +                        then
    2.48 +                            echo 'guest'
    2.49 +                            return
    2.50 +                        fi
    2.51 +                    fi
    2.52 +                fi
    2.53 +            fi
    2.54 +        done
    2.55 +    done
    2.56 +
    2.57 +    echo 'ok'
    2.58 +}
    2.59 +
    2.60 +
    2.61 +t=$(xenstore_read_default "$XENBUS_PATH/type" 'MISSING')
    2.62 +if [ -n "$t" ]
    2.63 +then
    2.64 +    p=$(xenstore_read "$XENBUS_PATH/params")
    2.65 +    # if we have a ':', chew from head including :
    2.66 +    if echo $p | grep -q \:
    2.67 +    then
    2.68 +        p=${p#*:}
    2.69 +    fi
    2.70 +fi
    2.71 +# some versions of readlink cannot be passed a regular file
    2.72 +if [ -L "$p" ]; then
    2.73 +    file=$(readlink -f "$p") || fatal "$p link does not exist."
    2.74 +else
    2.75 +    file="$p"
    2.76 +fi
    2.77 +
    2.78 +if [ "$command" = 'add' ]
    2.79 +then
    2.80 +    [ -e "$file" ] || { fatal $file does not exist; }
    2.81 +
    2.82 +    FRONTEND_ID=$(xenstore_read "$XENBUS_PATH/frontend-id")
    2.83 +    FRONTEND_UUID=$(xenstore_read "/local/domain/$FRONTEND_ID/vm")
    2.84 +    mode=$(xenstore_read "$XENBUS_PATH/mode")
    2.85 +    mode=$(canonicalise_mode "$mode")
    2.86 +
    2.87 +    if [ "$mode" != '!' ] 
    2.88 +    then
    2.89 +        result=$(check_blktap_sharing "$file" "$mode")
    2.90 +        [ "$result" = 'ok' ] || ebusy "$file already in use by other domain"
    2.91 +    fi
    2.92 +
    2.93 +    success
    2.94 +fi
    2.95 +
    2.96 +exit 0
     3.1 --- a/tools/hotplug/Linux/xen-backend.rules	Mon Jul 20 15:51:14 2009 +0100
     3.2 +++ b/tools/hotplug/Linux/xen-backend.rules	Tue Jul 21 12:06:52 2009 +0100
     3.3 @@ -1,3 +1,4 @@
     3.4 +SUBSYSTEM=="xen-backend", KERNEL=="tap*", RUN+="/etc/xen/scripts/blktap $env{ACTION}"
     3.5  SUBSYSTEM=="xen-backend", KERNEL=="vbd*", RUN+="/etc/xen/scripts/block $env{ACTION}"
     3.6  SUBSYSTEM=="xen-backend", KERNEL=="vtpm*", RUN+="/etc/xen/scripts/vtpm $env{ACTION}"
     3.7  SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="online", RUN+="$env{script} online"