aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAyan Kumar Halder2021-12-21 13:04:47 +0000
committerStefano Stabellini2021-12-21 09:43:01 -0800
commitb098f3d5d627ad40c000fa100f8a72d011dba15e (patch)
tree07536202d04d8c4b1eeeeb7356a8cbcadccf9b55 /scripts
parent1ff56037d6dc9e94c4ba512dd0af41e6843645af (diff)
Generate the domU partial dtb via disk_image
Similar to uboot-script-gen, disk_image invokes compile_merge_partial_dts to generate the domU partial dtbs. It copies the dtbs to /etc/xen. Added functions to cleanup the temporary files. Also removed 'set -e'. This was causing the script to terminate if any of the functions returned non zero. In our approach, the functions in common script will return 1 (on failure), and the caller (ie disk_image) will check the return code and do the appropriate cleanup. Moreover, 'set -e' cannot be relied upon to terminate the script if any function returns error. Thus, it is not very useful. Details :- https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html Signed-off-by: Ayan Kumar Halder <ayankuma@xilinx.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/disk_image57
1 files changed, 45 insertions, 12 deletions
diff --git a/scripts/disk_image b/scripts/disk_image
index 81bbee4..69b037f 100755
--- a/scripts/disk_image
+++ b/scripts/disk_image
@@ -1,11 +1,28 @@
#!/bin/bash
-# This helps to see what is going on
-set -e
-
PROG_REQ=( kpartx mkfs.ext4 losetup sgdisk readlink awk )
SLACK=128
+function cleanup_disk_image()
+{
+ kpartx -d /dev/mapper/diskimage
+ dmsetup remove diskimage
+ losetup -d $_loop_dev
+
+ remove_tmp_files
+
+ if [ "$DESTDIR_DEL" = true ]
+ then
+ rm -rf "$DESTDIR"
+ fi
+}
+
+function cleanup_disk_image_error()
+{
+ cleanup_disk_image
+ rm $IMG
+}
+
function check_depends()
{
for ((i=0; i<${#PROG_REQ[@]}; i++))
@@ -58,6 +75,7 @@ function generate_domU_configs()
# $j + 1 - 1 as it is starting from 0
local n=$1
local dest
+ local dtb_name
mount -t ext4 /dev/mapper/diskimage$j $DESTDIR/part/disk$j
mkdir -p $DESTDIR/part/disk$j/etc/xen
@@ -68,10 +86,30 @@ function generate_domU_configs()
do
if test "${DOMU_NOBOOT[$i]}"
then
+ if test -z "${DOMU_PASSTHROUGH_DTB[$i]}" && test "${DOMU_PASSTHROUGH_PATHS[$i]}"
+ then
+ output_dir=`mktemp -d`
+ tmp_dirs+=($output_dir)
+
+ # Check if the below function returns error
+ # and unmount the partition
+ compile_merge_partial_dts $output_dir "$PASSTHROUGH_DTS_REPO"
+ if test $? -ne 0
+ then
+ umount $DESTDIR/part/disk$j
+ cleanup_disk_image_error
+ exit 1
+ fi
+ fi
+
dest="$DESTDIR/part/disk$j/etc/xen/domU$i.cfg"
+ cp ${DOMU_PASSTHROUGH_DTB[$i]} $DESTDIR/part/disk$j/etc/xen/
echo "name=\"domU$i\"" >> $dest
echo "memory=${DOMU_MEM[$i]}" >> $dest
echo "vcpus=${DOMU_VCPUS[$i]}" >> $dest
+
+ dtb_name="$(basename ${DOMU_PASSTHROUGH_DTB[$i]})"
+ echo "device_tree=\"/etc/xen/$dtb_name\"" >> $dest
echo "# mount $first_part /boot" >> $dest
echo "kernel=\"/boot/${DOMU_KERNEL[$i]}\"" >> $dest
if test "${DOMU_RAMDISK[$i]}"
@@ -302,6 +340,9 @@ check_depends
source "$CFG_FILE"
+SCRIPT_PATH=$(dirname "$0")
+source "$SCRIPT_PATH/common"
+
i=0
while test $i -lt $NUM_DOMUS
do
@@ -546,12 +587,4 @@ do
i=$(( $i + 1 ))
done
-
-kpartx -d /dev/mapper/diskimage
-dmsetup remove diskimage
-losetup -d $_loop_dev
-
-if [ "$DESTDIR_DEL" = true ]
-then
- rm -rf "$DESTDIR"
-fi
+cleanup_disk_image