27.12.2012 Views

The Virtualization Cookbook for SLES 10 SP2 - z/VM - IBM

The Virtualization Cookbook for SLES 10 SP2 - z/VM - IBM

The Virtualization Cookbook for SLES 10 SP2 - z/VM - IBM

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

cp_cmd LINK $source_id $source_mdisk $target_mdisk $link_mode $LINK_PASSWD<br />

if [ $? != 0 ]; then<br />

echo "cp_cmd link $source_id $source_mdisk $target_mdisk $link_mode failed -<br />

exiting"<br />

abort 1<br />

fi<br />

}<br />

#+--------------------------------------------------------------------------+<br />

function unlink_one<br />

# This will unlink a minidisk from the current z/<strong>VM</strong> user id.<br />

# Arg1: <strong>The</strong> target minidisk to unlink<br />

#+--------------------------------------------------------------------------+<br />

{<br />

cp_cmd DETACH $1<br />

return $?<br />

}<br />

#+--------------------------------------------------------------------------+<br />

function copy_one<br />

# Try to use z/<strong>VM</strong> FLASHCOPY to copy one disk to another. If that fails,<br />

# call dd_copy() to fall back to the Linux DD command<br />

# Arg 1: Source minidisk<br />

# Arg 2: Target minidisk<br />

#+--------------------------------------------------------------------------+<br />

{<br />

source_mdisk=$1<br />

target_mdisk=$2<br />

if [ "$CLONE_METHOD" == "AUTO" -o "$CLONE_METHOD" == "auto" ] ; then<br />

cp_cmd FLASHCOPY $source_mdisk 0 END $target_mdisk 0 END<br />

rc=$?<br />

if [ $rc -ne 0 ]; then # FLASHCOPY failed<br />

[ -n "$VERBOSE" ] && echo "FLASHCOPY $source_mdisk $target_mdisk failed with $rc -<br />

using Linux dd"<br />

else<br />

return 0<br />

fi<br />

fi<br />

dd_copy $source_mdisk $target_mdisk<br />

[ $? -ne 0 ] && return 1<br />

}<br />

#+--------------------------------------------------------------------------+<br />

function copy_disks<br />

# Call copy_one to copy each disk passed in as an argument.<br />

# Arg1-n: <strong>The</strong> minidisk address to copy<br />

#+--------------------------------------------------------------------------+<br />

{<br />

[ -n "$VERBOSE" ] && echo "Copying minidisks..."<br />

while [ $# -gt 0 ]; do<br />

link_one $source_linux_id $1 $MASTER_LINK RR<br />

link_one $target_linux_id $1 $CLONE_LINK W<br />

copy_one $MASTER_LINK $CLONE_LINK<br />

[ $? -eq 0 ] && echo "$1 disk copied ..."<br />

unlink_one $MASTER_LINK<br />

unlink_one $CLONE_LINK<br />

shift<br />

done<br />

256 <strong>The</strong> <strong>Virtualization</strong> <strong>Cookbook</strong> <strong>for</strong> RHEL 6

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!