From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ryan Grimm Subject: [PATCH 6 of 6] dm-userspace backend script and xmexample change Date: Fri, 25 Aug 2006 16:24:14 -0500 Message-ID: <20060825212414.GG31071@localhost.localdomain> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Xen Devel Cc: Dan Smith List-Id: xen-devel@lists.xenproject.org Signed-off-by: Ryan Grimm Signed-off-by: Dan Smith # HG changeset patch # User Ryan Grimm # Date 1156536098 18000 # Node ID 55e3795e5bc46ea6a205e60ebf27ed9faf306616 # Parent be4574d288030b64d4623dd33505d0990185a6b9 dm-userspace backend script and xmexample change diff -r be4574d28803 -r 55e3795e5bc4 tools/examples/Makefile --- a/tools/examples/Makefile Fri Aug 25 15:01:36 2006 -0500 +++ b/tools/examples/Makefile Fri Aug 25 15:01:38 2006 -0500 @@ -32,6 +32,7 @@ XEN_SCRIPTS += vtpm vtpm-delete XEN_SCRIPTS += vtpm vtpm-delete XEN_SCRIPTS += xen-hotplug-cleanup XEN_SCRIPTS += external-device-migrate +XEN_SCRIPTS += block-dmu XEN_SCRIPT_DATA = xen-script-common.sh locking.sh logging.sh XEN_SCRIPT_DATA += xen-hotplug-common.sh xen-network-common.sh vif-common.sh XEN_SCRIPT_DATA += block-common.sh vtpm-common.sh vtpm-hotplug-common.sh diff -r be4574d28803 -r 55e3795e5bc4 tools/examples/README --- a/tools/examples/README Fri Aug 25 15:01:36 2006 -0500 +++ b/tools/examples/README Fri Aug 25 15:01:38 2006 -0500 @@ -13,6 +13,7 @@ block-common.sh - sourced by block, block-common.sh - sourced by block, block-* block-enbd - binds/unbinds network block devices block-nbd - binds/unbinds network block devices +block-dmu - binds/unbinds dm-userspace devices external-device-migrate - called by xend for migrating external devices locking.sh - locking functions to prevent concurrent access to critical sections inside script files diff -r be4574d28803 -r 55e3795e5bc4 tools/examples/xmexample1 --- a/tools/examples/xmexample1 Fri Aug 25 15:01:36 2006 -0500 +++ b/tools/examples/xmexample1 Fri Aug 25 15:01:38 2006 -0500 @@ -64,6 +64,13 @@ vif = [ '' ] # and MODE is r for read-only, w for read-write. disk = [ 'phy:hda1,hda1,w' ] + +#---------------------------------------------------------------------------- +# Using a dm-userspace backed device +# for dmu, the syntax is dmu::: +# if does not exist, it is created and is used +# as a base. if does exist, is ignored. +# disk = [ 'dmu:dscow:/path/to/domain.dscow:/path/to/domain.img,hda1,w'] #---------------------------------------------------------------------------- # Define to which TPM instance the user domain should communicate. diff -r be4574d28803 -r 55e3795e5bc4 tools/examples/block-dmu --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/examples/block-dmu Fri Aug 25 15:01:38 2006 -0500 @@ -0,0 +1,57 @@ +#!/bin/sh +# +# Copyright (C) International Business Machines Corp., 2006 +# Author: Ryan Grimm + +dir=$(dirname "$0") +. "$dir/block-common.sh" + +p=$(xenstore_read "$XENBUS_PATH/params") +mode=$(xenstore_read "$XENBUS_PATH/mode") + +wait_for_cowd_exit() { + while ps ax | grep -v grep | grep cowd | grep -q $1; do + sleep 1 + done +} + +case "$command" in + add) + plugin=$(echo $p | cut -d: -f1) + dmu_file=$(echo $p | cut -d: -f2) + base_file=$(echo $p | cut -d: -f3) + + domain_name=$(xenstore_read "$XENBUS_PATH/domain") + domain_dev=$(xenstore_read "$XENBUS_PATH/dev") + target="$domain_name""_""$domain_dev" + md_dev="/dev/mapper/$target" + + lsmod | grep -q dm_user || modprobe dm-user || fatal \ + 'cannot load module dm-user' + + wait_for_cowd_exit $target + + if [ ! -e $dmu_file ] + then + dscow_tool -c $dmu_file $base_file || fatal \ + 'creation of $dmu_file failed' + fi + + cowd --sync --pidfile=/var/run/cowd.$target.pid -p $plugin \ + $target $dmu_file || fatal 'cowd failed' + + xenstore_write "$XENBUS_PATH/node" "$target" + + claim_lock "block" + write_dev $md_dev + release_lock "block" + exit 0 + ;; + + remove) + node=$(xenstore_read "$XENBUS_PATH/node") + cowd_pid=$(cat "/var/run/cowd.$node.pid") + kill $cowd_pid + exit 0 + ;; +esac