1
0
mirror of https://git.yoctoproject.org/meta-arm synced 2026-01-11 15:00:39 +00:00

arm-autonomy/xenguest-manager: Allow guests named 'guest'

Prevented name collision on file guest.cfg when the name of the
guest is exactly 'guest'. Config is now piped into a tmp file
which can safely be deleted at the end of the start operation.

Change-Id: Id08ac08e52e9e64c508c841b257ecb28ed9d44ae
Issue-Id: SCM-1518
Signed-off-by: Nathan Dunne <Nathan.Dunne@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
This commit is contained in:
Nathan Dunne
2020-10-26 11:12:23 +00:00
committed by Jon Mason
parent 128af6b2d0
commit ceb5902e56
3 changed files with 18 additions and 14 deletions

View File

@@ -83,11 +83,13 @@ Inside the directory, scripts will be executed in alphabetical order.
Since these scripts are sourced by xenguest-manager they can acccess functions
and variables from the parent file's scope, including:
- ${guestname} : The name of the guest being created
- ${guestname} : The name of the guest being created
- ${guestdir} : The path to the guest directory
- ${guestdir} : The path to the guest directory
- ${LOGFILE} : The file to append any logging to, e.g.
- ${guestcfgfile} : The name of the config file for the starting guest
- ${LOGFILE} : The file to append any logging to, e.g.
echo "Hello, World" >> ${LOGFILE}
Sourcing also allows the script to access params.cfg.

View File

@@ -20,10 +20,10 @@ case "${XENGUEST_NETWORK_TYPE:-}" in
if [ ! -f /etc/default/dhcp3-server ]; then
ln -s dhcp-server /etc/default/dhcp3-server
fi
echo "vif = ['script=vif-nat']" >> ${guestname}.cfg
echo "vif = ['script=vif-nat']" >> ${guestcfgfile}
;;
bridge)
echo "vif = ['script=vif-bridge,bridge=${BRIDGE_NAME}']" >> ${guestname}.cfg
echo "vif = ['script=vif-bridge,bridge=${BRIDGE_NAME}']" >> ${guestcfgfile}
;;
*)
echo "${@}: XENGUEST_NETWORK_TYPE=$XENGUEST_NETWORK_TYPE invalid"

View File

@@ -465,13 +465,15 @@ function xenguest_guest_start()
guestname="${1}"
guestdir=${XENGUEST_CONF_BASE}/guests/${guestname}
guestcfgfile=$(mktemp -u "${guestname}.XXXXXX" --tmpdir="${guestdir}" --suffix=".cfg")
# Get guest configuration
source ${guestdir}/params.cfg
pushd ${guestdir} > /dev/null 2>&1
# create config by merging all configurations together
cat guest.cfg $(find guest.d -type f 2> /dev/null) > ${guestname}.cfg
cat guest.cfg $(find guest.d -type f 2> /dev/null) > ${guestcfgfile}
# Build init script lists (ignore non existing dirs errors,
# sort alphabetically and run global scripts first)
@@ -491,7 +493,7 @@ function xenguest_guest_start()
echo "( . $f )" >> ${LOGFILE} 2>&1
( . $f ) >> ${LOGFILE} 2>&1
if [ $? -ne 0 ]; then
rm -f ${guestname}.cfg
rm -f ${guestcfgfile}
popd > /dev/null 2>&1
echo "Error in init script $f" >> ${LOGFILE} 2>&1
echo "${PREF} Error during pre init script of ${guestname}"
@@ -503,10 +505,10 @@ function xenguest_guest_start()
done
# Create non started guest
echo "xl create -p ${guestname}.cfg" >> ${LOGFILE} 2>&1
xl create -p ${guestname}.cfg >> ${LOGFILE} 2>&1
echo "xl create -p ${guestcfgfile}" >> ${LOGFILE} 2>&1
xl create -p ${guestcfgfile} >> ${LOGFILE} 2>&1
if [ $? -ne 0 ]; then
rm -f ${guestname}.cfg
rm -f ${guestcfgfile}
popd > /dev/null 2>&1
echo "${PREF} Error starting ${guestname}"
exit 1
@@ -518,7 +520,7 @@ function xenguest_guest_start()
echo "( . $f )" >> ${LOGFILE} 2>&1
( . $f ) >> ${LOGFILE} 2>&1
if [ $? -ne 0 ]; then
rm -f ${guestname}.cfg
rm -f ${guestcfgfile}
echo "xl destroy ${guestname}" >> ${LOGFILE} 2>&1
xl destroy ${guestname} >> ${LOGFILE} 2>&1
popd > /dev/null 2>&1
@@ -535,7 +537,7 @@ function xenguest_guest_start()
echo "xl unpause ${guestname}" >> ${LOGFILE} 2>&1
xl unpause ${guestname} >> ${LOGFILE} 2>&1
if [ $? -ne 0 ]; then
rm -f ${guestname}.cfg
rm -f ${guestcfgfile}
popd > /dev/null 2>&1
echo "${PREF} Error starting ${guestname}"
exit 1
@@ -547,7 +549,7 @@ function xenguest_guest_start()
echo "( . $f )" >> ${LOGFILE} 2>&1
( . $f ) >> ${LOGFILE} 2>&1
if [ $? -ne 0 ]; then
rm -f ${guestname}.cfg
rm -f ${guestcfgfile}
echo "xl destroy ${guestname}" >> ${LOGFILE} 2>&1
xl destroy ${guestname} >> ${LOGFILE} 2>&1
popd > /dev/null 2>&1
@@ -560,7 +562,7 @@ function xenguest_guest_start()
fi
done
rm -f ${guestname}.cfg
rm -f ${guestcfgfile}
popd > /dev/null 2>&1
}