- bsc#954872 - script block-dmmd not working as expected - libxl:
error: libxl_dm.c (Additional fixes) block-dmmd OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=441
This commit is contained in:
parent
fe96474232
commit
82ff4f51e5
271
block-dmmd
271
block-dmmd
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Usage: block-dmmd [add args | remove args]
|
# Usage: block-dmmd [add args | remove args]
|
||||||
#
|
#
|
||||||
# the dmmd device syntax (in xm commands/configs) is something like:
|
# the dmmd device syntax (in xm/xl commands/configs) is something like:
|
||||||
# dmmd:md;/dev/md0;md;/dev/md1;lvm;/dev/vg1/lv1
|
# dmmd:md;/dev/md0;md;/dev/md1;lvm;/dev/vg1/lv1
|
||||||
# or
|
# or
|
||||||
# dmmd:lvm;/dev/vg1/lv1;lvm;/dev/vg1/lv2;md;/dev/md0
|
# dmmd:lvm;/dev/vg1/lv1;lvm;/dev/vg1/lv2;md;/dev/md0
|
||||||
@ -16,6 +16,15 @@
|
|||||||
# dmmd:md;My-MD-name;lvm;/dev/vg1/lv1
|
# dmmd:md;My-MD-name;lvm;/dev/vg1/lv1
|
||||||
#
|
#
|
||||||
# History:
|
# History:
|
||||||
|
# 2016-05-27, mlatimer@suse.com:
|
||||||
|
# Merge improvements by loic.devulder@mpsa.com. Highlights include:
|
||||||
|
# - Re-write and simplification to speed up the script!
|
||||||
|
# - Add some (useful) logging messages and comments
|
||||||
|
# Minor tweaks and logging improvements
|
||||||
|
# 2016-05-26, mlatimer@suse.com:
|
||||||
|
# Verify MD activation if mdadm returns 2
|
||||||
|
# 2016-05-20, mlatimer@suse.com:
|
||||||
|
# Strip leading "dmmd:" if present in xenstore params value
|
||||||
# 2013-07-03, loic.devulder@mpsa.com:
|
# 2013-07-03, loic.devulder@mpsa.com:
|
||||||
# Partial rewrite of the script for supporting MD activation by name
|
# Partial rewrite of the script for supporting MD activation by name
|
||||||
# 2009-06-09, mh@novell.com:
|
# 2009-06-09, mh@novell.com:
|
||||||
@ -24,22 +33,32 @@
|
|||||||
# Make variables used in functions local to avoid global overridings
|
# Make variables used in functions local to avoid global overridings
|
||||||
# Use vgscan and vgchange where required
|
# Use vgscan and vgchange where required
|
||||||
# Use the C locale to avoid dealing with localized messages
|
# Use the C locale to avoid dealing with localized messages
|
||||||
# Assign output from assembling an MD device to a variable to aid debugging
|
# Assign output from assembling an MD device to a variable to aid
|
||||||
|
# debugging
|
||||||
|
|
||||||
# We do not want to deal with localized messages:
|
# We do not want to deal with localized messages
|
||||||
LANG=C
|
# We use LC_ALL because LC_ALL superse LANG
|
||||||
LC_MESSAGES=C
|
# But we also use LANG because some applications may still use LANG...
|
||||||
export LANG LC_MESSAGES
|
export LC_ALL=C
|
||||||
|
export LANG=${LC_ALL}
|
||||||
|
|
||||||
dir=$(dirname "$0")
|
# Loading common libraries
|
||||||
. "$dir/block-common.sh"
|
. $(dirname $0)/block-common.sh
|
||||||
|
|
||||||
#exec >> /tmp/block-dmmd-`date +%F_%T.%N`.log 2>&1
|
# Constants
|
||||||
#echo shell-flags: $-
|
typeset -rx MDADM_BIN=/sbin/mdadm
|
||||||
|
typeset -rx LVCHANGE_BIN=/sbin/lvchange
|
||||||
|
typeset -rx PVSCAN_BIN=/sbin/pvscan
|
||||||
|
typeset -rx VGSCAN_BIN=/sbin/vgscan
|
||||||
|
typeset -rx VGCHANGE_BIN=/sbin/vgchange
|
||||||
|
typeset -rx DATE_LOG="date +%F_%T.%N"
|
||||||
|
typeset -rx DATE_SEC="date +%s"
|
||||||
|
|
||||||
command=$1
|
# Uncomment for debugging purposes
|
||||||
|
# exec >> /tmp/block-dmmd-$(${DATE_LOG}).log 2>&1
|
||||||
|
# echo shell-flags: $-
|
||||||
|
|
||||||
# We check for errors ourselves:
|
# We check for errors ourselves
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
function run_mdadm()
|
function run_mdadm()
|
||||||
@ -48,21 +67,24 @@ function run_mdadm()
|
|||||||
local msg
|
local msg
|
||||||
local rc
|
local rc
|
||||||
|
|
||||||
msg="$(/sbin/mdadm $mdadm_cmd 2>&1)"
|
msg="$(${MDADM_BIN} ${mdadm_cmd} 2>&1)"
|
||||||
rc=$?
|
rc=$?
|
||||||
case "$msg" in
|
case "${msg}" in
|
||||||
*"has been started"* | *"already active"* )
|
*"has been started"* | *"already active"*)
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
*"is already in use"* )
|
*"is already in use"*)
|
||||||
# hmm, might be used by another device in this domU
|
# Hmm, might be used by another device in this domU
|
||||||
# leave it to upper layers to detect a real error
|
# Leave it to upper layers to detect a real error
|
||||||
return 2
|
return 2
|
||||||
;;
|
;;
|
||||||
* )
|
*)
|
||||||
return $rc
|
return ${rc}
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Normally we should not get here, but if this happens
|
||||||
|
# we have to return an error
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,10 +94,10 @@ function activate_md()
|
|||||||
local par=$1
|
local par=$1
|
||||||
local cfg dev dev_path rc t mdadm_opts
|
local cfg dev dev_path rc t mdadm_opts
|
||||||
|
|
||||||
if [ ${par} = ${par%%(*} ]; then
|
if [[ ${par} == ${par%%(*} ]]; then
|
||||||
# No configuration file specified
|
# No configuration file specified
|
||||||
dev=$par
|
dev=${par}
|
||||||
cfg=
|
cfg=""
|
||||||
else
|
else
|
||||||
dev=${par%%(*}
|
dev=${par%%(*}
|
||||||
t=${par#*(}
|
t=${par#*(}
|
||||||
@ -83,25 +105,38 @@ function activate_md()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Looking for device name or aliase
|
# Looking for device name or aliase
|
||||||
if [ ${dev:0:1} = / ]; then
|
if [[ ${dev:0:1} == / ]]; then
|
||||||
dev_path=${dev%/*}
|
dev_path=${dev%/*}
|
||||||
mdadm_opts=
|
mdadm_opts=""
|
||||||
else
|
else
|
||||||
dev_path=/dev/md
|
dev_path=/dev/md
|
||||||
mdadm_opts="-s -N"
|
mdadm_opts="-s -N"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Is md device already active?
|
# Logging message
|
||||||
|
echo "[$(${DATE_LOG})] activate MD device ${dev}..." >&2
|
||||||
|
|
||||||
|
# Is MD device already active?
|
||||||
# We need to use full path name, aliase is not possible...
|
# We need to use full path name, aliase is not possible...
|
||||||
if [ -e $dev_path/${dev##*/} ]; then
|
if [ -e $dev_path/${dev##*/} ]; then
|
||||||
/sbin/mdadm -Q -D $dev_path/${dev##*/} 2>/dev/null | grep -iq state.*\:.*inactive || return 0
|
${MDADM_BIN} -Q -D $dev_path/${dev##*/} 2>/dev/null \
|
||||||
|
| grep -iq state.*\:.*inactive || return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
run_mdadm "-A $mdadm_opts $dev $cfg"
|
# Activate MD device
|
||||||
|
run_mdadm "-A ${mdadm_opts} ${dev} ${cfg}"
|
||||||
rc=$?
|
rc=$?
|
||||||
[ $rc -eq 2 ] && return 0
|
# A return code of 2 can indicate the array configuration was incorrect
|
||||||
|
if [[ ${rc} == 2 ]]; then
|
||||||
|
# Logging message
|
||||||
|
echo "[$(${DATE_LOG})] verifying MD device ${dev} activation..." >&2
|
||||||
|
|
||||||
return $rc
|
# If the array is active, return 0, otherwise return an error
|
||||||
|
${MDADM_BIN} -Q -D $dev_path/${dev##*/} &>/dev/null && return 0 \
|
||||||
|
|| return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
return ${rc}
|
||||||
}
|
}
|
||||||
|
|
||||||
function deactivate_md()
|
function deactivate_md()
|
||||||
@ -109,7 +144,7 @@ function deactivate_md()
|
|||||||
local par=$1
|
local par=$1
|
||||||
local dev
|
local dev
|
||||||
|
|
||||||
if [ ${par} = ${par%%(*} ]; then
|
if [[ ${par} == ${par%%(*} ]]; then
|
||||||
# No configuration file specified
|
# No configuration file specified
|
||||||
dev=${par}
|
dev=${par}
|
||||||
else
|
else
|
||||||
@ -117,14 +152,17 @@ function deactivate_md()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Looking for device name or aliase
|
# Looking for device name or aliase
|
||||||
if [ ${dev:0:1} = / ]; then
|
if [[ ${dev:0:1} == / ]]; then
|
||||||
dev_path=${dev%/*}
|
dev_path=${dev%/*}
|
||||||
else
|
else
|
||||||
dev_path=/dev/md
|
dev_path=/dev/md
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Logging message
|
||||||
|
echo "[$(${DATE_LOG})] deactivate MD device ${dev}..." >&2
|
||||||
|
|
||||||
# We need the device name only while deactivating
|
# We need the device name only while deactivating
|
||||||
/sbin/mdadm -S ${dev_path}/${dev##*/} > /dev/null 2>&1
|
${MDADM_BIN} -S ${dev_path}/${dev##*/} > /dev/null 2>&1
|
||||||
|
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
@ -132,169 +170,200 @@ function deactivate_md()
|
|||||||
function activate_lvm()
|
function activate_lvm()
|
||||||
{
|
{
|
||||||
local run_timeout=90
|
local run_timeout=90
|
||||||
|
local parsed_timeout
|
||||||
local end_time
|
local end_time
|
||||||
|
|
||||||
# First scan for PVs and VGs
|
# If /etc/xen/xend-config.sxp exists (e.g. SLES11), use
|
||||||
# We need this for using md device as PV
|
# device-create-timeout, instead of the default setting
|
||||||
/sbin/pvscan > /dev/null 2>&1
|
if [[ -f /etc/xen/xend-config.sxp ]]; then
|
||||||
# /sbin/vgscan --mknodes > /dev/null 2>&1
|
parsed_timeout=$(grep -v "^[ \t]*#.*" /etc/xen/xend-config.sxp \
|
||||||
|
|sed -n 's/(device-create-timeout \+\([0-9]\+\))/\1/p')
|
||||||
|
if [[ ! -z $parsed_timeout ]]; then
|
||||||
|
run_timeout=$((${parsed_timeout}*9/10))
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# First scan for PVs and VGs
|
||||||
|
# We need this for using MD device as PV
|
||||||
|
${PVSCAN_BIN} > /dev/null 2>&1
|
||||||
|
# ${VGSCAN_BIN} --mknodes > /dev/null 2>&1
|
||||||
|
|
||||||
|
# Logging message
|
||||||
|
echo "[$(${DATE_LOG})] activate LVM device ${dev}..." >&2
|
||||||
|
|
||||||
|
# Set end_time for the loop
|
||||||
|
(( end_time = $(${DATE_SEC}) + run_timeout ))
|
||||||
|
|
||||||
end_time=$(($(date +%s)+${run_timeout}))
|
|
||||||
while true; do
|
while true; do
|
||||||
/sbin/lvchange -aey $1 > /dev/null 2>&1
|
${LVCHANGE_BIN} -aey $1 > /dev/null 2>&1
|
||||||
|
|
||||||
if [ $? -eq 0 -a -e $1 ]; then
|
if [ $? -eq 0 -a -e $1 ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
if [ $(date +%s) -ge ${end_time} ]; then
|
# If it takes too long we need to return an error
|
||||||
|
if (( $(${DATE_SEC}) >= end_time )); then
|
||||||
log err "Failed to activate $1 within ${run_timeout} seconds"
|
log err "Failed to activate $1 within ${run_timeout} seconds"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Normally we should not get here, but if this happens
|
||||||
|
# we have to return an error
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function deactivate_lvm()
|
function deactivate_lvm()
|
||||||
{
|
{
|
||||||
/sbin/lvchange -aen $1 > /dev/null 2>&1
|
# Logging message
|
||||||
|
echo "[$(${DATE_LOG})] deactivate LVM device ${dev}..." >&2
|
||||||
|
|
||||||
|
${LVCHANGE_BIN} -aen $1 > /dev/null 2>&1
|
||||||
|
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
# We may have to deactivate the VG now, but can ignore errors:
|
# We may have to deactivate the VG now, but can ignore errors:
|
||||||
# /sbin/vgchange -an ${1%/*} || :
|
# ${VGCHANGE_BIN} -an ${1%/*} || :
|
||||||
# Maybe we need to cleanup the LVM cache:
|
# Maybe we need to cleanup the LVM cache:
|
||||||
# /sbin/vgscan --mknodes || :
|
# ${VGSCAN_BIN} --mknodes || :
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
BP=100
|
# Variables
|
||||||
SP=$BP
|
typeset command=$1
|
||||||
VBD=
|
typeset BP=100
|
||||||
|
typeset SP=${BP}
|
||||||
|
typeset VBD
|
||||||
|
typeset -a stack
|
||||||
|
|
||||||
declare -a stack
|
|
||||||
function push()
|
function push()
|
||||||
{
|
{
|
||||||
if [ -z "$1" ]; then
|
local value="$1"
|
||||||
return
|
|
||||||
fi
|
[[ -n "${value}" ]] \
|
||||||
let "SP -= 1"
|
&& stack[$((--SP))]="${value}"
|
||||||
stack[$SP]="${1}"
|
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function pop()
|
function pop()
|
||||||
{
|
{
|
||||||
VBD=
|
[[ "${SP}" != "${BP}" ]] \
|
||||||
|
&& VBD=${stack[$((SP++))]} \
|
||||||
|
|| VBD=""
|
||||||
|
|
||||||
if [ "$SP" -eq "$BP" ]; then
|
return 0
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
VBD=${stack[$SP]}
|
|
||||||
let "SP += 1"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function activate_dmmd()
|
function activate_dmmd()
|
||||||
{
|
{
|
||||||
case $1 in
|
case "$1" in
|
||||||
md)
|
"md")
|
||||||
activate_md $2
|
activate_md $2
|
||||||
return
|
return $?
|
||||||
;;
|
;;
|
||||||
lvm)
|
"lvm")
|
||||||
activate_lvm $2
|
activate_lvm $2
|
||||||
return
|
return $?
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Normally we should not get here, but if this happens
|
||||||
|
# we have to return an error
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function deactivate_dmmd()
|
function deactivate_dmmd()
|
||||||
{
|
{
|
||||||
case "$1" in
|
case "$1" in
|
||||||
md)
|
"md")
|
||||||
deactivate_md $2
|
deactivate_md $2
|
||||||
return
|
return $?
|
||||||
;;
|
;;
|
||||||
lvm)
|
"lvm")
|
||||||
deactivate_lvm $2
|
deactivate_lvm $2
|
||||||
return
|
return $?
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Normally we should not get here, but if this happens
|
||||||
|
# we have to return an error
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup_stack()
|
function cleanup_stack()
|
||||||
{
|
{
|
||||||
while [ 1 ]; do
|
while true; do
|
||||||
pop
|
pop
|
||||||
if [ -z "$VBD" ]; then
|
[[ -z "${VBD}" ]] && break
|
||||||
break
|
deactivate_dmmd ${VBD}
|
||||||
fi
|
|
||||||
deactivate_dmmd $VBD
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function parse_par()
|
function parse_par()
|
||||||
{
|
{
|
||||||
local ac par rc s t # Make these explicitly local vars
|
# Make these vars explicitly local
|
||||||
|
local ac par rc s t
|
||||||
|
|
||||||
ac=$1
|
ac=$1
|
||||||
par="$2"
|
par="$2"
|
||||||
|
|
||||||
par="$par;"
|
par="${par};"
|
||||||
while [ 1 ]; do
|
while true; do
|
||||||
t=${par%%;*}
|
t=${par%%;*}
|
||||||
if [ -z "$t" ]; then
|
|
||||||
return 0
|
[[ -z "${t}" ]] && return 0
|
||||||
fi
|
|
||||||
par=${par#*;}
|
par=${par#*;}
|
||||||
|
|
||||||
s=${par%%;*}
|
s=${par%%;*}
|
||||||
if [ -z "$s" ]; then
|
[[ -z "${s}" ]] && return 1
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
par=${par#*;}
|
par=${par#*;}
|
||||||
|
|
||||||
if [ "$ac" = "activate" ]; then
|
if [[ "${ac}" == "activate" ]]; then
|
||||||
activate_dmmd $t $s
|
activate_dmmd ${t} ${s} \
|
||||||
rc=$?
|
|| return 1
|
||||||
if [ $rc -ne 0 ]; then
|
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
fi
|
push "${t} ${s}"
|
||||||
push "$t $s"
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "${command}" in
|
||||||
case "$command" in
|
"add")
|
||||||
add)
|
p=$(xenstore-read ${XENBUS_PATH}/params) || true
|
||||||
p=`xenstore-read $XENBUS_PATH/params` || true
|
|
||||||
claim_lock "dmmd"
|
claim_lock "dmmd"
|
||||||
dmmd=${p#dmmd:}
|
dmmd=${p#dmmd:}
|
||||||
parse_par activate "$dmmd"
|
|
||||||
rc=$?
|
if ! parse_par activate "${dmmd}"; then
|
||||||
if [ $rc -ne 0 ]; then
|
|
||||||
cleanup_stack
|
cleanup_stack
|
||||||
release_lock "dmmd"
|
release_lock "dmmd"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
lastparam=${dmmd##*;}
|
lastparam=${dmmd##*;}
|
||||||
usedevice=${lastparam%(*}
|
usedevice=${lastparam%(*}
|
||||||
xenstore-write $XENBUS_PATH/node "$usedevice"
|
xenstore-write ${XENBUS_PATH}/node "${usedevice}"
|
||||||
write_dev "$usedevice"
|
write_dev "${usedevice}"
|
||||||
release_lock "dmmd"
|
release_lock "dmmd"
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
remove)
|
"remove")
|
||||||
p=`xenstore-read $XENBUS_PATH/params` || true
|
p=$(xenstore-read ${XENBUS_PATH}/params) || true
|
||||||
claim_lock "dmmd"
|
claim_lock "dmmd"
|
||||||
dmmd=${p#dmmd:}
|
dmmd=${p#dmmd:}
|
||||||
parse_par noactivate "$dmmd"
|
|
||||||
|
parse_par noactivate "${dmmd}"
|
||||||
|
|
||||||
cleanup_stack
|
cleanup_stack
|
||||||
release_lock "dmmd"
|
release_lock "dmmd"
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Normally we should not get here, but if this happens
|
||||||
|
# we have to return an error
|
||||||
|
return 1
|
||||||
|
@ -5,6 +5,13 @@ Tue Jun 21 08:26:51 MDT 2016 - carnold@suse.com
|
|||||||
xen-4.7.0-testing-src.tar.bz2
|
xen-4.7.0-testing-src.tar.bz2
|
||||||
- Drop CVE-2014-3672-qemut-xsa180.patch
|
- Drop CVE-2014-3672-qemut-xsa180.patch
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Jun 16 16:27:25 MDT 2016 - carnold@suse.com
|
||||||
|
|
||||||
|
- bsc#954872 - script block-dmmd not working as expected - libxl:
|
||||||
|
error: libxl_dm.c (Additional fixes)
|
||||||
|
block-dmmd
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Fri Jun 10 14:23:51 UTC 2016 - ohering@suse.de
|
Fri Jun 10 14:23:51 UTC 2016 - ohering@suse.de
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user