Port-xen archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Improved block-file script



I've attached an improved block-file script that is used by xend to
create the virtual disks for file-backed guest domains.  This script
is a little friendlier to your xend log when starting large numbers
of domains, since we don't need to fail binding the first (N-1) vnode
devices before successfully binding the Nth one.

I'm also still testing various network configurations using Xen and
will post improved network-* and vif-* scripts here when I'm finished.

        Cheers,

        -- Johnny Lam <jlam%pkgsrc.org@localhost>
#!/bin/sh
#
# $NetBSD$
#
# Usage: block-file bind file
#
#    The file argument is the path to the file to which a vnd(4) device
#    will be bound.
#
# Usage: block-file unbind node
#
#    The node argument is the name of the device node to unbind.
#

case "$1" in
bind)
        FILE="$2"

        # Store the list of available vnd(4) devices in ``available_disks'',
        # and mark them as ``free''.
        #
        for dev in /dev/vnd[0-9]*d; do
                disk="${dev#/dev/}"
                disk="${disk%d}"
                available_disks="$available_disks $disk"
                eval $disk=free
        done

        # Mark the used vnd(4) devices as ``used''.
        for disk in `sysctl hw.disknames`; do
                case $disk in
                vnd[0-9]*) eval $disk=used ;;
                esac
        done

        # Configure the first free vnd(4) device.
        for disk in $available_disks; do
                eval status=\$$disk
                if [ "$status" = "free" ] && \
                   vnconfig /dev/${disk}d $FILE >/dev/null; then
                        echo /dev/${disk}d
                        exit 0
                fi
        done
        exit 1
        ;;

unbind)
        NODE="$2"
        vnconfig -u $NODE
        exit 0
        ;;

*)
        echo "Unknown command: $1"
        echo "Valid commands are: bind, unbind"
        exit 1
        ;;
esac


Home | Main Index | Thread Index | Old Index