From: Anton Mikanovich <amikan@ilbers.de>
To: isar-users@googlegroups.com
Cc: Anton Mikanovich <amikan@ilbers.de>
Subject: [PATCH v3 5/5] start_vm: Reuse getVars API
Date: Fri, 21 Jun 2024 18:08:14 +0300 [thread overview]
Message-ID: <20240621150814.189288-6-amikan@ilbers.de> (raw)
In-Reply-To: <20240621150814.189288-1-amikan@ilbers.de>
We already have an API to get Bitbake variable values without manual
handling of bitbake execution. This will speedup und simplify start_vm.
Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
testsuite/start_vm.py | 50 ++++++++++++++++++++++---------------------
1 file changed, 26 insertions(+), 24 deletions(-)
diff --git a/testsuite/start_vm.py b/testsuite/start_vm.py
index 0e0d7000..d6e04049 100755
--- a/testsuite/start_vm.py
+++ b/testsuite/start_vm.py
@@ -11,43 +11,50 @@ import sys
import shutil
import time
-OVMF_VARS_PATH = '/usr/share/OVMF/OVMF_VARS_4M.ms.fd'
-
-def get_bitbake_env(arch, distro, image):
- multiconfig = 'mc:qemu' + arch + '-' + distro + ':' + image
- output = subprocess.check_output(['bitbake', '-e', str(multiconfig)])
- return output
+from utils import CIUtils
-def get_bitbake_var(output, var):
- ret = ''
- for line in output.splitlines():
- if line.startswith(var + '='):
- ret = line.split('"')[1]
- return ret
+OVMF_VARS_PATH = '/usr/share/OVMF/OVMF_VARS_4M.ms.fd'
def format_qemu_cmdline(arch, build, distro, image, out, pid, enforce_pcbios=False):
- bb_output = get_bitbake_env(arch, distro, image).decode()
+ multiconfig = f'mc:qemu{arch}-{distro}:{image}'
+
+ image_fstypes, \
+ deploy_dir_image, \
+ kernel_image, \
+ initrd_image, \
+ serial, \
+ root_dev, \
+ qemu_arch, \
+ qemu_machine, \
+ qemu_cpu, \
+ qemu_disk_args = CIUtils.getVars('IMAGE_FSTYPES',
+ 'DEPLOY_DIR_IMAGE',
+ 'KERNEL_IMAGE',
+ 'INITRD_DEPLOY_FILE',
+ 'MACHINE_SERIAL',
+ 'QEMU_ROOTFS_DEV',
+ 'QEMU_ARCH',
+ 'QEMU_MACHINE',
+ 'QEMU_CPU',
+ 'QEMU_DISK_ARGS',
+ target=multiconfig)
extra_args = ''
cpu = ['']
- image_type = get_bitbake_var(bb_output, 'IMAGE_FSTYPES').split()[0]
- deploy_dir_image = get_bitbake_var(bb_output, 'DEPLOY_DIR_IMAGE')
+ image_type = image_fstypes.split()[0]
base = 'ubuntu' if distro in ['jammy', 'focal'] else 'debian'
rootfs_image = image + '-' + base + '-' + distro + '-qemu' + arch + '.' + image_type
if image_type == 'ext4':
- kernel_image = deploy_dir_image + '/' + get_bitbake_var(bb_output, 'KERNEL_IMAGE')
- initrd_image = get_bitbake_var(bb_output, 'INITRD_DEPLOY_FILE')
+ kernel_image = deploy_dir_image + '/' + kernel_image
if not initrd_image:
initrd_image = '/dev/null'
else:
initrd_image = deploy_dir_image + '/' + initrd_image
- serial = get_bitbake_var(bb_output, 'MACHINE_SERIAL')
- root_dev = get_bitbake_var(bb_output, 'QEMU_ROOTFS_DEV')
kargs = ['-append', '"console=' + serial + ' root=/dev/' + root_dev + ' rw"']
extra_args = ['-kernel', kernel_image, '-initrd', initrd_image]
@@ -57,11 +64,6 @@ def format_qemu_cmdline(arch, build, distro, image, out, pid, enforce_pcbios=Fal
else:
raise ValueError('Invalid image type: ' + str(image_type))
- qemu_arch = get_bitbake_var(bb_output, 'QEMU_ARCH')
- qemu_machine = get_bitbake_var(bb_output, 'QEMU_MACHINE')
- qemu_cpu = get_bitbake_var(bb_output, 'QEMU_CPU')
- qemu_disk_args = get_bitbake_var(bb_output, 'QEMU_DISK_ARGS')
-
if out:
extra_args.extend(['-chardev','stdio,id=ch0,logfile=' + out])
extra_args.extend(['-serial','chardev:ch0'])
--
2.34.1
next prev parent reply other threads:[~2024-06-21 15:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-21 15:08 [PATCH v3 0/5] Remove code duplications for start_vm Anton Mikanovich
2024-06-21 15:08 ` [PATCH v3 1/5] start_vm: Switch to python version Anton Mikanovich
2024-06-21 15:08 ` [PATCH v3 2/5] start_vm: Add secureboot support Anton Mikanovich
2024-06-21 15:08 ` [PATCH v3 3/5] scripts: Remove vm_smoke_test Anton Mikanovich
2024-06-21 15:08 ` [PATCH v3 4/5] CI: Allow external usage for some APIs Anton Mikanovich
2024-06-21 15:08 ` Anton Mikanovich [this message]
2024-06-26 6:32 ` [PATCH v3 0/5] Remove code duplications for start_vm Uladzimir Bely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240621150814.189288-6-amikan@ilbers.de \
--to=amikan@ilbers.de \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox