* [PATCH 0/3] Migration to start_vm.py and removing deprecated scripts
@ 2024-02-01 6:58 Ilia Skochilov
2024-02-01 6:58 ` [PATCH 1/3] Migration from start_vm to start_vm.py Ilia Skochilov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Ilia Skochilov @ 2024-02-01 6:58 UTC (permalink / raw)
To: isar-users; +Cc: Ilia Skochilov
Migration to start_vm.py and removing deprecated scripts.
Ilia Skochilov (3):
Migration from start_vm to start_vm.py
start_vm: remove shell version
Remove vm_smoke_test
CONTRIBUTING.md | 2 -
README.md | 2 +-
doc/user_manual.md | 2 +-
scripts/isar-buildenv-internal | 2 +-
scripts/start_vm | 156 ---------------------------------
scripts/vm_smoke_test | 104 ----------------------
testsuite/start_vm.py | 31 +++++--
7 files changed, 29 insertions(+), 270 deletions(-)
delete mode 100755 scripts/start_vm
delete mode 100755 scripts/vm_smoke_test
--
2.39.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] Migration from start_vm to start_vm.py
2024-02-01 6:58 [PATCH 0/3] Migration to start_vm.py and removing deprecated scripts Ilia Skochilov
@ 2024-02-01 6:58 ` Ilia Skochilov
2024-02-01 6:58 ` [PATCH 2/3] start_vm: remove shell version Ilia Skochilov
2024-02-01 6:58 ` [PATCH 3/3] Remove vm_smoke_test Ilia Skochilov
2 siblings, 0 replies; 4+ messages in thread
From: Ilia Skochilov @ 2024-02-01 6:58 UTC (permalink / raw)
To: isar-users; +Cc: Ilia Skochilov
start_vm.py: Add support for the secureboot option. Option --secureboot (-s)
enables secureboot with default MS keys for amd64-sb as -a option.
isar-buildenv-internal: adds ISARROOT/testsuite to $PATH.
user_manual.md, README.md: Update. Describe how to start a QEMU instance
with start_vm.py.
Signed-off-by: Ilia Skochilov <iskochilov@ilbers.de>
---
README.md | 2 +-
doc/user_manual.md | 2 +-
scripts/isar-buildenv-internal | 2 +-
testsuite/start_vm.py | 31 ++++++++++++++++++++++++++-----
4 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/README.md b/README.md
index f549aa9..881182a 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@ for the instructions.
To test the QEMU image, run the following command:
- $ start_vm -a <arch of your build> -d <distro of your build>
+ $ start_vm.py -a <arch of your build> -d <distro of your build>
Ex: Architecture of your build could be arm,arm64,i386,amd64,etc.
Distribution of your build could be buster,bullseye,bookworm,etc.
diff --git a/doc/user_manual.md b/doc/user_manual.md
index 2eb9764..056a446 100644
--- a/doc/user_manual.md
+++ b/doc/user_manual.md
@@ -1021,7 +1021,7 @@ bitbake mc:qemuamd64-sb-bullseye:isar-image-base
**Start the image:** (consider adding `-enable-kvm` to get some decent performance):
```bash
-start_vm -a amd64-sb -d bullseye -s
+start_vm.py -a amd64-sb -d bullseye -s
```
**Check if SB is actually enabled (detected):**
diff --git a/scripts/isar-buildenv-internal b/scripts/isar-buildenv-internal
index 1f609a5..1379f90 100755
--- a/scripts/isar-buildenv-internal
+++ b/scripts/isar-buildenv-internal
@@ -63,7 +63,7 @@ export BITBAKEDIR="${ISARROOT}/bitbake"
export SCRIPTSDIR="${ISARROOT}/scripts"
export TESTSUITEDIR="${ISARROOT}/testsuite"
-for newpath in "$BITBAKEDIR/bin" "$SCRIPTSDIR"; do
+for newpath in "$BITBAKEDIR/bin" "$SCRIPTSDIR" "$ISARROOT/testsuite"; do
# Remove any existences of $newpath from $PATH
PATH=$(echo $PATH | sed -re "s#(^|:)$newpath(:|$)#\2#g;s#^:##")
diff --git a/testsuite/start_vm.py b/testsuite/start_vm.py
index ef0dfbc..a7c91e0 100755
--- a/testsuite/start_vm.py
+++ b/testsuite/start_vm.py
@@ -22,12 +22,17 @@ def get_bitbake_var(output, var):
ret = line.split('"')[1]
return ret
-def format_qemu_cmdline(arch, build, distro, image, out, pid, enforce_pcbios=False):
+def format_qemu_cmdline(arch, build, distro, image, out, pid, enforce_pcbios=False, secureboot=False):
bb_output = get_bitbake_env(arch, distro, image).decode()
extra_args = ''
cpu = ['']
+ if secureboot and arch != 'amd64-sb':
+ raise ValueError('Invalid arch. Secureboot is only supported by amd64-sb')
+ if arch == 'amd64-sb' and not secureboot:
+ raise ValueError('amd64-sb is only compatible with the secureboot option enabled')
+
image_type = get_bitbake_var(bb_output, 'IMAGE_FSTYPES').split()[0]
deploy_dir_image = get_bitbake_var(bb_output, 'DEPLOY_DIR_IMAGE')
base = 'ubuntu' if distro in ['jammy', 'focal'] else 'debian'
@@ -67,6 +72,10 @@ def format_qemu_cmdline(arch, build, distro, image, out, pid, enforce_pcbios=Fal
extra_args.extend(['-pidfile', pid])
qemu_disk_args = qemu_disk_args.replace('##ROOTFS_IMAGE##', deploy_dir_image + '/' + rootfs_image).split()
+
+ if secureboot:
+ qemu_disk_args.extend(['-drive', f'if=pflash,format=raw,unit=1,file="OVMF_VARS_4M.ms.fd"'])
+
if enforce_pcbios and '-bios' in qemu_disk_args:
bios_idx = qemu_disk_args.index('-bios')
del qemu_disk_args[bios_idx : bios_idx+2]
@@ -91,22 +100,34 @@ def format_qemu_cmdline(arch, build, distro, image, out, pid, enforce_pcbios=Fal
return cmd
-def start_qemu(arch, build, distro, image, out, pid, enforce_pcbios):
- cmdline = format_qemu_cmdline(arch, build, distro, image, out, pid, enforce_pcbios)
+def start_qemu(arch, build, distro, image, out, pid, enforce_pcbios, secureboot):
+ cmdline = format_qemu_cmdline(arch, build, distro, image, out, pid, enforce_pcbios, secureboot)
cmdline.insert(1, '-nographic')
print(cmdline)
+
+ if secureboot:
+ import shutil
+ ovmf_vars_orig = '/usr/share/OVMF/OVMF_VARS_4M.ms.fd'
+ ovmf_vars_copy = 'OVMF_VARS_4M.ms.fd'
+ shutil.copy(ovmf_vars_orig, ovmf_vars_copy)
+ try:
+ p1 = subprocess.call('exec ' + ' '.join(cmdline), shell=True)
+ finally:
+ os.remove(ovmf_vars_copy)
+
p1 = subprocess.call('exec ' + ' '.join(cmdline), shell=True)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
- parser.add_argument('-a', '--arch', choices=['arm', 'arm64', 'amd64', 'i386', 'mipsel'], help='set isar machine architecture.', default='arm')
+ parser.add_argument('-a', '--arch', choices=['arm', 'arm64', 'amd64', 'amd64-sb', 'i386', 'mipsel'], help='set isar machine architecture.', default='arm')
parser.add_argument('-b', '--build', help='set path to build directory.', default=os.getcwd())
parser.add_argument('-d', '--distro', choices=['buster', 'bullseye', 'bookworm', 'trixie', 'focal', 'jammy'], help='set isar Debian distribution.', default='bookworm')
parser.add_argument('-i', '--image', help='set image name.', default='isar-image-base')
parser.add_argument('-o', '--out', help='Route QEMU console output to specified file.')
parser.add_argument('-p', '--pid', help='Store QEMU pid to specified file.')
parser.add_argument('--pcbios', action="store_true", help='remove any bios options to enforce use of pc bios')
+ parser.add_argument('-s', '--secureboot', action='store_true', help='Enable secureboot with default MS keys')
args = parser.parse_args()
- start_qemu(args.arch, args.build, args.distro, args.image, args.out, args.pid, args.pcbios)
+ start_qemu(args.arch, args.build, args.distro, args.image, args.out, args.pid, args.pcbios, args.secureboot)
--
2.39.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/3] start_vm: remove shell version
2024-02-01 6:58 [PATCH 0/3] Migration to start_vm.py and removing deprecated scripts Ilia Skochilov
2024-02-01 6:58 ` [PATCH 1/3] Migration from start_vm to start_vm.py Ilia Skochilov
@ 2024-02-01 6:58 ` Ilia Skochilov
2024-02-01 6:58 ` [PATCH 3/3] Remove vm_smoke_test Ilia Skochilov
2 siblings, 0 replies; 4+ messages in thread
From: Ilia Skochilov @ 2024-02-01 6:58 UTC (permalink / raw)
To: isar-users; +Cc: Ilia Skochilov
Remove shell version of start_vm as it is no longer used.
Signed-off-by: Ilia Skochilov <iskochilov@ilbers.de>
---
scripts/start_vm | 156 -----------------------------------------------
1 file changed, 156 deletions(-)
delete mode 100755 scripts/start_vm
diff --git a/scripts/start_vm b/scripts/start_vm
deleted file mode 100755
index 8c696a4..0000000
--- a/scripts/start_vm
+++ /dev/null
@@ -1,156 +0,0 @@
-#!/bin/sh
-#
-# This software is a part of ISAR.
-# Copyright (C) 2015-2017 ilbers GmbH
-
-set -e
-
-ES_OK=0
-ES_BUG=3
-
-# Convert bitbake assignments to shell ones
-# a = b a=b
-# a ?= b a=b
-# TODO: Use bitbake to parse vars correctly (overriding in local.conf, etc.)
-bb2sh() {
- sed 's/[[:space:]]*?*=[[:space:]]*/=/'
-}
-
-start_qemu() {
- root=`echo $QEMU_DISK_ARGS \
- | sed 's,##ROOTFS_IMAGE##,'$IMAGE_DIR/$ROOTFS_IMAGE','`
- [ -n "$KARGS$EXTRA_KARGS" ] && OPT_KERNEL_ARGS="-append $KARGS$EXTRA_KARGS"
- local had_x
- echo $- | grep -q x && had_x=1 || had_x=0
- [ $had_x -eq 0 ] && set -x
- qemu-system-$QEMU_ARCH \
- -m 1024M \
- -M $QEMU_MACHINE \
- $QCPU \
- -nographic \
- $EXTRA_ARGS \
- $OPT_KERNEL_ARGS \
- $root
- [ $had_x -eq 0 ] && set +x
-}
-
-show_help() {
- echo "This script runs ISAR image in QEMU emulator."
- echo
- echo "Usage:"
- echo " $0 [params] [BUILD_DIR]"
- echo "BUILD_DIR is your ISAR build folder. If not set, current folder"
- echo "is used."
- echo
- echo "Parameters:"
- echo " -a, --arch ARCH set isar machine architecture."
- echo " Supported: arm, i386, amd64, arm64, mipsel, riscv64."
- echo " -b, --build BUILD set path to build directory."
- echo " -d, --distro DISTRO set isar Debian distribution."
- echo " Supported: buster, bullseye, bookworm"
- echo " -o, --out FILE Route QEMU console output to"
- echo " specified file."
- echo " -p, --pid FILE Store QEMU pid to file."
- echo " -s, --secureboot Enable secureboot with default MS keys."
- echo " --help display this message and exit."
- echo
- echo "Exit status:"
- echo " 0 if OK,"
- echo " 3 if invalid parameters are passed."
-}
-
-# Set default values, that can be overwritten from command line
-ARCH=arm
-DISTRO=bullseye
-BUILD_DIR=$PWD
-
-# Parse command line to get user configuration
-while [ $# -gt 0 ]
-do
- key="$1"
-
- case $key in
- -h|--help)
- show_help
- exit 0
- ;;
- -a|--arch)
- ARCH=$2
- shift
- ;;
- -b|--build)
- BUILD_DIR=$2
- shift
- ;;
- -d|--distro)
- DISTRO=$2
- shift
- ;;
- -o|--out)
- EXTRA_ARGS="$EXTRA_ARGS -serial file:$2"
- shift
- ;;
- -p|--pid)
- EXTRA_ARGS="$EXTRA_ARGS -pidfile $2"
- shift
- ;;
- -s|--secureboot)
- OVMF_VARS_ORIG="/usr/share/OVMF/OVMF_VARS_4M.ms.fd"
- OVMF_VARS="$(basename "${OVMF_VARS_ORIG}")"
- cp "${OVMF_VARS_ORIG}" "${OVMF_VARS}"
- EXTRA_ARGS="$EXTRA_ARGS -drive if=pflash,format=raw,unit=1,file=${OVMF_VARS}"
- ;;
- *)
- echo "error: invalid parameter '$key', please try '--help' to get list of supported parameters"
- exit $ES_BUG
- ;;
- esac
-
- shift
-done
-
-eval $(bitbake -e mc:qemu$ARCH-$DISTRO:isar-image-base | grep "^DEPLOY_DIR_IMAGE=")
-readonly IMAGE_DIR=$DEPLOY_DIR_IMAGE
-
-readonly ISARROOT="$(dirname "$0")"/..
-
-readonly MACHINE_CONF=$ISARROOT/meta-isar/conf/machine/qemu$ARCH.conf
-eval "$(egrep 'MACHINE_SERIAL|QEMU_' $MACHINE_CONF |bb2sh)"
-
-eval $(bitbake -e mc:qemu$ARCH-$DISTRO:isar-image-base | grep "\(^IMAGE_FSTYPES=\|^IMAGE_FULLNAME=\)")
-# Take first image type for VM if there are several defined
-IMAGE_FSTYPES=$(echo "$IMAGE_FSTYPES" | awk '{print $1}')
-case "$IMAGE_FSTYPES" in
- ext4)
- readonly ROOTFS_IMAGE=$IMAGE_FULLNAME.ext4
-
- eval $(bitbake -e mc:qemu$ARCH-$DISTRO:isar-image-base | grep "^KERNEL_IMAGE=")
- eval $(bitbake -e mc:qemu$ARCH-$DISTRO:isar-image-base | grep "^INITRD_DEPLOY_FILE=")
- QKERNEL=$IMAGE_DIR/${KERNEL_IMAGE}
- QINITRD=/dev/null
- [ -n "$INITRD_DEPLOY_FILE" ] && QINITRD=$IMAGE_DIR/${INITRD_DEPLOY_FILE}
- if [ "$ARCH" = "riscv64" ]; then
- EXTRA_ARGS="$EXTRA_ARGS -device loader,file=$QKERNEL,addr=0x80200000"
- QKERNEL="/usr/lib/riscv64-linux-gnu/opensbi/qemu/virt/fw_jump.elf"
- fi
- EXTRA_ARGS="$EXTRA_ARGS \
- -kernel $QKERNEL \
- -initrd $QINITRD"
- KARGS="console=$MACHINE_SERIAL root=/dev/$QEMU_ROOTFS_DEV rw $QEMU_KARGS"
- ;;
- wic)
- readonly ROOTFS_IMAGE=$IMAGE_FULLNAME.wic
- EXTRA_ARGS="$EXTRA_ARGS -snapshot"
- ;;
- *)
- echo "IMAGE_FSTYPES \"$IMAGE_FSTYPES\" not supported"
- exit 1
- ;;
-esac
-
-QCPU=
-[ -n "$QEMU_CPU" ] && QCPU="-cpu $QEMU_CPU"
-
-start_qemu
-
-exit $ES_OK
--
2.39.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/3] Remove vm_smoke_test
2024-02-01 6:58 [PATCH 0/3] Migration to start_vm.py and removing deprecated scripts Ilia Skochilov
2024-02-01 6:58 ` [PATCH 1/3] Migration from start_vm to start_vm.py Ilia Skochilov
2024-02-01 6:58 ` [PATCH 2/3] start_vm: remove shell version Ilia Skochilov
@ 2024-02-01 6:58 ` Ilia Skochilov
2 siblings, 0 replies; 4+ messages in thread
From: Ilia Skochilov @ 2024-02-01 6:58 UTC (permalink / raw)
To: isar-users; +Cc: Ilia Skochilov
Remove vm_smoke_test and mentions of it in the documentation as it is
no longer used.
Signed-off-by: Ilia Skochilov <iskochilov@ilbers.de>
---
CONTRIBUTING.md | 2 -
scripts/vm_smoke_test | 104 ------------------------------------------
2 files changed, 106 deletions(-)
delete mode 100755 scripts/vm_smoke_test
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 9ad6bf3..90bc7d4 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -85,7 +85,6 @@ Plan merges to `master` so that both fit the two-week window; short extensions s
scripts/ci_build.sh -q -f
...
source isar-init-build-env
- scripts/vm_smoke_test -f
```
Currently "fast" CI launches
* parallel cross build of QEMU arm/arm64/amd64 Debian stretch and Raspberry Pi 1 Raspbian stretch targets
@@ -97,7 +96,6 @@ Plan merges to `master` so that both fit the two-week window; short extensions s
scripts/ci_build.sh -q
...
source isar-init-build-env
- scripts/vm_smoke_test -q
```
Currently standard CI launches
* parallel native build of QEMU arm/arm64/i386/amd64 Debian stretch/buster and Raspberry Pi 1 Raspbian stretch targets
diff --git a/scripts/vm_smoke_test b/scripts/vm_smoke_test
deleted file mode 100755
index 5c16d86..0000000
--- a/scripts/vm_smoke_test
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/bin/sh
-#
-# This software is a part of ISAR.
-# Copyright (C) 2015-2018 ilbers GmbH
-
-VERBOSE="--show=test"
-TIMEOUT=300
-
-# Error codes:
-ES_OK=0
-ES_FAIL=1
-ES_BUG=3
-
-RET=$ES_FAIL
-
-# Get Avocado QEMU tests path
-TESTSUITE_DIR="$(dirname "$0")/../testsuite"
-
-# Go to Isar root
-cd "$(dirname "$0")/.."
-
-BUILD_DIR=./build
-
-show_help() {
- echo "This script tests the Isar images for default targets in QEMU."
- echo
- echo "Usage:"
- echo " $0 [params]"
- echo
- echo "Parameters:"
- echo " -f,--fast test reduced set of supported targets."
- echo " -q, --quiet do not display boot logs for all the targets."
- echo " If test failed for the specific configuration,"
- echo " the respective boot log will be printed anyway."
- echo " -t,--timeout SEC specify time in seconds to wait before stop QEMU."
- echo " The default is: 300"
- echo " -h, --help display this message and exit."
- echo
- echo "Exit status:"
- echo " 0 if OK,"
- echo " 1 if test failed,"
- echo " 3 if invalid parameters are passed."
-}
-
-# Parse command line to get user configuration
-while [ $# -gt 0 ]
-do
- key="$1"
-
- case $key in
- -h|--help)
- show_help
- exit 0
- ;;
- -o|--output)
- # Deprecated option
- shift
- ;;
- -p|--pid-file)
- # Deprecated option
- shift
- ;;
- -f|--fast)
- FAST_BUILD="1"
- ;;
- -q|--quiet)
- VERBOSE=""
- ;;
- -t|--timeout)
- TIMEOUT=$2
- shift
- ;;
- *)
- echo "error: invalid parameter '$key', please try '--help' to get list of supported parameters"
- exit $ES_BUG
- ;;
- esac
-
- shift
-done
-
-TAGS="full"
-if [ -n "$FAST_BUILD" ]; then
- TAGS="fast"
-fi
-
-# Provide working path
-mkdir -p .config/avocado
-cat <<EOF > .config/avocado/avocado.conf
-[datadir.paths]
-base_dir = $BUILD_DIR/
-test_dir = $BUILD_DIR/tests
-data_dir = $BUILD_DIR/data
-logs_dir = $BUILD_DIR/job-results
-EOF
-export VIRTUAL_ENV="./"
-
-if avocado $VERBOSE run "$TESTSUITE_DIR/citest.py" -t $TAGS,startvm \
- --test-runner=runner --disable-sysinfo \
- -p build_dir="$BUILD_DIR" -p time_to_wait=$TIMEOUT; then
- RET=$ES_OK
-fi
-
-exit $RET
--
2.39.2
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-02-01 10:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-01 6:58 [PATCH 0/3] Migration to start_vm.py and removing deprecated scripts Ilia Skochilov
2024-02-01 6:58 ` [PATCH 1/3] Migration from start_vm to start_vm.py Ilia Skochilov
2024-02-01 6:58 ` [PATCH 2/3] start_vm: remove shell version Ilia Skochilov
2024-02-01 6:58 ` [PATCH 3/3] Remove vm_smoke_test Ilia Skochilov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox