mirror of
https://git.yoctoproject.org/meta-arm
synced 2026-06-05 02:20:30 +00:00
arm-autonomy/xenguest: Fix issues raised by shellcheck
Ignore issues in xenguest-manager and xenguest-mkimage as these will soon be rewritten. Issue-Id: SCM-1526 Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com> Change-Id: I733b4bfaaa5002f7a64c577e16548af62c425ebf Signed-off-by: Jon Mason <jon.mason@arm.com>
This commit is contained in:
@@ -22,7 +22,7 @@ case "$1" in
|
||||
*)
|
||||
# do not advertise unreasonable commands that there is no reason
|
||||
# to use with this device
|
||||
echo $"Usage: $0 {start|stop|status|restart|force-reload}"
|
||||
echo "Usage: $0 {start|stop|status|restart|force-reload}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ BRIDGE_NAME="###BRIDGE_NAME###"
|
||||
|
||||
case "${XENGUEST_NETWORK_TYPE:=}" in
|
||||
nat)
|
||||
echo "vif = ['script=vif-nat']" >> ${guestcfgfile}
|
||||
echo "vif = ['script=vif-nat']" >> "${guestcfgfile:?}"
|
||||
log info "Network type is NAT"
|
||||
;;
|
||||
bridge)
|
||||
echo "vif = ['script=vif-bridge,bridge=${BRIDGE_NAME}']" >> ${guestcfgfile}
|
||||
echo "vif = ['script=vif-bridge,bridge=${BRIDGE_NAME}']" >> "${guestcfgfile:?}"
|
||||
log info "Network type is bridge: ${BRIDGE_NAME}"
|
||||
;;
|
||||
*)
|
||||
|
||||
@@ -25,19 +25,19 @@ case "$1" in
|
||||
echo "Starting xenguest"
|
||||
|
||||
# Create unconfigured guests
|
||||
if [ -d ${XENGUEST_GUEST_DIR} ]; then
|
||||
for f in $(find ${XENGUEST_GUEST_DIR} -name "*.xenguest" \
|
||||
-exec basename {} .xenguest \;); do
|
||||
if [ ! -f ${XENGUEST_CONF_BASE}/guests/${f}/guest.cfg ]; then
|
||||
if [ -d "${XENGUEST_GUEST_DIR}" ]; then
|
||||
shopt -s nullglob
|
||||
for path in "${XENGUEST_GUEST_DIR}"/*.xenguest; do
|
||||
f=$(basename "${path}" .xenguest)
|
||||
if [ ! -f "${XENGUEST_CONF_BASE}/guests/${f}/guest.cfg" ]; then
|
||||
# Check if this guest should be auto booted
|
||||
autoboot=$(/usr/bin/xenguest-mkimage dump-paramsconfig \
|
||||
${XENGUEST_GUEST_DIR}/${f}.xenguest | \
|
||||
"${path}" | \
|
||||
grep GUEST_AUTOBOOT | sed -e "s,.*=,," | tr -d '"')
|
||||
if [ "$autoboot" = "0" ]; then
|
||||
echo "Do not create $f, autoboot disabled"
|
||||
else
|
||||
/usr/bin/xenguest-manager create \
|
||||
${XENGUEST_GUEST_DIR}/${f}.xenguest
|
||||
/usr/bin/xenguest-manager create "${path}"
|
||||
# Update guestlist
|
||||
if [ $? -eq 0 ]; then
|
||||
guestlist="${guestlist} ${f}"
|
||||
@@ -49,11 +49,11 @@ case "$1" in
|
||||
if [ -n "${guestlist}" ]; then
|
||||
for f in ${guestlist}; do
|
||||
GUEST_AUTOBOOT="1"
|
||||
if [ -f ${XENGUEST_CONF_BASE}/guests/${f}/params.cfg ]; then
|
||||
source ${XENGUEST_CONF_BASE}/guests/${f}/params.cfg
|
||||
if [ -f "${XENGUEST_CONF_BASE}/guests/${f}/params.cfg" ]; then
|
||||
source "${XENGUEST_CONF_BASE}/guests/${f}/params.cfg"
|
||||
fi
|
||||
if [ "${GUEST_AUTOBOOT}" = "1" ]; then
|
||||
/usr/bin/xenguest-manager start ${f}
|
||||
/usr/bin/xenguest-manager start "${f}"
|
||||
fi
|
||||
done
|
||||
else
|
||||
@@ -68,7 +68,7 @@ case "$1" in
|
||||
# update guest list
|
||||
guestlist=$(xenguest-manager status | grep Running | cut -d ":" -f1)
|
||||
for f in ${guestlist}; do
|
||||
xenguest-manager shutdown ${f} --kill
|
||||
xenguest-manager shutdown "${f}" --kill
|
||||
done
|
||||
;;
|
||||
reload)
|
||||
|
||||
@@ -36,7 +36,7 @@ case "$1" in
|
||||
*)
|
||||
# do not advertise unreasonable commands that there is no reason
|
||||
# to use with this device
|
||||
echo $"Usage: $0 {start|stop|status|restart|force-reload}"
|
||||
echo "Usage: $0 {start|stop|status|restart|force-reload}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
|
||||
@@ -11,19 +11,20 @@ set +u
|
||||
#
|
||||
|
||||
check_if_vif_is_ready() {
|
||||
ret=($(xl network-list "${guestname}" | grep "${1}"))
|
||||
# ${ret[4]} is network interface status value
|
||||
ret=$(xl network-list "${guestname:?}" | grep "${1}" \
|
||||
| tr -s ' ' | cut -d' ' -f5)
|
||||
# ${ret} is network interface status value
|
||||
# 1 means vif is not ready
|
||||
# 4 means vif is ready
|
||||
[ "${ret[4]}" = "4" ] && return 0
|
||||
[ "${ret}" = "4" ] && return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
case "${XENGUEST_NETWORK_TYPE:-}" in
|
||||
nat)
|
||||
vif_name="$(xl network-list ${guestname} | grep -o vif.*)"
|
||||
vif_name="$(xl network-list "${guestname:?}" | grep -o "vif.*")"
|
||||
|
||||
for try in {1..20}
|
||||
for try in $(seq 20)
|
||||
do
|
||||
if check_if_vif_is_ready "${vif_name}"; then
|
||||
claim_lock "vif-nat-kea"
|
||||
|
||||
Reference in New Issue
Block a user