From patchwork Thu Oct 17 08:45:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikko Rapeli X-Patchwork-Id: 50809 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id B57A0D21252 for ; Thu, 17 Oct 2024 08:46:23 +0000 (UTC) Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) by mx.groups.io with SMTP id smtpd.web10.43904.1729154773286082976 for ; Thu, 17 Oct 2024 01:46:13 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=xPcOSsWY; spf=pass (domain: linaro.org, ip: 209.85.167.52, mailfrom: mikko.rapeli@linaro.org) Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-539f1292a9bso888561e87.2 for ; Thu, 17 Oct 2024 01:46:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729154771; x=1729759571; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Iyp9362Z4M3adhdcTJ8A6OzCXqM22i/SfhTqjiGK4D8=; b=xPcOSsWYhRr1V0g3aXFM60e98hy9uydANJcVnnydK8tmcMpkYfii9tVBLdlfAGVExe HgeK6wKFOm38Oh3sAw9OaHWZf8w+zroDhD3zUFQRMYIhOCOKaNYV7vzbGoDzATc82JEm jGYwwyJZXtC3xYW6mA19yrCN4LoJ1Q3L1uXE9gKRs2HXUVov0pOjOdqUFaI4juUR6/vz /U+6vakrDLfQ/YJeEcu1CynaMzuqCIn0saEIvwzYVqQ9CnNLSdf+NmUZ0XoSoxHYYFn8 Poy4PRFG7fHZL/a1Ixl4Xv56KMxUmYnwxkc/e7FJUXgj1dY8ncbY9BoYYdvT6gvnXPEU 5wWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729154771; x=1729759571; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Iyp9362Z4M3adhdcTJ8A6OzCXqM22i/SfhTqjiGK4D8=; b=rh6omlXqdFnVi9VXJKl8M6Cby36NecPIjxCA5lR/aOqubNXwSRSUiuX5k7kWQZ2fmZ IUtJBB8cyRBtYeATYuV3vtqc85ZIgow3muwLty/D3cTdoJsXqTXkGXqZCRQT2scgmZWF 2FLj50dvdrNchZJNBgIBuxSZeiT34C2lZc7b2I2VLj0m23v+qdBZXlu2n0bccj22ir2t /f9q8EcV/FLRINTquwwGgxCnaLwne3txL8e5ZwA6lteCp8Nmz3loddrqOiCR5m0jEcqe VbMHppj9+rvq7XuSo0rKBhaj53i+oPlGpl7TzleSxUYWVsDAysBaER9lxQlAhJDobG+L NBEg== X-Gm-Message-State: AOJu0Yzp1DrOrE6SBTHN3DASEVZ+j/As89CZK39H2rYKRqpBFb1pZhPN g3j+OPYU4/Y2qqGlmrfkYewaiPWaJm3oeNdmrw7mmiIahDIf49glEhV6m9gHkXgmBJtyjH/6xSd dPPE= X-Google-Smtp-Source: AGHT+IGMMsjCUYm6OfbZBW7zj9lsNPwqqs4LVgdROiWvFRmAWYJOFjrudCHpfpDHHomfJlaSrRJd5Q== X-Received: by 2002:a05:6512:3094:b0:539:fb49:c47d with SMTP id 2adb3069b0e04-53a03f07430mr4734116e87.12.1729154771109; Thu, 17 Oct 2024 01:46:11 -0700 (PDT) Received: from localhost.localdomain (78-27-76-97.bb.dnainternet.fi. [78.27.76.97]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-539fffa8e4asm706138e87.55.2024.10.17.01.46.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 01:46:10 -0700 (PDT) From: Mikko Rapeli To: openembedded-core@lists.openembedded.org Cc: Michelle Lin , Erik Schilling , Mikko Rapeli Subject: [PATCH v9 01/11] uki.bbclass: add class for building Unified Kernel Images (UKI) Date: Thu, 17 Oct 2024 11:45:42 +0300 Message-ID: <20241017084552.182136-2-mikko.rapeli@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241017084552.182136-1-mikko.rapeli@linaro.org> References: <20241017084552.182136-1-mikko.rapeli@linaro.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 17 Oct 2024 08:46:23 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/205996 From: Michelle Lin This class calls systemd ukify tool, which will combine kernel/initrd/stub components to build the UKI. To sign the UKI (i.e. SecureBoot), the keys/cert files can be specified in a configuration file or UEFI binary signing can be done via separate steps, see qemuarm64-secureboot in meta-arm. UKIs are loaded by UEFI firmware on target which can improve security by loading only correctly signed kernel, initrd and kernel command line. Using systemd-measure to pre-calculate TPM PCR values and sign them is not supported since that requires a TPM device on the build host. Thus "ConditionSecurity=measured-uki" default from systemd 256 does not work but "ConditionSecurity=tpm2" in combination with secure boot will. These can be used to boot securely into systemd-boot, kernel, kernel command line and initrd which then securely mounts a read-only dm-verity /usr partition and creates a TPM encrypted read-write / rootfs. Tested via qemuarm64-secureboot in meta-arm with https://lists.yoctoproject.org/g/meta-arm/topic/patch_v3_02_13/108031399 and a few more changes needed, will be posted separately. Signed-off-by: Michelle Lin Acked-by: Erik Schilling Signed-off-by: Mikko Rapeli --- meta/classes-recipe/uki.bbclass | 195 ++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 meta/classes-recipe/uki.bbclass diff --git a/meta/classes-recipe/uki.bbclass b/meta/classes-recipe/uki.bbclass new file mode 100644 index 0000000000..d4f25c7fd2 --- /dev/null +++ b/meta/classes-recipe/uki.bbclass @@ -0,0 +1,195 @@ +# Unified kernel image (UKI) class +# +# This bbclass merges kernel, initrd etc as a UKI standard UEFI binary, +# to be loaded with UEFI firmware and systemd-boot on target HW. +# TPM PCR pre-calculation is not supported since systemd-measure tooling +# is meant to run on target, not in cross compile environment. +# +# See: +# https://www.freedesktop.org/software/systemd/man/latest/ukify.html +# https://uapi-group.org/specifications/specs/unified_kernel_image/ +# +# The UKI contains: +# +# - UEFI stub +# The linux kernel can generate a UEFI stub, however the one from systemd-boot can fetch +# the command line from a separate section of the EFI application, avoiding the need to +# rebuild the kernel. +# - kernel +# - initramfs +# - kernel command line +# - uname -r kernel version +# - /etc/os-release to create a boot menu with version details +# - optionally secure boot signature(s) +# - other metadata (e.g. TPM PCR measurements) +# +# Usage instructions: +# +# - requires UEFI compatible firmware on target, e.g. qemuarm64-secureboot u-boot based +# from meta-arm or qemux86 ovmf/edk2 based firmware for x86_64 +# +# - Distro/build config: +# +# INIT_MANAGER = "systemd" +# MACHINE_FEATURES:append = " efi" +# EFI_PROVIDER = "systemd-boot" +# INITRAMFS_IMAGE = "core-image-minimal-initramfs" +# +# - image recipe: +# +# inherit uki +# +# - qemuboot/runqemu changes in image recipe or build config: +# +# # Kernel command line must be inside the signed uki +# QB_KERNEL_ROOT = "" +# # kernel is in the uki image, not loaded separately +# QB_DEFAULT_KERNEL = "none" +# +# - for UEFI secure boot, systemd-boot and uki (including kernel) can +# be signed but require sbsign-tool-native (recipe available from meta-secure-core, +# see also qemuarm64-secureboot from meta-arm). Set variable +# UKI_SB_KEY to path of private key and UKI_SB_CERT for certificate. +# Note that systemd-boot also need to be signed with the same key. +# +# - at runtime, UEFI firmware will load and boot systemd-boot which +# creates a menu from all detected uki binaries. No need to manually +# setup boot menu entries. +# +# - see efi-uki-bootdisk.wks.in how to create ESP partition which hosts systemd-boot, +# config file(s) for systemd-boot and the UKI binaries. +# + +DEPENDS += "\ + os-release \ + systemd-boot \ + systemd-boot-native \ + virtual/${TARGET_PREFIX}binutils \ + virtual/kernel \ +" + +inherit image-artifact-names +require ../conf/image-uefi.conf + +INITRAMFS_IMAGE ?= "core-image-minimal-initramfs" + +INITRD_ARCHIVE ?= "${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES}" + +do_image_complete[depends] += "${INITRAMFS_IMAGE}:do_image_complete" + +UKIFY_CMD ?= "ukify build" +UKI_CONFIG_FILE ?= "${UNPACKDIR}/uki.conf" +UKI_FILENAME ?= "uki.efi" +UKI_KERNEL_FILENAME ?= "${KERNEL_IMAGETYPE}" +UKI_CMDLINE ?= "rootwait root=LABEL=root console=${KERNEL_CONSOLE}" +# secure boot keys and cert, needs sbsign-tools-native (meta-secure-core) +#UKI_SB_KEY ?= "" +#UKI_SB_CERT ?= "" + +IMAGE_EFI_BOOT_FILES ?= "${UKI_FILENAME};EFI/Linux/${UKI_FILENAME}" + +do_uki[depends] += " \ + systemd-boot:do_deploy \ + virtual/kernel:do_deploy \ + " +do_uki[depends] += "${@ '${INITRAMFS_IMAGE}:do_image_complete' if d.getVar('INITRAMFS_IMAGE') else ''}" + +# ensure that the build directory is empty everytime we generate a newly-created uki +do_uki[cleandirs] = "${B}" +# influence the build directory at the start of the builds +do_uki[dirs] = "${B}" + +# we want to allow specifying files in SRC_URI, such as for signing the UKI +python () { + d.delVarFlag("do_fetch","noexec") + d.delVarFlag("do_unpack","noexec") +} + +# main task +python do_uki() { + import glob + import bb.process + + # base ukify command, can be extended if needed + ukify_cmd = d.getVar('UKIFY_CMD') + + deploy_dir_image = d.getVar('DEPLOY_DIR_IMAGE') + + # architecture + target_arch = d.getVar('EFI_ARCH') + if target_arch: + ukify_cmd += " --efi-arch %s" % (target_arch) + + # systemd stubs + stub = "%s/linux%s.efi.stub" % (d.getVar('DEPLOY_DIR_IMAGE'), target_arch) + if not os.path.exists(stub): + bb.fatal(f"ERROR: cannot find {stub}.") + ukify_cmd += " --stub %s" % (stub) + + # initrd + initramfs_image = "%s" % (d.getVar('INITRD_ARCHIVE')) + ukify_cmd += " --initrd=%s" % (os.path.join(deploy_dir_image, initramfs_image)) + + deploy_dir_image = d.getVar('DEPLOY_DIR_IMAGE') + + # kernel + kernel_filename = d.getVar('UKI_KERNEL_FILENAME') or None + if kernel_filename: + kernel = "%s/%s" % (deploy_dir_image, kernel_filename) + if not os.path.exists(kernel): + bb.fatal(f"ERROR: cannot find %s" % (kernel)) + ukify_cmd += " --linux=%s" % (kernel) + # not always needed, ukify can detect version from kernel binary + kernel_version = d.getVar('KERNEL_VERSION') + if kernel_version: + ukify_cmd += "--uname %s" % (kernel_version) + else: + bb.fatal("ERROR - UKI_KERNEL_FILENAME not set") + + # command line + cmdline = d.getVar('UKI_CMDLINE') + if cmdline: + ukify_cmd += " --cmdline='%s'" % (cmdline) + + # dtb + if d.getVar('KERNEL_DEVICETREE'): + for dtb in d.getVar('KERNEL_DEVICETREE').split(): + dtb_path = "%s/%s" % (deploy_dir_image, dtb) + if not os.path.exists(dtb_path): + bb.fatal(f"ERROR: cannot find {dtb_path}.") + ukify_cmd += " --devicetree %s" % (dtb_path) + + # custom config for ukify + if os.path.exists(d.getVar('UKI_CONFIG_FILE')): + ukify_cmd += " --config=%s" % (d.getVar('UKI_CONFIG_FILE')) + + # systemd tools + ukify_cmd += " --tools=%s%s/lib/systemd/tools" % \ + (d.getVar("RECIPE_SYSROOT_NATIVE"), d.getVar("prefix")) + + # version + ukify_cmd += " --os-release=@%s%s/lib/os-release" % \ + (d.getVar("RECIPE_SYSROOT"), d.getVar("prefix")) + + # TODO: tpm2 measure for secure boot, depends on systemd-native and TPM tooling + # needed in systemd > 254 to fulfill ConditionSecurity=measured-uki + # Requires TPM device on build host, thus not supported at build time. + #ukify_cmd += " --measure" + + # securebooot signing, also for kernel + key = d.getVar('UKI_SB_KEY') + if key: + ukify_cmd += " --sign-kernel --secureboot-private-key='%s'" % (key) + cert = d.getVar('UKI_SB_CERT') + if cert: + ukify_cmd += " --secureboot-certificate='%s'" % (cert) + + # custom output UKI filename + output = " --output=%s/%s" % (d.getVar('DEPLOY_DIR_IMAGE'), d.getVar('UKI_FILENAME')) + ukify_cmd += " %s" % (output) + + # Run the ukify command + bb.debug("uki: running command: %s" % (ukify_cmd)) + bb.process.run(ukify_cmd, shell=True) +} +addtask uki after do_rootfs before do_deploy do_image_complete do_image_wic From patchwork Thu Oct 17 08:45:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikko Rapeli X-Patchwork-Id: 50810 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA4CDD21250 for ; Thu, 17 Oct 2024 08:46:23 +0000 (UTC) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by mx.groups.io with SMTP id smtpd.web11.44632.1729154776115728578 for ; Thu, 17 Oct 2024 01:46:16 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=BCR5ZLdT; spf=pass (domain: linaro.org, ip: 209.85.167.47, mailfrom: mikko.rapeli@linaro.org) Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-539fbe22ac0so792760e87.2 for ; Thu, 17 Oct 2024 01:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729154774; x=1729759574; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=l0By32o/C+iOFmrKlzNfHouLvy5UgXAOcr2DlyVaw4c=; b=BCR5ZLdTDN8l7cPd4bdmTqlecC0Y6u1CdnIcGUh069pZ1Chdsvm2ul2Ex5ECqcrhSM DzPUXlPmWvdGFXYOd+TCFrJdMz6qSbNSsgpATUuZ43NTelFFInh1vjV4I+3iGd+ttR96 +qTjXqlhTyfIUHpcxSwgTOEUTugYvChNEcS5sLQvRFZxE6slyjcWa1/BkGWBjkBw2pAi eqRNvF+kbFy7bn6WuMdx16Xo41kRuweVJRR1JbrY3yX/SysZdl39mnu1HVEiVJ8D/DWq o6KS9CCeaeIhMNiD4h5ric/GNb7xuhv+CiWGE+viXYP2LHxgz7LdFHdX28WPPEjXjrjZ pEpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729154774; x=1729759574; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l0By32o/C+iOFmrKlzNfHouLvy5UgXAOcr2DlyVaw4c=; b=OUzqjYU43SWzmtM+mrGWmyzGlowzC4nq8LScxL/XkTtGX/9cmAA/Uiqw4DjFRnJnui ey20UF7ZQbcyPgNy5D6glQMC/aPy8pOd5fTXpUfY4ebYtay28TC6dS1UOY7F3OFFB1nE LkF4mElohhZ9wT/j2kt/5/yt2ThJY++RZiItwnAtyC3GaabUG7rhylmqTRM+MTG/E5xp jZJgc48ZlTQNNCaZQrW6ExXn4ZRqTgyJAAicugZRcZYRbbXloFvfKOKWMLzkjjV2JyaM e8L+wtIuwUv5x9xPWCPP8L4XJQxvz4opYwwEbV5SB2FLzZ+ltTyAesdUiNRGH3TdF6f0 Zttw== X-Gm-Message-State: AOJu0Yz+1rk7gWpwaKq57K3xUJK7Y5p5Z0TH0mOUea2PfihUDvRTKts1 Ka+wwYxqaaxxrtzJu+pyNbhrn2iAFnGfDQhxm7/AaEWSiPtE9J94b2LMbicei84ZvcU4gz0/31C KhwA= X-Google-Smtp-Source: AGHT+IHEBRNgFlcASDwgYwFsbXaEW2IHt1RFgSMGDSyNz90ImWQMptX003OHMeaJhxcamebzLFPg1w== X-Received: by 2002:a05:6512:68f:b0:539:e317:b05f with SMTP id 2adb3069b0e04-53a03f31724mr4579820e87.28.1729154774103; Thu, 17 Oct 2024 01:46:14 -0700 (PDT) Received: from localhost.localdomain (78-27-76-97.bb.dnainternet.fi. [78.27.76.97]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-539fffa8e4asm706138e87.55.2024.10.17.01.46.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 01:46:12 -0700 (PDT) From: Mikko Rapeli To: openembedded-core@lists.openembedded.org Cc: Mikko Rapeli Subject: [PATCH v9 02/11] wic bootimg-efi.py: keep timestamps and add debug prints Date: Thu, 17 Oct 2024 11:45:43 +0300 Message-ID: <20241017084552.182136-3-mikko.rapeli@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241017084552.182136-1-mikko.rapeli@linaro.org> References: <20241017084552.182136-1-mikko.rapeli@linaro.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 17 Oct 2024 08:46:23 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/205997 Keep timestamps etc to help build reproducibility. Add prints to see what is being copied to ESP partition. Signed-off-by: Mikko Rapeli --- scripts/lib/wic/plugins/source/bootimg-efi.py | 49 ++++++++++++------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py index 7cc5131541..d00f5428da 100644 --- a/scripts/lib/wic/plugins/source/bootimg-efi.py +++ b/scripts/lib/wic/plugins/source/bootimg-efi.py @@ -43,16 +43,18 @@ class BootimgEFIPlugin(SourcePlugin): if initrd: initrds = initrd.split(';') for rd in initrds: - cp_cmd = "cp %s/%s %s" % (bootimg_dir, rd, hdddir) - exec_cmd(cp_cmd, True) + cp_cmd = "cp -v -p %s/%s %s" % (bootimg_dir, rd, hdddir) + out = exec_cmd(cp_cmd, True) + logger.debug("initrd files:\n%s" % (out)) else: logger.debug("Ignoring missing initrd") if dtb: if ';' in dtb: raise WicError("Only one DTB supported, exiting") - cp_cmd = "cp %s/%s %s" % (bootimg_dir, dtb, hdddir) - exec_cmd(cp_cmd, True) + cp_cmd = "cp -v -p %s/%s %s" % (bootimg_dir, dtb, hdddir) + out = exec_cmd(cp_cmd, True) + logger.debug("dtb files:\n%s" % (out)) @classmethod def do_configure_grubefi(cls, hdddir, creator, cr_workdir, source_params): @@ -150,6 +152,7 @@ class BootimgEFIPlugin(SourcePlugin): "%s/hdd/boot/loader/loader.conf", cr_workdir) cfg = open("%s/hdd/boot/loader/loader.conf" % cr_workdir, "w") cfg.write(loader_conf) + logger.debug("loader.conf:\n%s" % (loader_conf)) cfg.close() configfile = creator.ks.bootloader.configfile @@ -401,30 +404,33 @@ class BootimgEFIPlugin(SourcePlugin): exec_native_cmd(objcopy_cmd, native_sysroot) else: if source_params.get('install-kernel-into-boot-dir') != 'false': - install_cmd = "install -m 0644 %s/%s %s/%s" % \ + install_cmd = "install -v -p -m 0644 %s/%s %s/%s" % \ (staging_kernel_dir, kernel, hdddir, kernel) - exec_cmd(install_cmd) + out = exec_cmd(install_cmd) + logger.debug("Installed kernel files:\n%s" % out) if get_bitbake_var("IMAGE_EFI_BOOT_FILES"): for src_path, dst_path in cls.install_task: - install_cmd = "install -m 0644 -D %s %s" \ + install_cmd = "install -v -p -m 0644 -D %s %s" \ % (os.path.join(kernel_dir, src_path), os.path.join(hdddir, dst_path)) - exec_cmd(install_cmd) + out = exec_cmd(install_cmd) + logger.debug("Installed IMAGE_EFI_BOOT_FILES:\n%s" % out) try: if source_params['loader'] == 'grub-efi': shutil.copyfile("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir, "%s/grub.cfg" % cr_workdir) for mod in [x for x in os.listdir(kernel_dir) if x.startswith("grub-efi-")]: - cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (kernel_dir, mod, hdddir, mod[9:]) + cp_cmd = "cp -v -p %s/%s %s/EFI/BOOT/%s" % (kernel_dir, mod, hdddir, mod[9:]) exec_cmd(cp_cmd, True) shutil.move("%s/grub.cfg" % cr_workdir, "%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir) elif source_params['loader'] == 'systemd-boot': for mod in [x for x in os.listdir(kernel_dir) if x.startswith("systemd-")]: - cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (kernel_dir, mod, hdddir, mod[8:]) - exec_cmd(cp_cmd, True) + cp_cmd = "cp -v -p %s/%s %s/EFI/BOOT/%s" % (kernel_dir, mod, hdddir, mod[8:]) + out = exec_cmd(cp_cmd, True) + logger.debug("systemd-boot files:\n%s" % out) elif source_params['loader'] == 'uefi-kernel': kernel = get_bitbake_var("KERNEL_IMAGETYPE") if not kernel: @@ -445,8 +451,9 @@ class BootimgEFIPlugin(SourcePlugin): raise WicError("UEFI stub kernel is incompatible with target %s" % target) for mod in [x for x in os.listdir(kernel_dir) if x.startswith(kernel)]: - cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (kernel_dir, mod, hdddir, kernel_efi_image) - exec_cmd(cp_cmd, True) + cp_cmd = "cp -v -p %s/%s %s/EFI/BOOT/%s" % (kernel_dir, mod, hdddir, kernel_efi_image) + out = exec_cmd(cp_cmd, True) + logger.debug("uefi-kernel files:\n%s" % out) else: raise WicError("unrecognized bootimg-efi loader: %s" % source_params['loader']) @@ -455,13 +462,15 @@ class BootimgEFIPlugin(SourcePlugin): startup = os.path.join(kernel_dir, "startup.nsh") if os.path.exists(startup): - cp_cmd = "cp %s %s/" % (startup, hdddir) - exec_cmd(cp_cmd, True) + cp_cmd = "cp -v -p %s %s/" % (startup, hdddir) + out = exec_cmd(cp_cmd, True) + logger.debug("startup files:\n%s" % out) for paths in part.include_path or []: for path in paths: - cp_cmd = "cp -r %s %s/" % (path, hdddir) + cp_cmd = "cp -v -p -r %s %s/" % (path, hdddir) exec_cmd(cp_cmd, True) + logger.debug("include_path files:\n%s" % out) du_cmd = "du -bks %s" % hdddir out = exec_cmd(du_cmd) @@ -489,12 +498,14 @@ class BootimgEFIPlugin(SourcePlugin): label = part.label if part.label else "ESP" - dosfs_cmd = "mkdosfs -n %s -i %s -C %s %d" % \ + dosfs_cmd = "mkdosfs -v -n %s -i %s -C %s %d" % \ (label, part.fsuuid, bootimg, blocks) exec_native_cmd(dosfs_cmd, native_sysroot) + logger.debug("mkdosfs:\n%s" % (str(out))) - mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir) - exec_native_cmd(mcopy_cmd, native_sysroot) + mcopy_cmd = "mcopy -v -p -i %s -s %s/* ::/" % (bootimg, hdddir) + out = exec_native_cmd(mcopy_cmd, native_sysroot) + logger.debug("mcopy:\n%s" % (str(out))) chmod_cmd = "chmod 644 %s" % bootimg exec_cmd(chmod_cmd) From patchwork Thu Oct 17 08:45:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikko Rapeli X-Patchwork-Id: 50811 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C748ED21254 for ; Thu, 17 Oct 2024 08:46:23 +0000 (UTC) Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) by mx.groups.io with SMTP id smtpd.web10.43905.1729154780066533437 for ; Thu, 17 Oct 2024 01:46:20 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=lFsHcNPR; spf=pass (domain: linaro.org, ip: 209.85.167.52, mailfrom: mikko.rapeli@linaro.org) Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-539fb49c64aso951387e87.0 for ; Thu, 17 Oct 2024 01:46:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729154778; x=1729759578; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5oflp4uTMQ+zTlPct28xqYF6LyrMyvI8XmhD31XupPA=; b=lFsHcNPR8Q97GQyf/nMpRC0k/WQDijiub1VmXQuJZAQqJsoiIdDT7sFSCq+Ydhoqli x3kNuSk1RUlM7l/LravtSmnH0FwtiT9eBZtjva/NB2xxOVUWosePbwH3dSGwgQPSmB3z 2/2xYg6HTGk0niGK4N9wgvls8pW9QLd8OGOvyNgCzzf2S8kI01NG8U9nJiD1NPU12FFP zeuxIObsSV8m2oMLzt8RP0uazduso9/WtQ53KqiJ1B9ayVcPR2XlQDP167LPjBAJnrkT 9oajCrYsM23/0d/Xga+K+QmCMlSPzpoisfFS0TdIrsE8M7Z2ZRsijJw3Xnb9YO69udj0 4+yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729154778; x=1729759578; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5oflp4uTMQ+zTlPct28xqYF6LyrMyvI8XmhD31XupPA=; b=p6ryX8k72+nNaIyFO5Ik2/9tNEv61ywTjGwR4K4Gpyn0WtS2jVQhTMBz6WDC12gZrl iBgzZnV2At4ZlPhuOy6HS955SsZLH5o4tPHqy0Qx01BgMW/SyXOUvfl9BrH+NATWy5YB hc74N1eJQgubHp87Bc2myTfwVNb+Vuq5xXRJh6xGwVsHXkFgpXg3b+JY3/GeDrmu3+L0 1LINv4mCXl6gPwyAb954yZ0mVPh1U1jCFysmS+vv4hzDNXh7yt0fTTxgGxNzZUEjBeq7 T7ysi98RmqOwRIY9w9zTuMlwzwq1PCSEOv0dyON0D4gk7u4WnFcJYzTOFren1JOcOvrI T4gg== X-Gm-Message-State: AOJu0YyuJH2at0yg6XSAVe6z9ANVWnsYWuZMj8/1hn2Jo/S6MCNoYZRM jo74MrdHJ2Ca4oyl3Yum/kAvgTPYu5fdLNFYmu6Xvh4oYkE+cVoUyUl8areUFpqcfE0bUoWKr8I nOMY= X-Google-Smtp-Source: AGHT+IHKbJEO4mxYll/ngGw8TZ/3JTeEOuIS3/wlYGbQX2nGRR5oZxj+kMa6LEEypgFH5ZPyoURTrQ== X-Received: by 2002:a05:6512:694:b0:535:6baa:8c5d with SMTP id 2adb3069b0e04-539e54e8226mr12724719e87.20.1729154777982; Thu, 17 Oct 2024 01:46:17 -0700 (PDT) Received: from localhost.localdomain (78-27-76-97.bb.dnainternet.fi. [78.27.76.97]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-539fffa8e4asm706138e87.55.2024.10.17.01.46.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 01:46:16 -0700 (PDT) From: Mikko Rapeli To: openembedded-core@lists.openembedded.org Cc: Mikko Rapeli Subject: [PATCH v9 03/11] wic bootimg-efi.py: change UKI support from wic plugin to uki.bbclass Date: Thu, 17 Oct 2024 11:45:44 +0300 Message-ID: <20241017084552.182136-4-mikko.rapeli@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241017084552.182136-1-mikko.rapeli@linaro.org> References: <20241017084552.182136-1-mikko.rapeli@linaro.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 17 Oct 2024 08:46:23 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/205998 Remove custom wic plugin implementation and use systemd ukify reference implementation when generating UKI images. Fail if users still have create-unified-kernel-image in wic image config. uki.bbclass use is detected from IMAGE_CLASSES variable ("inherit uki" in image recipe) so export that to wic plugins. If UKI is used, then only generate a minimal loader config for systemd-boot which basically just sets a timeout. Also set 5 second timeout by default instead of failing if wic bootloader config is missing. Boot menu is generated at runtime based on UKI binaries found from ESP partition. Signed-off-by: Mikko Rapeli --- meta/classes-recipe/image_types_wic.bbclass | 3 +- scripts/lib/wic/plugins/source/bootimg-efi.py | 140 ++++-------------- 2 files changed, 27 insertions(+), 116 deletions(-) diff --git a/meta/classes-recipe/image_types_wic.bbclass b/meta/classes-recipe/image_types_wic.bbclass index 1fa016c16e..9a2996658a 100644 --- a/meta/classes-recipe/image_types_wic.bbclass +++ b/meta/classes-recipe/image_types_wic.bbclass @@ -15,6 +15,7 @@ WICVARS ?= "\ HOSTTOOLS_DIR \ IMAGE_BASENAME \ IMAGE_BOOT_FILES \ + IMAGE_CLASSES \ IMAGE_EFI_BOOT_FILES \ IMAGE_LINK_NAME \ IMAGE_ROOTFS \ @@ -113,7 +114,7 @@ WKS_FILE_DEPENDS_DEFAULT += "bmaptool-native cdrtools-native btrfs-tools-native WKS_FILE_DEPENDS_DEFAULT += "virtual/${TARGET_PREFIX}binutils" WKS_FILE_DEPENDS_BOOTLOADERS = "" WKS_FILE_DEPENDS_BOOTLOADERS:x86 = "syslinux grub-efi systemd-boot os-release" -WKS_FILE_DEPENDS_BOOTLOADERS:x86-64 = "syslinux grub-efi systemd-boot os-release" +WKS_FILE_DEPENDS_BOOTLOADERS:x86-64 = "syslinux systemd-boot os-release" WKS_FILE_DEPENDS_BOOTLOADERS:x86-x32 = "syslinux grub-efi" WKS_FILE_DEPENDS ??= "${WKS_FILE_DEPENDS_DEFAULT} ${WKS_FILE_DEPENDS_BOOTLOADERS}" diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py index d00f5428da..c05f38f229 100644 --- a/scripts/lib/wic/plugins/source/bootimg-efi.py +++ b/scripts/lib/wic/plugins/source/bootimg-efi.py @@ -125,8 +125,16 @@ class BootimgEFIPlugin(SourcePlugin): @classmethod def do_configure_systemdboot(cls, hdddir, creator, cr_workdir, source_params): """ - Create loader-specific systemd-boot/gummiboot config + Create loader-specific systemd-boot/gummiboot config. Unified Kernel Image (uki) + support is done in image recipe with uki.bbclass and only systemd-boot loader config + and ESP partition structure is created here. """ + # detect uki.bbclass usage + image_classes = get_bitbake_var("IMAGE_CLASSES").split() + unified_image = False + if "uki" in image_classes: + unified_image = True + install_cmd = "install -d %s/loader" % hdddir exec_cmd(install_cmd) @@ -134,19 +142,10 @@ class BootimgEFIPlugin(SourcePlugin): exec_cmd(install_cmd) bootloader = creator.ks.bootloader - - unified_image = source_params.get('create-unified-kernel-image') == "true" - loader_conf = "" - if not unified_image: - loader_conf += "default boot\n" - loader_conf += "timeout %d\n" % bootloader.timeout - initrd = source_params.get('initrd') - dtb = source_params.get('dtb') - - if not unified_image: - cls._copy_additional_files(hdddir, initrd, dtb) + # 5 seconds is a sensible default timeout + loader_conf += "timeout %d\n" % (bootloader.timeout or 5) logger.debug("Writing systemd-boot config " "%s/hdd/boot/loader/loader.conf", cr_workdir) @@ -155,8 +154,14 @@ class BootimgEFIPlugin(SourcePlugin): logger.debug("loader.conf:\n%s" % (loader_conf)) cfg.close() + initrd = source_params.get('initrd') + dtb = source_params.get('dtb') + if not unified_image: + cls._copy_additional_files(hdddir, initrd, dtb) + configfile = creator.ks.bootloader.configfile custom_cfg = None + boot_conf = "" if configfile: custom_cfg = get_custom_config(configfile) if custom_cfg: @@ -167,8 +172,7 @@ class BootimgEFIPlugin(SourcePlugin): else: raise WicError("configfile is specified but failed to " "get it from %s.", configfile) - - if not custom_cfg: + else: # Create systemd-boot configuration using parameters from wks file kernel = get_bitbake_var("KERNEL_IMAGETYPE") if get_bitbake_var("INITRAMFS_IMAGE_BUNDLE") == "1": @@ -178,7 +182,6 @@ class BootimgEFIPlugin(SourcePlugin): title = source_params.get('title') - boot_conf = "" boot_conf += "title %s\n" % (title if title else "boot") boot_conf += "linux /%s\n" % kernel @@ -203,6 +206,7 @@ class BootimgEFIPlugin(SourcePlugin): "%s/hdd/boot/loader/entries/boot.conf", cr_workdir) cfg = open("%s/hdd/boot/loader/entries/boot.conf" % cr_workdir, "w") cfg.write(boot_conf) + logger.debug("boot.conf:\n%s" % (boot_conf)) cfg.close() @@ -307,107 +311,13 @@ class BootimgEFIPlugin(SourcePlugin): (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME")) if source_params.get('create-unified-kernel-image') == "true": - initrd = source_params.get('initrd') - if not initrd: - raise WicError("initrd= must be specified when create-unified-kernel-image=true, exiting") - - deploy_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") - efi_stub = glob("%s/%s" % (deploy_dir, "linux*.efi.stub")) - if len(efi_stub) == 0: - raise WicError("Unified Kernel Image EFI stub not found, exiting") - efi_stub = efi_stub[0] - - with tempfile.TemporaryDirectory() as tmp_dir: - label = source_params.get('label') - label_conf = "root=%s" % creator.rootdev - if label: - label_conf = "LABEL=%s" % label - - bootloader = creator.ks.bootloader - cmdline = open("%s/cmdline" % tmp_dir, "w") - cmdline.write("%s %s" % (label_conf, bootloader.append)) - cmdline.close() + raise WicError("create-unified-kernel-image is no longer supported. Please use uki.bbclass.") - initrds = initrd.split(';') - initrd = open("%s/initrd" % tmp_dir, "wb") - for f in initrds: - with open("%s/%s" % (deploy_dir, f), 'rb') as in_file: - shutil.copyfileobj(in_file, initrd) - initrd.close() - - # Searched by systemd-boot: - # https://systemd.io/BOOT_LOADER_SPECIFICATION/#type-2-efi-unified-kernel-images - install_cmd = "install -d %s/EFI/Linux" % hdddir - exec_cmd(install_cmd) - - staging_dir_host = get_bitbake_var("STAGING_DIR_HOST") - target_sys = get_bitbake_var("TARGET_SYS") - - objdump_cmd = "%s-objdump" % target_sys - objdump_cmd += " -p %s" % efi_stub - objdump_cmd += " | awk '{ if ($1 == \"SectionAlignment\"){print $2} }'" - - ret, align_str = exec_native_cmd(objdump_cmd, native_sysroot) - align = int(align_str, 16) - - objdump_cmd = "%s-objdump" % target_sys - objdump_cmd += " -h %s | tail -2" % efi_stub - ret, output = exec_native_cmd(objdump_cmd, native_sysroot) - - offset = int(output.split()[2], 16) + int(output.split()[3], 16) - - osrel_off = offset + align - offset % align - osrel_path = "%s/usr/lib/os-release" % staging_dir_host - osrel_sz = os.stat(osrel_path).st_size - - cmdline_off = osrel_off + osrel_sz - cmdline_off = cmdline_off + align - cmdline_off % align - cmdline_sz = os.stat(cmdline.name).st_size - - dtb_off = cmdline_off + cmdline_sz - dtb_off = dtb_off + align - dtb_off % align - - dtb = source_params.get('dtb') - if dtb: - if ';' in dtb: - raise WicError("Only one DTB supported, exiting") - dtb_path = "%s/%s" % (deploy_dir, dtb) - dtb_params = '--add-section .dtb=%s --change-section-vma .dtb=0x%x' % \ - (dtb_path, dtb_off) - linux_off = dtb_off + os.stat(dtb_path).st_size - linux_off = linux_off + align - linux_off % align - else: - dtb_params = '' - linux_off = dtb_off - - linux_path = "%s/%s" % (staging_kernel_dir, kernel) - linux_sz = os.stat(linux_path).st_size - - initrd_off = linux_off + linux_sz - initrd_off = initrd_off + align - initrd_off % align - - # https://www.freedesktop.org/software/systemd/man/systemd-stub.html - objcopy_cmd = "%s-objcopy" % target_sys - objcopy_cmd += " --enable-deterministic-archives" - objcopy_cmd += " --preserve-dates" - objcopy_cmd += " --add-section .osrel=%s" % osrel_path - objcopy_cmd += " --change-section-vma .osrel=0x%x" % osrel_off - objcopy_cmd += " --add-section .cmdline=%s" % cmdline.name - objcopy_cmd += " --change-section-vma .cmdline=0x%x" % cmdline_off - objcopy_cmd += dtb_params - objcopy_cmd += " --add-section .linux=%s" % linux_path - objcopy_cmd += " --change-section-vma .linux=0x%x" % linux_off - objcopy_cmd += " --add-section .initrd=%s" % initrd.name - objcopy_cmd += " --change-section-vma .initrd=0x%x" % initrd_off - objcopy_cmd += " %s %s/EFI/Linux/linux.efi" % (efi_stub, hdddir) - - exec_native_cmd(objcopy_cmd, native_sysroot) - else: - if source_params.get('install-kernel-into-boot-dir') != 'false': - install_cmd = "install -v -p -m 0644 %s/%s %s/%s" % \ - (staging_kernel_dir, kernel, hdddir, kernel) - out = exec_cmd(install_cmd) - logger.debug("Installed kernel files:\n%s" % out) + if source_params.get('install-kernel-into-boot-dir') != 'false': + install_cmd = "install -v -p -m 0644 %s/%s %s/%s" % \ + (staging_kernel_dir, kernel, hdddir, kernel) + out = exec_cmd(install_cmd) + logger.debug("Installed kernel files:\n%s" % out) if get_bitbake_var("IMAGE_EFI_BOOT_FILES"): for src_path, dst_path in cls.install_task: From patchwork Thu Oct 17 08:45:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikko Rapeli X-Patchwork-Id: 50808 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id B454FD21251 for ; Thu, 17 Oct 2024 08:46:23 +0000 (UTC) Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by mx.groups.io with SMTP id smtpd.web11.44636.1729154782792200434 for ; Thu, 17 Oct 2024 01:46:23 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=L3R78bbc; spf=pass (domain: linaro.org, ip: 209.85.167.46, mailfrom: mikko.rapeli@linaro.org) Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-539e7e73740so600346e87.3 for ; Thu, 17 Oct 2024 01:46:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729154781; x=1729759581; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=70+o0ofg/OggCGxLvCGoOH5ETDurb+U98ellNhc2uhc=; b=L3R78bbcIiyJ3RQCFE9KB9Jdl+oIhzaKml2skATwdVC3f8rI8FCMRRoAZPbNvXKRZC n2tVJdeNeGigsay0rtdDgGZga1uG4rPo7LHqELyXudRyuxe/4dSgWNr7psVsS1w4uFfb q9OANMTyRtsQfuBotVBa0BT64pqEtgrN6Sxj+/vPGyjJIOpbbMlDoRsHSb5svvsRS3VJ P492Sav/EsFORwzNu9exH9DYJHFThXo2iPIgwEmQoKiWVZgzwhnsMl6ddrZNz9gDNEkp NBIeXv2/kHzJge+dMF5HgsSGlg5Scaeifby0vvENwn3sJFCYq8VvMwL2ZKqOTTxld/Cd XYnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729154781; x=1729759581; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=70+o0ofg/OggCGxLvCGoOH5ETDurb+U98ellNhc2uhc=; b=DsXtMGQNAfXqk8rw8x8LCz1zYGXEbekoLyxo7Ad0wlS0aYCBrsKKPJGZg709Q2Y+J+ swv6qCzgFYaio0pCUXYrAJX5MzOsZMritYaDLE4YScslDfMlF+Z9SiQ7tIEONSFcy0r7 VtK7ysvLRMmSvZ+aKH2aLAfOQOQhoYZyey9O4uHvvLkyEfqagn+0OPzTiUnwMyfSpjca eHamMEi698NexXiOdYL7Hc80CcE3oRmYaMgfYDvCpt8wAruSFGN8L9biZpFffkdXHGer 0pG3C03u+3ectn7k7cORio6Kiwmj5/7wTitheSwyUT2BU5QOyLpJdUfEQQiHdgVU2IvO z/0A== X-Gm-Message-State: AOJu0YyITQI3WacWaj6k11z52Tmo353Hrv/MdJk3L5B2hVft+aG58Yyc x9PxoG+t/nDL6UMMQ2NIEeFeLkw58Tq/Yn6C5PaP05/dgJBOZnkItFEC+tGXxsYCUpX3h20ghv5 t6aw= X-Google-Smtp-Source: AGHT+IGzlMY45l4H9MmCoYjwcAiV3++gDXcOilg1ffh0Ilvj3RYp3ijscjG1JV/MXOTOIUr3wQUdNg== X-Received: by 2002:a05:6512:6402:b0:539:e1c6:9d7f with SMTP id 2adb3069b0e04-539e1c69ec4mr11334155e87.25.1729154780801; Thu, 17 Oct 2024 01:46:20 -0700 (PDT) Received: from localhost.localdomain (78-27-76-97.bb.dnainternet.fi. [78.27.76.97]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-539fffa8e4asm706138e87.55.2024.10.17.01.46.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 01:46:20 -0700 (PDT) From: Mikko Rapeli To: openembedded-core@lists.openembedded.org Cc: Mikko Rapeli Subject: [PATCH v9 04/11] oeqa selftest uki.py: add tests for uki.bbclass Date: Thu, 17 Oct 2024 11:45:45 +0300 Message-ID: <20241017084552.182136-5-mikko.rapeli@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241017084552.182136-1-mikko.rapeli@linaro.org> References: <20241017084552.182136-1-mikko.rapeli@linaro.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 17 Oct 2024 08:46:23 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/205999 Tests builds and boots qemu into uki binary with systemd and sysvinit. Due to depedency to x86 specific ovmf UEFI firmware, tests are specific to x86 curently. UEFI firmware for ARM can be generated via qemuarm64-secureboot machine in meta-arm and similar tests on qemu will pass. Signed-off-by: Mikko Rapeli --- meta/lib/oeqa/selftest/cases/uki.py | 133 ++++++++++++++++++ .../wic/canned-wks/efi-uki-bootdisk.wks.in | 3 + 2 files changed, 136 insertions(+) create mode 100644 meta/lib/oeqa/selftest/cases/uki.py create mode 100644 scripts/lib/wic/canned-wks/efi-uki-bootdisk.wks.in diff --git a/meta/lib/oeqa/selftest/cases/uki.py b/meta/lib/oeqa/selftest/cases/uki.py new file mode 100644 index 0000000000..4121a094dc --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/uki.py @@ -0,0 +1,133 @@ +# Based on runqemu.py test file +# +# Copyright (c) 2017 Wind River Systems, Inc. +# +# SPDX-License-Identifier: MIT +# + +from oeqa.selftest.case import OESelftestTestCase +from oeqa.utils.commands import bitbake, runqemu, get_bb_var +from oeqa.core.decorator.data import skipIfNotArch +from oeqa.core.decorator import OETestTag +import oe.types + +class UkiTest(OESelftestTestCase): + """Boot Unified Kernel Image (UKI) generated with uki.bbclass on UEFI firmware (omvf/edk2)""" + + @skipIfNotArch(['i586', 'i686', 'x86_64']) + @OETestTag("runqemu") + def test_uki_boot_systemd(self): + """Build and boot into UEFI firmware (omvf/edk2), systemd-boot, initrd without systemd, rootfs with systemd""" + image = "core-image-minimal" + runqemu_params = get_bb_var('TEST_RUNQEMUPARAMS', image) or "" + cmd = "runqemu %s nographic serial wic ovmf" % (runqemu_params) + if oe.types.qemu_use_kvm(self.td.get('QEMU_USE_KVM', 0), self.td["TARGET_ARCH"]): + cmd += " kvm" + + self.write_config(""" +# efi firmware must load systemd-boot, not grub +EFI_PROVIDER = "systemd-boot" + +# image format must be wic, needs esp partition for firmware etc +IMAGE_FSTYPES:pn-%s:append = " wic" +WKS_FILE = "efi-uki-bootdisk.wks.in" + +# efi, uki and systemd features must be enabled +INIT_MANAGER = "systemd" +MACHINE_FEATURES:append = " efi" +IMAGE_CLASSES:append:pn-core-image-minimal = " uki" + +# uki embeds also an initrd +INITRAMFS_IMAGE = "core-image-minimal-initramfs" + +# runqemu must not load kernel separately, it's in the uki +QB_KERNEL_ROOT = "" +QB_DEFAULT_KERNEL = "none" + +# boot command line provided via uki, not via bootloader +UKI_CMDLINE = "rootwait root=LABEL=root console=${KERNEL_CONSOLE}" +""" % (image)) + + uki_filename = get_bb_var('UKI_FILENAME', image) + + bitbake(image + " ovmf") + with runqemu(image, ssh=False, launch_cmd=cmd) as qemu: + self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd) + + # Verify from efivars that firmware was: + # x86_64, qemux86_64, ovmf = edk2 + cmd = "echo $( cat /sys/firmware/efi/efivars/LoaderFirmwareInfo-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f ) | grep 'EDK II'" + status, output = qemu.run_serial(cmd) + self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) + + # Check that systemd-boot was the loader + cmd = "echo $( cat /sys/firmware/efi/efivars/LoaderInfo-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f ) | grep systemd-boot" + status, output = qemu.run_serial(cmd) + self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) + + # Check that systemd-stub was used + cmd = "echo $( cat /sys/firmware/efi/efivars/StubInfo-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f ) | grep systemd-stub" + status, output = qemu.run_serial(cmd) + self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) + + # Check that the compiled uki file was booted into + cmd = "echo $( cat /sys/firmware/efi/efivars/LoaderEntrySelected-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f ) | grep '%s'" % (uki_filename) + status, output = qemu.run_serial(cmd) + self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) + + @skipIfNotArch(['i586', 'i686', 'x86_64']) + @OETestTag("runqemu") + def test_uki_sysvinit(self): + """Build and boot into UEFI firmware (omvf/edk2), systemd-boot, initrd with sysvinit, rootfs with sysvinit""" + config = """ +# efi firmware must load systemd-boot, not grub +EFI_PROVIDER = "systemd-boot" + +# image format must be wic, needs esp partition for firmware etc +IMAGE_FSTYPES:pn-core-image-base:append = " wic" +WKS_FILE = "efi-uki-bootdisk.wks.in" + +# efi, uki and systemd features must be enabled +MACHINE_FEATURES:append = " efi" +DISTRO_FEATURES_NATIVE:append = " systemd" +IMAGE_CLASSES:append:pn-core-image-base = " uki" + +# uki embeds also an initrd, no systemd or udev +INITRAMFS_IMAGE = "core-image-initramfs-boot" + +# runqemu must not load kernel separately, it's in the uki +QB_KERNEL_ROOT = "" +QB_DEFAULT_KERNEL = "none" + +# boot command line provided via uki, not via bootloader +UKI_CMDLINE = "rootwait root=LABEL=root console=${KERNEL_CONSOLE}" + +""" + self.append_config(config) + bitbake('core-image-base ovmf') + runqemu_params = get_bb_var('TEST_RUNQEMUPARAMS', 'core-image-base') or "" + uki_filename = get_bb_var('UKI_FILENAME', 'core-image-base') + self.remove_config(config) + + with runqemu('core-image-base', ssh=False, + runqemuparams='%s slirp nographic ovmf' % (runqemu_params), image_fstype='wic') as qemu: + # Verify from efivars that firmware was: + # x86_64, qemux86_64, ovmf = edk2 + cmd = "echo $( cat /sys/firmware/efi/efivars/LoaderFirmwareInfo-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f ) | grep 'EDK II'" + status, output = qemu.run_serial(cmd) + self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) + + # Check that systemd-boot was the loader + cmd = "echo $( cat /sys/firmware/efi/efivars/LoaderInfo-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f ) | grep systemd-boot" + status, output = qemu.run_serial(cmd) + self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) + + # Check that systemd-stub was used + cmd = "echo $( cat /sys/firmware/efi/efivars/StubInfo-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f ) | grep systemd-stub" + status, output = qemu.run_serial(cmd) + self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) + + # Check that the compiled uki file was booted into + cmd = "echo $( cat /sys/firmware/efi/efivars/LoaderEntrySelected-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f ) | grep '%s'" % (uki_filename) + status, output = qemu.run_serial(cmd) + self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) diff --git a/scripts/lib/wic/canned-wks/efi-uki-bootdisk.wks.in b/scripts/lib/wic/canned-wks/efi-uki-bootdisk.wks.in new file mode 100644 index 0000000000..1ea9c8a845 --- /dev/null +++ b/scripts/lib/wic/canned-wks/efi-uki-bootdisk.wks.in @@ -0,0 +1,3 @@ +bootloader --ptable gpt --timeout=5 +part /boot --source bootimg-efi --sourceparams="loader=${EFI_PROVIDER}" --label boot --active --align 1024 --use-uuid --part-name="ESP" --part-type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B --fixed-size 512M +part / --source rootfs --fstype=ext4 --label root --align 1024 --exclude-path boot/ From patchwork Thu Oct 17 08:45:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikko Rapeli X-Patchwork-Id: 50812 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB4AAD21257 for ; Thu, 17 Oct 2024 08:46:33 +0000 (UTC) Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) by mx.groups.io with SMTP id smtpd.web10.43907.1729154785472472261 for ; Thu, 17 Oct 2024 01:46:25 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=SxsEJUrn; spf=pass (domain: linaro.org, ip: 209.85.167.43, mailfrom: mikko.rapeli@linaro.org) Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-539e8607c2aso857814e87.3 for ; Thu, 17 Oct 2024 01:46:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729154783; x=1729759583; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yHK/wJqit9EI4RDs5pqRkRsBKVbzpULM3hajdw6AHGY=; b=SxsEJUrnnBPpthbLAhAoQOJgPqhqrGCnxNjZUHB5KxkOHCCQlYGOwC0iHC3qxjFfu0 BgCe54irRzhiqhaynNf5PH0MzpkxJKf3nYQTSXp0QzyPteUXI3Bk1f37Kcy1nJH1EStP /9rBFVQwowOLGrSrFPgos2mg9GoYqs7YH0IHS+Ab+ELNCnzykbHOYYQDJfB6zMgLa9nv BRLH5mTgbcExVUCUBmLdqefd/bQwJAs2CIwPaozkWq9508+HQV6LCsq5QAnO0tupsfNx m1LU/tTgZFJvDgUzpQ8oM17oB3rykFWoYF6wqc+gYvknR7RGfjbf4bFzyQa1Ed7YgUze jzWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729154783; x=1729759583; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yHK/wJqit9EI4RDs5pqRkRsBKVbzpULM3hajdw6AHGY=; b=l/L2hyhzT5ZoK99ag3GVYyoJAYJQVaD/ZmFbYBk/fs6MwkSleTsoOY9ub/oGh5ueCI u+tNFDZHo8vv+xZME7/H/xA/DgVsZVTsyGhwxRqTDWvuTwncMBzMi0icTN+qkV8/+j6w RfMCRuUhfxJUYADR55aSdeoqgHdxtQBz8aqgzZidqzRTYj/rHpiTnsgburUynxFwhf59 GyuaG59oiYTg6ib3VCLcFoMVTnRgHWNYHbqPEOcPITF1bJ0uIUe2xaduWnFdX6TqAjDK ideyXC/8L3wJGcMDZnGCn5VGH7KWF4M1NTDpKQCMEEXb9GPIjXUhuHKO7rEQ7qLrcdIv uyiA== X-Gm-Message-State: AOJu0YynIGB1IbpshZWjpC/Cwm8S1ZDlfwvUcmqPVOUKXk5TXd98tjRF 6ZvtDINl9vR15Le/cSQ68mOXqHTsSdtYi5QKIkNfVVNuANZRg2sGUQZBSyReBr8LKprr8HXnaqj WbTM= X-Google-Smtp-Source: AGHT+IHoDyG5L3hmoo3YflPhuL5EcyC4S7AmOq+7dE6MgbyT/BumhrMP3GT3iAJQfgklvoKsa5RscA== X-Received: by 2002:a05:6512:15a5:b0:539:f607:1d2b with SMTP id 2adb3069b0e04-53a03f07230mr4549884e87.7.1729154783476; Thu, 17 Oct 2024 01:46:23 -0700 (PDT) Received: from localhost.localdomain (78-27-76-97.bb.dnainternet.fi. [78.27.76.97]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-539fffa8e4asm706138e87.55.2024.10.17.01.46.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 01:46:22 -0700 (PDT) From: Mikko Rapeli To: openembedded-core@lists.openembedded.org Cc: Mikko Rapeli Subject: [PATCH v9 05/11] oeqa selftest efibootpartition.py: add TEST_RUNQEMUPARAMS to runqemu Date: Thu, 17 Oct 2024 11:45:46 +0300 Message-ID: <20241017084552.182136-6-mikko.rapeli@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241017084552.182136-1-mikko.rapeli@linaro.org> References: <20241017084552.182136-1-mikko.rapeli@linaro.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 17 Oct 2024 08:46:33 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/206000 TEST_RUNQEMUPARAMS variable is used to add runqemu parameters like "slirp" networking. Support this also in selftests so that "slirp" networking can be used instead of the tun/tap devices setup which is easier to work with on shared build machines. Signed-off-by: Mikko Rapeli --- meta/lib/oeqa/selftest/cases/efibootpartition.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/efibootpartition.py b/meta/lib/oeqa/selftest/cases/efibootpartition.py index fa74103dec..e6d6a91a22 100644 --- a/meta/lib/oeqa/selftest/cases/efibootpartition.py +++ b/meta/lib/oeqa/selftest/cases/efibootpartition.py @@ -6,7 +6,7 @@ # from oeqa.selftest.case import OESelftestTestCase -from oeqa.utils.commands import bitbake, runqemu +from oeqa.utils.commands import bitbake, runqemu, get_bb_var from oeqa.core.decorator.data import skipIfNotMachine import oe.types @@ -14,10 +14,11 @@ class GenericEFITest(OESelftestTestCase): """EFI booting test class""" @skipIfNotMachine("qemux86-64", "test is qemux86-64 specific currently") def test_boot_efi(self): - cmd = "runqemu nographic serial wic ovmf" + image = "core-image-minimal" + runqemu_params = get_bb_var('TEST_RUNQEMUPARAMS', image) or "" + cmd = "runqemu %s nographic serial wic ovmf" % (runqemu_params) if oe.types.qemu_use_kvm(self.td.get('QEMU_USE_KVM', 0), self.td["TARGET_ARCH"]): cmd += " kvm" - image = "core-image-minimal" self.write_config(""" EFI_PROVIDER = "systemd-boot" From patchwork Thu Oct 17 08:45:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikko Rapeli X-Patchwork-Id: 50813 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9C88D21254 for ; Thu, 17 Oct 2024 08:46:33 +0000 (UTC) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by mx.groups.io with SMTP id smtpd.web11.44637.1729154788124351514 for ; Thu, 17 Oct 2024 01:46:28 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=Ql64/HzS; spf=pass (domain: linaro.org, ip: 209.85.167.47, mailfrom: mikko.rapeli@linaro.org) Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-539f84907caso859079e87.3 for ; Thu, 17 Oct 2024 01:46:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729154786; x=1729759586; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=V9V65r0HXKpZR9eOjIBLjsUByBDggRnmrGcQf/O+X80=; b=Ql64/HzSoF/y3VPwFvHB8rx+8NyFtN84AU+utencWnbYNk04zJqk0+MDdCBYrlz+3Z o/b1WPcgmFAvodod2zpJt3W/HJ7mnN8Nbq8R/AcgmC7v3EQ9sH0k33JKAfeKoUuGfMTX EhhkNkh4xnbK2a/xhYSjsNVkNLMwrrT4KZFOZpXR2b/siYLh3RSYFu5NGysVgUCDETc9 Qkdyr5/GLpQJBiKij7yTnz47UId3Y2hj/e+fm7x6VLc1nhv6sHNo/qlREu8ozLlphWxk 0bsnAb7ESv6P1apotBQjgJVvoH/xerKjzRWBWTqwkPG/I9IgNyJrOgsCw6VuP8ongNGg SrYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729154786; x=1729759586; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=V9V65r0HXKpZR9eOjIBLjsUByBDggRnmrGcQf/O+X80=; b=LoTd5TNexEn6xtqZ0EeLWRxgi2ANV3bYE4Gt18ls7/i1cQVB6fgO1skj+R5ZSzXHJ+ 4a36J+YEC/CtBehmuEZzAlp8Aahf+2ch82qcoQAcpJ//aj7oy27HrrulICKyRKX0+Kqh ++kI/Xfa2r1pJNhwZgGOiOfQulBQFroOVXp31mOEU7pujb16jpXENEo8uKV3yukxAMm9 BahQWU5pPJb9vRMoSokM8Qg94DURDFVfwNDfIpdNJHsqLwUAZHIjYGBHQ1RvVLdYYel5 J6DBu8Cd8NaWiaK7LbjWWw3PPbmU/k4tXaGBMwkpRZuCX+t7YQ373Qa4q8eNmeAQRg4J EwKw== X-Gm-Message-State: AOJu0YxShK4stMnLPldERSWKv0EJ6SpqyDhA+ZMRsHQ84CWrR1vgoktJ FIYXfIoVCPMgchs6aY04Dc759RC4DYtcoHZUTyjj8NoSZrF6CjTdhia69W2vj7ToclmGxV0oTxg jfdg= X-Google-Smtp-Source: AGHT+IG46ge1AakYY4ZxtDoveU41yWBrhlLVFEjoNcE0iwkdCVl+Gn9U2r23yUfssE3k1pK/knLvHw== X-Received: by 2002:a05:6512:1256:b0:536:7a88:6185 with SMTP id 2adb3069b0e04-53a03f185c1mr4156309e87.15.1729154786182; Thu, 17 Oct 2024 01:46:26 -0700 (PDT) Received: from localhost.localdomain (78-27-76-97.bb.dnainternet.fi. [78.27.76.97]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-539fffa8e4asm706138e87.55.2024.10.17.01.46.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 01:46:25 -0700 (PDT) From: Mikko Rapeli To: openembedded-core@lists.openembedded.org Cc: Mikko Rapeli Subject: [PATCH v9 06/11] oeqa selftest efibootpartition.py: remove systemd-boot from grub-efi test Date: Thu, 17 Oct 2024 11:45:47 +0300 Message-ID: <20241017084552.182136-7-mikko.rapeli@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241017084552.182136-1-mikko.rapeli@linaro.org> References: <20241017084552.182136-1-mikko.rapeli@linaro.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 17 Oct 2024 08:46:33 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/206001 The test is actually using grub-efi not systemd-boot so remove it completely. systemd-boot will be tested via uki.py tests. Signed-off-by: Mikko Rapeli --- meta/lib/oeqa/selftest/cases/efibootpartition.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/efibootpartition.py b/meta/lib/oeqa/selftest/cases/efibootpartition.py index e6d6a91a22..fcfcdaf7e4 100644 --- a/meta/lib/oeqa/selftest/cases/efibootpartition.py +++ b/meta/lib/oeqa/selftest/cases/efibootpartition.py @@ -21,11 +21,11 @@ class GenericEFITest(OESelftestTestCase): cmd += " kvm" self.write_config(""" -EFI_PROVIDER = "systemd-boot" +EFI_PROVIDER = "grub-efi" IMAGE_FSTYPES:pn-%s:append = " wic" MACHINE_FEATURES:append = " efi" WKS_FILE = "efi-bootdisk.wks.in" -IMAGE_INSTALL:append = " grub-efi systemd-boot kernel-image-bzimage" +IMAGE_INSTALL:append = " grub-efi kernel-image-bzimage" """ % (image)) From patchwork Thu Oct 17 08:45:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikko Rapeli X-Patchwork-Id: 50814 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1F83D21258 for ; Thu, 17 Oct 2024 08:46:33 +0000 (UTC) Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by mx.groups.io with SMTP id smtpd.web11.44639.1729154792098702163 for ; Thu, 17 Oct 2024 01:46:32 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=N4rmnC7N; spf=pass (domain: linaro.org, ip: 209.85.167.46, mailfrom: mikko.rapeli@linaro.org) Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-539f58c68c5so1111813e87.3 for ; Thu, 17 Oct 2024 01:46:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729154790; x=1729759590; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YMQTWSW2pxYCYeqvg5XPpJ4xKvMr/05hM5ADcPNUguk=; b=N4rmnC7NgKhCrFDUaCvMjyJzQFmBbsmDXJqcxdlyZgg5cadnU96CSTUw1fN3BrenwD hl6y/R4eCiShDDOtlaDsoXTtJZEA8QIcXAKd8fO6vqRNkeRc/OMPwr65Q4BqS96s+qZf EBKHaHOS5HCuhZDMSKxe41WAu8KYbrLLcuda6EsKr9WYSJqH5+6PHbfUtG2IPFSt4b1h j0VeS/zbKMpIR+IeC0Zena1cnq+85LofrlxZcCDHO35CPRYvUpsL6LiYmQGSsh002bPm sR8AA63whAKrEgWctm01mCKZ9FUIHrSuanaO+MmKNkBViZ7LJaJ/nIw6zHHH8Iz9IZFJ IwlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729154790; x=1729759590; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YMQTWSW2pxYCYeqvg5XPpJ4xKvMr/05hM5ADcPNUguk=; b=oLBuGFOA2N7Ck/VPmXHO4duuPIFQy1O8RZ/ZAWO2aSsjaFICulb7rFj4O2UfQFTYPj RI+fdI8FmTv4sGXuz1y6f2DMWNNtTgkrBHFTqJDjKY0pVQiIiQkePyp9I8eoZmx/ULi8 YpF1icYgeBuRsA9nXwcafPBBhuK6yiHcxvH/eSI1rT5/72rQSpeKnVPhDtYRiYs/JzHh zsjBsssmDbCvdMHFOHW1CN1i2t86D7QtDIFgiA25vfICUVFHbi0mHAKd38iR3bfcF/Bp /IHjfqL8XpAlZEmfXWGkgxGWsQwCJN5YzS5BxLe+qvnqshhcH78mPtTFzypi/a4bQMFg y6Eg== X-Gm-Message-State: AOJu0Yz7PDlHcbCPmX5Ci8OutGgfMoqk1we7xi6qQeP5lz8xnwYL+sl3 Y+9yX9kEIcb6Rf2Q0yqnzJZCb/THBpTta90eveMkTgNiESv9GTIOQu+pYJ1bXiscCaVNioKsx9S k+fA= X-Google-Smtp-Source: AGHT+IHOr8J8bQJYHDNUqmVg5Rp1mSJLqO8qp9envQzVhG0Ciw1WMR3QnuQIX8h1df2gf/6e+jD3ng== X-Received: by 2002:a05:6512:2398:b0:536:741a:6bc5 with SMTP id 2adb3069b0e04-539e54d6122mr13780832e87.12.1729154790090; Thu, 17 Oct 2024 01:46:30 -0700 (PDT) Received: from localhost.localdomain (78-27-76-97.bb.dnainternet.fi. [78.27.76.97]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-539fffa8e4asm706138e87.55.2024.10.17.01.46.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 01:46:28 -0700 (PDT) From: Mikko Rapeli To: openembedded-core@lists.openembedded.org Cc: Mikko Rapeli Subject: [PATCH v9 07/11] oeqa selftest wic.py: add TEST_RUNQEMUPARAMS to runqemu Date: Thu, 17 Oct 2024 11:45:48 +0300 Message-ID: <20241017084552.182136-8-mikko.rapeli@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241017084552.182136-1-mikko.rapeli@linaro.org> References: <20241017084552.182136-1-mikko.rapeli@linaro.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 17 Oct 2024 08:46:33 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/206002 To support "slirp" networking on shared build machines instead of tun/tap devices. Users can set TEST_RUNQEMUPARAMS = "slirp" in their build/conf/local.conf to run selftests using "slirp" networking. The same works for testimage.bbclass and oeqa runtime tests. Signed-off-by: Mikko Rapeli --- meta/lib/oeqa/selftest/cases/wic.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py index b616759209..f2a46c965b 100644 --- a/meta/lib/oeqa/selftest/cases/wic.py +++ b/meta/lib/oeqa/selftest/cases/wic.py @@ -939,7 +939,8 @@ class Wic2(WicTestCase): bitbake('wic-image-minimal') self.remove_config(config) - with runqemu('wic-image-minimal', ssh=False, runqemuparams='nographic') as qemu: + runqemu_params = get_bb_var('TEST_RUNQEMUPARAMS', 'wic-image-minimal') or "" + with runqemu('wic-image-minimal', ssh=False, runqemuparams='%s nographic' % (runqemu_params)) as qemu: cmd = "mount | grep '^/dev/' | cut -f1,3 -d ' ' | egrep -c -e '/dev/sda1 /boot' " \ "-e '/dev/root /|/dev/sda2 /' -e '/dev/sda3 /media' -e '/dev/sda4 /mnt'" status, output = qemu.run_serial(cmd) @@ -959,8 +960,9 @@ class Wic2(WicTestCase): bitbake('core-image-minimal ovmf') self.remove_config(config) + runqemu_params = get_bb_var('TEST_RUNQEMUPARAMS', 'core-image-minimal') or "" with runqemu('core-image-minimal', ssh=False, - runqemuparams='nographic ovmf', image_fstype='wic') as qemu: + runqemuparams='%s nographic ovmf' % (runqemu_params), image_fstype='wic') as qemu: cmd = "grep sda. /proc/partitions |wc -l" status, output = qemu.run_serial(cmd) self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) @@ -1154,8 +1156,9 @@ class Wic2(WicTestCase): bitbake('core-image-minimal-mtdutils') self.remove_config(config) + runqemu_params = get_bb_var('TEST_RUNQEMUPARAMS', 'core-image-minimal-mtdutils') or "" with runqemu('core-image-minimal-mtdutils', ssh=False, - runqemuparams='nographic', image_fstype='wic') as qemu: + runqemuparams='%s nographic' % (runqemu_params), image_fstype='wic') as qemu: cmd = "grep sda. /proc/partitions |wc -l" status, output = qemu.run_serial(cmd) self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) @@ -1214,8 +1217,9 @@ class Wic2(WicTestCase): bitbake('core-image-minimal') self.remove_config(config) + runqemu_params = get_bb_var('TEST_RUNQEMUPARAMS', 'core-image-minimal') or "" with runqemu('core-image-minimal', ssh=False, - runqemuparams='nographic', image_fstype='wic') as qemu: + runqemuparams='%s nographic' % (runqemu_params), image_fstype='wic') as qemu: # Check that we have ONLY two /dev/sda* partitions (/boot and /) cmd = "grep sda. /proc/partitions | wc -l" status, output = qemu.run_serial(cmd) @@ -1446,8 +1450,8 @@ class Wic2(WicTestCase): os.rename(image_path, image_path + '.bak') os.rename(new_image_path, image_path) - # Check if it boots in qemu - with runqemu('core-image-minimal', ssh=False, runqemuparams='nographic') as qemu: + runqemu_params = get_bb_var('TEST_RUNQEMUPARAMS', 'core-image-minimal') or "" + with runqemu('core-image-minimal', ssh=False, runqemuparams='%s nographic' % (runqemu_params)) as qemu: cmd = "ls /etc/" status, output = qemu.run_serial('true') self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) From patchwork Thu Oct 17 08:45:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikko Rapeli X-Patchwork-Id: 50816 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id B82FCD21259 for ; Thu, 17 Oct 2024 08:46:43 +0000 (UTC) Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) by mx.groups.io with SMTP id smtpd.web11.44640.1729154793610705446 for ; Thu, 17 Oct 2024 01:46:34 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=aJYJ7CPN; spf=pass (domain: linaro.org, ip: 209.85.167.52, mailfrom: mikko.rapeli@linaro.org) Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-539fbbadf83so864491e87.0 for ; Thu, 17 Oct 2024 01:46:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729154792; x=1729759592; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IuHZkcVcAaiLuaoJ73avrDUIOctbKKNU1Fk6MO4D/ew=; b=aJYJ7CPNncpkBwK2JPDySMlwG6D3tLUcLQ2uNte7uv4otwh6e+oFVCIIlwOZET9ICX bvOf03MYQOb9nLaKhWR2spR2JCOBxHwVy2fLZdgl2QmqwD95oL2bgWFtFsLeC4hSCT++ ml9BOpzathvR72SRUWRIENNlLVL1JTD5aeNPLMbbTEofWSt8MWGH77lELwVB3HM1VSj1 cCkhKGf7XFuGQ7SkpyCOdFFG/KKjbJrQc6NKGpvnOZKkPXU5BzCIW6fYuQ9IiZKmV19X sZjDuULUHrkIll5veiDV42ocBtDho8sQnwB2/257HybgeiUPxTaGox3R6YhrYkhoaMru 7+8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729154792; x=1729759592; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IuHZkcVcAaiLuaoJ73avrDUIOctbKKNU1Fk6MO4D/ew=; b=kvCfF/8McekKjh6jWZBxi5Q0hsZZJsIiY25y2SfJO1YzWqHHJZWqvl5hh07HHKUkE3 NBe6cdHcXtB9urENAzYXDQwU9wLib/nvP7Fk99KFaueBls0Hb0JDZby8407K4IoknUn5 iktvjW/0GF8ltkDm2bGIZp3+dNGCtyWfE/PmXOgQIeAzXTroOCemR081yavowUgQc1oc 49yNXISlzKusHq9R8Inw4jxwSvN6UzW/hpGilmqiWgnNtN+YDJF8dex3d95OqspFfd5O QfITWdgE3610GMcBobroC1i0luRmCOMrkj8srqKujY3cDeRRlWax1g6oXV1KfKs9WZqA zEWg== X-Gm-Message-State: AOJu0YzSNmBJuKMGC/tYJvRX9jVdpTfA6w/n6ui9RPc9CuhEAUuKoF0Y tbILr8+gkyLaYcXSRUhd+MO/WC0p/2cg16wbQwNXFgQ8lDT/nTBw8BFSB/mQfFOA4rzkgQanQkE o5hw= X-Google-Smtp-Source: AGHT+IEVJrq+RPMUpD3rYv8DQwxM+tU1ujpYlE2EDP4JAtN/z7S4lJM+oylAYPovD1sDFcksf9EFoQ== X-Received: by 2002:a05:6512:3b0b:b0:539:f2f6:c6fe with SMTP id 2adb3069b0e04-539f2f6c9a6mr6462623e87.16.1729154791671; Thu, 17 Oct 2024 01:46:31 -0700 (PDT) Received: from localhost.localdomain (78-27-76-97.bb.dnainternet.fi. [78.27.76.97]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-539fffa8e4asm706138e87.55.2024.10.17.01.46.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 01:46:31 -0700 (PDT) From: Mikko Rapeli To: openembedded-core@lists.openembedded.org Cc: Mikko Rapeli Subject: [PATCH v9 08/11] oeqa selftest wic.py: support UKIs via uki.bbclass Date: Thu, 17 Oct 2024 11:45:49 +0300 Message-ID: <20241017084552.182136-9-mikko.rapeli@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241017084552.182136-1-mikko.rapeli@linaro.org> References: <20241017084552.182136-1-mikko.rapeli@linaro.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 17 Oct 2024 08:46:43 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/206003 Use label to detect rootfs since UKI with kernel command line is generated before rootfs is generated by wic. Adapt wic tests to build and boot uki.bbclass generated UKIs. Keeping one UKI test in wic.py and rest of the UKI features are tested with dedicated uki.py test. Add plain non-UKI systemd-boot tests to wic suite for aarch64 and x86. Signed-off-by: Mikko Rapeli --- meta-selftest/wic/test_efi_plugin.wks | 5 +- .../test_efi_plugin_plain_systemd-boot.wks | 5 + meta/lib/oeqa/selftest/cases/wic.py | 115 ++++++++++++++++-- 3 files changed, 110 insertions(+), 15 deletions(-) create mode 100644 meta-selftest/wic/test_efi_plugin_plain_systemd-boot.wks diff --git a/meta-selftest/wic/test_efi_plugin.wks b/meta-selftest/wic/test_efi_plugin.wks index 1603d6c4bb..e876a4be0e 100644 --- a/meta-selftest/wic/test_efi_plugin.wks +++ b/meta-selftest/wic/test_efi_plugin.wks @@ -1,6 +1,5 @@ # short-description: This file is used in oe-selftest wic module to test efi plugin - -part /boot --source bootimg-efi --sourceparams="loader=systemd-boot,create-unified-kernel-image=true,initrd=${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES}" --active --align 1024 --use-uuid -part / --source rootfs --fstype=ext4 --align 1024 --use-uuid +part /boot --source bootimg-efi --sourceparams="loader=systemd-boot" --active --align 1024 --use-uuid +part / --source rootfs --fstype=ext4 --align 1024 --use-uuid --label root bootloader --timeout=0 --append="console=ttyS0,115200n8" diff --git a/meta-selftest/wic/test_efi_plugin_plain_systemd-boot.wks b/meta-selftest/wic/test_efi_plugin_plain_systemd-boot.wks new file mode 100644 index 0000000000..2745c19e85 --- /dev/null +++ b/meta-selftest/wic/test_efi_plugin_plain_systemd-boot.wks @@ -0,0 +1,5 @@ +# short-description: This file is used in oe-selftest wic module to test efi plugin +part /boot --source bootimg-efi --sourceparams="loader=systemd-boot,initrd=${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES}" --active --align 1024 --use-uuid +part / --source rootfs --fstype=ext4 --align 1024 --use-uuid + +bootloader --timeout=0 --append="console=ttyS0,115200n8" diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py index f2a46c965b..e5caef74c4 100644 --- a/meta/lib/oeqa/selftest/cases/wic.py +++ b/meta/lib/oeqa/selftest/cases/wic.py @@ -1292,24 +1292,46 @@ class Wic2(WicTestCase): @skipIfNotArch(['i586', 'i686', 'x86_64']) @OETestTag("runqemu") def test_efi_plugin_unified_kernel_image_qemu(self): - """Test efi plugin's Unified Kernel Image feature in qemu""" - config = 'IMAGE_FSTYPES = "wic"\n'\ - 'INITRAMFS_IMAGE = "core-image-minimal-initramfs"\n'\ - 'WKS_FILE = "test_efi_plugin.wks"\n'\ - 'MACHINE_FEATURES:append = " efi"\n' + """Test Unified Kernel Image feature in qemu without systemd in initramfs or rootfs""" + config = """ +# efi firmware must load systemd-boot, not grub +EFI_PROVIDER = "systemd-boot" + +# image format must be wic, needs esp partition for firmware etc +IMAGE_FSTYPES:pn-core-image-base:append = " wic" +WKS_FILE = "test_efi_plugin.wks" + +# efi, uki and systemd features must be enabled +MACHINE_FEATURES:append = " efi" +DISTRO_FEATURES_NATIVE:append = " systemd" +IMAGE_CLASSES:append:pn-core-image-base = " uki" + +# uki embeds also an initrd, no systemd or udev +INITRAMFS_IMAGE = "core-image-initramfs-boot" + +# runqemu must not load kernel separately, it's in the uki +QB_KERNEL_ROOT = "" +QB_DEFAULT_KERNEL = "none" + +# boot command line provided via uki, not via bootloader +UKI_CMDLINE = "rootwait root=LABEL=root console=${KERNEL_CONSOLE}" + +""" self.append_config(config) - bitbake('core-image-minimal core-image-minimal-initramfs ovmf') + bitbake('core-image-base ovmf') + runqemu_params = get_bb_var('TEST_RUNQEMUPARAMS', 'core-image-base') or "" + uki_filename = get_bb_var('UKI_FILENAME', 'core-image-base') self.remove_config(config) - with runqemu('core-image-minimal', ssh=False, - runqemuparams='nographic ovmf', image_fstype='wic') as qemu: - # Check that /boot has EFI bootx64.efi (required for EFI) - cmd = "ls /boot/EFI/BOOT/bootx64.efi | wc -l" + with runqemu('core-image-base', ssh=False, + runqemuparams='%s nographic ovmf' % (runqemu_params), image_fstype='wic') as qemu: + # Check that /boot has EFI boot*.efi (required for EFI) + cmd = "ls /boot/EFI/BOOT/boot*.efi | wc -l" status, output = qemu.run_serial(cmd) self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) self.assertEqual(output, '1') - # Check that /boot has EFI/Linux/linux.efi (required for Unified Kernel Images auto detection) - cmd = "ls /boot/EFI/Linux/linux.efi | wc -l" + # Check that /boot has EFI/Linux/${UKI_FILENAME} (required for Unified Kernel Images auto detection) + cmd = "ls /boot/EFI/Linux/%s | wc -l" % (uki_filename) status, output = qemu.run_serial(cmd) self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) self.assertEqual(output, '1') @@ -1319,6 +1341,75 @@ class Wic2(WicTestCase): self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) self.assertEqual(output, '0') + @skipIfNotArch(['aarch64']) + @OETestTag("runqemu") + def test_efi_plugin_plain_systemd_boot_qemu_aarch64(self): + """Test plain systemd-boot in qemu with systemd""" + config = """ +INIT_MANAGER = "systemd" +EFI_PROVIDER = "systemd-boot" + +# image format must be wic, needs esp partition for firmware etc +IMAGE_FSTYPES:pn-core-image-base:append = " wic" +WKS_FILE = "test_efi_plugin_plain_systemd-boot.wks" + +INITRAMFS_IMAGE = "core-image-initramfs-boot" + +# to configure runqemu +IMAGE_CLASSES += "qemuboot" +# u-boot efi firmware +QB_DEFAULT_BIOS = "u-boot.bin" +# need to use virtio, scsi not supported by u-boot by default +QB_DRIVE_TYPE = "/dev/vd" +""" + self.append_config(config) + bitbake('core-image-base u-boot') + runqemu_params = get_bb_var('TEST_RUNQEMUPARAMS', 'core-image-base') or "" + self.remove_config(config) + + with runqemu('core-image-base', ssh=False, + runqemuparams='%s nographic' % (runqemu_params), image_fstype='wic') as qemu: + # Check that /boot has EFI boot*.efi (required for EFI) + cmd = "ls /boot/EFI/BOOT/boot*.efi | wc -l" + status, output = qemu.run_serial(cmd) + self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) + self.assertEqual(output, '1') + # Check that boot.conf exists + cmd = "cat /boot/loader/entries/boot.conf" + status, output = qemu.run_serial(cmd) + self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) + + @skipIfNotArch(['i586', 'i686', 'x86_64']) + @OETestTag("runqemu") + def test_efi_plugin_plain_systemd_boot_qemu_x86(self): + """Test plain systemd-boot to systemd in qemu""" + config = """ +INIT_MANAGER = "systemd" +EFI_PROVIDER = "systemd-boot" + +# image format must be wic, needs esp partition for firmware etc +IMAGE_FSTYPES:pn-core-image-base:append = " wic" +WKS_FILE = "test_efi_plugin_plain_systemd-boot.wks" + +INITRAMFS_IMAGE = "core-image-initramfs-boot" +""" + self.append_config(config) + bitbake('core-image-base ovmf') + runqemu_params = get_bb_var('TEST_RUNQEMUPARAMS', 'core-image-base') or "" + self.remove_config(config) + + with runqemu('core-image-base', ssh=False, + runqemuparams='%s nographic ovmf' % (runqemu_params), image_fstype='wic') as qemu: + # Check that /boot has EFI boot*.efi (required for EFI) + cmd = "ls /boot/EFI/BOOT/boot*.efi | wc -l" + status, output = qemu.run_serial(cmd) + self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) + self.assertEqual(output, '1') + # Check that boot.conf exists + cmd = "cat /boot/loader/entries/boot.conf" + status, output = qemu.run_serial(cmd) + self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) + def test_fs_types(self): """Test filesystem types for empty and not empty partitions""" img = 'core-image-minimal' From patchwork Thu Oct 17 08:45:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikko Rapeli X-Patchwork-Id: 50817 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF792D21256 for ; Thu, 17 Oct 2024 08:46:43 +0000 (UTC) Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) by mx.groups.io with SMTP id smtpd.web11.44643.1729154796443952258 for ; Thu, 17 Oct 2024 01:46:36 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=EL4EvREd; spf=pass (domain: linaro.org, ip: 209.85.167.45, mailfrom: mikko.rapeli@linaro.org) Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-5366fd6fdf1so1064454e87.0 for ; Thu, 17 Oct 2024 01:46:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729154794; x=1729759594; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HGowovRpI9OoBujIbFQ6uvGwQWkQpRZ1xyRDNvdq1/w=; b=EL4EvREd9KYy6C2OhdLIFYXKFL99FGtzkgKP03IQKGBfY5axb5OVjZA5JwcPih5RJ8 od0nlIcHlUL4N6r1yvmMRe5tGbICgJ/f7TH/vPTuLLcJQg5inrPNW5w6AAZQZsxsdekM AEnrR40N6EWL0/htm8TGeQAVqQu8kvpF2TSoMT3joq0emVV2fqO1xgid6Jo72LvKN/my srEY3cyimj7Dg4qVk0QAsdu5ELu+JUPLAD7D438D/JIAglq3y/PexxOsTaqN4FN37jas qF0uj7PEMgFRFfW1O7HoB73NDPagnGzayz54MZbNevpy1j4m9o0YJUxOSbn3986+Ncsz OoNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729154794; x=1729759594; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HGowovRpI9OoBujIbFQ6uvGwQWkQpRZ1xyRDNvdq1/w=; b=HQ6+hZVoxHZBB0SZHwRn2c5kAY/VTyY6iHnk1407S3OoxRxmuJ+wUUu8/qT/9tEIDx Hq6JeHnglsK4ru0UKb3cgxx4IaaQ67q5jQOmSidwiQ8UivTTBLmOT8qzceEj1G4WeCeP uIywb/6oB/DymtNxWboHTVxFfVoj+GFvcrZLayXZ4FLZY6fP1xYHY8EJlLQ9xPQZapju ENWf04li4NKwV1SPcTNkpUcRZwQ6lNUUwfO9AzFN/ZaH74KSduso1kEpZbgBm7wQ8wON EjXSXICcVBC/+1uqkkfBUjLX8BDZ4d35Px0oeJKe69RkGeglBU663/qvDVrot4Dx06p+ qMqw== X-Gm-Message-State: AOJu0YwBZaQJTH43ZXhdSuNzG5uF6GB/0WzjnMdgQWLHET2SPW7zYziF 43X3EYr8+K18qqU/WiN70+0FnVtxEm04AKIRDXXN3K0QXncp1+3jEpq7PQnZVHu9j5BdbQxx+HY G0L4= X-Google-Smtp-Source: AGHT+IG9pDqBKDH+WqUkU2aLtZAtu7FRzeWlRdif87EOpdDN0FeT9Ffn8len4+aZFq0HT7HFBYigQA== X-Received: by 2002:a05:6512:3083:b0:52c:9383:4c16 with SMTP id 2adb3069b0e04-53a03f193a0mr4561693e87.22.1729154794382; Thu, 17 Oct 2024 01:46:34 -0700 (PDT) Received: from localhost.localdomain (78-27-76-97.bb.dnainternet.fi. [78.27.76.97]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-539fffa8e4asm706138e87.55.2024.10.17.01.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 01:46:33 -0700 (PDT) From: Mikko Rapeli To: openembedded-core@lists.openembedded.org Cc: Mikko Rapeli Subject: [PATCH v9 09/11] oeqa data.py: add skipIfNotBuildArch decorator Date: Thu, 17 Oct 2024 11:45:50 +0300 Message-ID: <20241017084552.182136-10-mikko.rapeli@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241017084552.182136-1-mikko.rapeli@linaro.org> References: <20241017084552.182136-1-mikko.rapeli@linaro.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 17 Oct 2024 08:46:43 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/206004 Now tests can be limited to specific build machine architectures like x86_64 or aarch64. Needed for tests which work on x86_64 but currently fail on aarch64 build machines. Signed-off-by: Mikko Rapeli --- meta/lib/oeqa/core/decorator/data.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/meta/lib/oeqa/core/decorator/data.py b/meta/lib/oeqa/core/decorator/data.py index 5444b2cb75..0daf46334f 100644 --- a/meta/lib/oeqa/core/decorator/data.py +++ b/meta/lib/oeqa/core/decorator/data.py @@ -228,3 +228,15 @@ class skipIfNotArch(OETestDecorator): arch = self.case.td['HOST_ARCH'] if arch not in self.archs: self.case.skipTest('Test skipped on %s' % arch) + +@registerDecorator +class skipIfNotBuildArch(OETestDecorator): + """ + Skip test if BUILD_ARCH is not present in the tuple specified. + """ + + attrs = ('archs',) + def setUpDecorator(self): + arch = self.case.td['BUILD_ARCH'] + if arch not in self.archs: + self.case.skipTest('Test skipped on %s' % arch) From patchwork Thu Oct 17 08:45:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikko Rapeli X-Patchwork-Id: 50818 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C63C7D2125A for ; Thu, 17 Oct 2024 08:46:43 +0000 (UTC) Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by mx.groups.io with SMTP id smtpd.web10.43909.1729154798086477101 for ; Thu, 17 Oct 2024 01:46:38 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=nZi4qPd8; spf=pass (domain: linaro.org, ip: 209.85.167.49, mailfrom: mikko.rapeli@linaro.org) Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-539e13375d3so768199e87.3 for ; Thu, 17 Oct 2024 01:46:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729154796; x=1729759596; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t9LeoT1E2wZPPInwpRJvXgrNhfKHRw6qkNxEF+VzWns=; b=nZi4qPd8qlT33Wai8BN17HVgDwJWf901Ypxf1tqhQgcSQUzbAeb5vpTzWya8RGRqxL tm8c61krXzD90ZYvukKwDSf/MDfW+IoN2J7HysLR6E0/nvtBHzsDmU2gyhCaAyl06b9+ IvoBKnPVTFOAdeaT/CNFB/NDhA+Pij1552svxYm1flmxM2xnqkZgApPTp+asajkOBOKq YR0mjQO72BQT8C2LxYKugvnrzC2FOZN2xwZn4+YDX+GmW9hnuVdjBMbw7DvVLbUVb5w3 Gg62CFcPlXEhHhTzk3MEsfXsmVEEiOfw+cH4bXgFNCePMW8tbQgIa+FpDVf5fqHoIPsi 4KSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729154796; x=1729759596; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t9LeoT1E2wZPPInwpRJvXgrNhfKHRw6qkNxEF+VzWns=; b=RuYuqmAf03lU5D7XTYLzabspwhkXKAQNHBgw9OdHE09i3TDeyvbsAyXCReeR1u8uQk dMemuWvjnJr8v+maWMbOXV6CLIC7mED3rFePYpr/MVJzBjTTx71LV5//encj/92frKSX t9kflCf9jZq86uSGac+KOH0FdI6bWeucaae4zIisZj4QF+CYen9IroOCF7m5zP8IX0YU uCREkc1zxgGgQdTwNs3yWysyVe5nPOFnTLa53/Oggzxjmdoxdry/cQ+RXD6AZxwK7mvw GzoRWFDCrHNcT56EjhPo5ITSa6mg72QCKrzm9bELkeu7O9ACziXlH7PfrDP8lmwLC4Zo B/FA== X-Gm-Message-State: AOJu0Yxl10zKW8NMMFQJww6up14jbXHJes+THOyXLuxnGwQZaU9W633F 7zPkjMkvlWqpm+zam8sBa+PAKA12KSfhMegPw1t1Lc4fUAb3Vk1NLJN/DI2fnfDk6WBGrfLWgAl UQmk= X-Google-Smtp-Source: AGHT+IHrkhK++JYCYxCMAOWQ+Y64VaBrsGCEfgqN/sNYNcnX30uWdIANIaEJ7CwIEWknl6Y+nscOWA== X-Received: by 2002:a05:6512:2350:b0:539:f7ab:e161 with SMTP id 2adb3069b0e04-539f7abe40bmr7361880e87.45.1729154796044; Thu, 17 Oct 2024 01:46:36 -0700 (PDT) Received: from localhost.localdomain (78-27-76-97.bb.dnainternet.fi. [78.27.76.97]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-539fffa8e4asm706138e87.55.2024.10.17.01.46.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 01:46:35 -0700 (PDT) From: Mikko Rapeli To: openembedded-core@lists.openembedded.org Cc: Mikko Rapeli Subject: [PATCH v9 10/11] oeqa selftest wic.py: mark efi tests to run on x86_64 build host only Date: Thu, 17 Oct 2024 11:45:51 +0300 Message-ID: <20241017084552.182136-11-mikko.rapeli@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241017084552.182136-1-mikko.rapeli@linaro.org> References: <20241017084552.182136-1-mikko.rapeli@linaro.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 17 Oct 2024 08:46:43 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/206005 aarch64 build host fails to boot aarch64 qemu target with u-boot uefi firmware currently. Signed-off-by: Mikko Rapeli --- meta/lib/oeqa/selftest/cases/wic.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py index e5caef74c4..664d1aa427 100644 --- a/meta/lib/oeqa/selftest/cases/wic.py +++ b/meta/lib/oeqa/selftest/cases/wic.py @@ -20,7 +20,7 @@ from tempfile import TemporaryDirectory from oeqa.selftest.case import OESelftestTestCase from oeqa.core.decorator import OETestTag -from oeqa.core.decorator.data import skipIfNotArch +from oeqa.core.decorator.data import skipIfNotArch, skipIfNotBuildArch from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu @@ -1342,6 +1342,7 @@ UKI_CMDLINE = "rootwait root=LABEL=root console=${KERNEL_CONSOLE}" self.assertEqual(output, '0') @skipIfNotArch(['aarch64']) + @skipIfNotBuildArch(['x86_64']) @OETestTag("runqemu") def test_efi_plugin_plain_systemd_boot_qemu_aarch64(self): """Test plain systemd-boot in qemu with systemd""" From patchwork Thu Oct 17 08:45:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikko Rapeli X-Patchwork-Id: 50815 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id B36F1D21257 for ; Thu, 17 Oct 2024 08:46:43 +0000 (UTC) Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by mx.groups.io with SMTP id smtpd.web11.44644.1729154802226368732 for ; Thu, 17 Oct 2024 01:46:42 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=FVnYhj9z; spf=pass (domain: linaro.org, ip: 209.85.167.51, mailfrom: mikko.rapeli@linaro.org) Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-539f76a6f0dso596616e87.1 for ; Thu, 17 Oct 2024 01:46:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729154800; x=1729759600; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6+IUGIYMQy4+I/TNl0353Ri8Nl2uMqB664dTz+MuZ3s=; b=FVnYhj9zXoD/j7mUxmtR+GS5KEh8Yly6n5abglKQUuTmG6CN1nz/1SYvn3yIS3+HUe vqC/pZ6qMt2izT7mGrOuq70VjN30WLB8kVw7vpMQiLJKGToASgF7jB9aSpyE0dNAIMpy qUxK4lMSc4r1RNoKl5b1smdY6/0GniqakRA+LRQTIR3ny2JB/xWg+Cbr4C/N7dJG6AWc b2BzFW9t1mgtIaN4Z7mtAowtvrhj0DnjFy7l7ohhqOqIwaJPo1JZzpEKT8xWNi783uSJ CFsGscCbPCE7JsK891Jxe5yWfGfYZG4qPvRZ1wwwMTSwR7NClBFHKjx/L7uXb9BkQKf3 MT3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729154800; x=1729759600; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6+IUGIYMQy4+I/TNl0353Ri8Nl2uMqB664dTz+MuZ3s=; b=LGkf9A55BXeOWR5byTa9w8fcFJTXBWHl6bU/88K9upyOgJsjPZDZLLt11RbUGaJppE dV2zaF/xM6puGAHtv0NtkFG6nKqjgI+T/8W950y85/bCTN3oekWrqzQxUX7PXa51WIIS cB1kzfzuOs8kNGCt3Qw4D6e4OQLcMcOkU+myU5pxtXGIgspQm5KX64Ult0oYcGP0uhEN TyqH+vnsGTv789E95jRZfHLY9s0hyvG8x9PoQc4zJrsHGmuju0GJytgXfqEc3EtAHSuP m2UohnB4LP6tinRqzo4JsEvR0DtNvWesJRcrvXr5loN0eAP44JUnCVzk+t8EK3/ygXPT DEOw== X-Gm-Message-State: AOJu0YwFk9oOHaN7+zRyo2kMbvRyzW69Rls22OGWVg/NxtxkfsxrItvf AY3AKTZLBfcm+/d1/C9co7g8BdUpHKarGIfgK1q6RRgggtjCSrs6AqNWE9IDgYzdb3HzkpGCS7W cVgQ= X-Google-Smtp-Source: AGHT+IG59jnqD6P0ih1DeIgAcCORWPDPvdiLFWy7OADF5wzxt1xTGklmiyDJp9Ab2qC5154v4qxTTg== X-Received: by 2002:a05:6512:3c88:b0:539:f23b:59db with SMTP id 2adb3069b0e04-539f23b5b96mr8624056e87.5.1729154800280; Thu, 17 Oct 2024 01:46:40 -0700 (PDT) Received: from localhost.localdomain (78-27-76-97.bb.dnainternet.fi. [78.27.76.97]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-539fffa8e4asm706138e87.55.2024.10.17.01.46.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 01:46:38 -0700 (PDT) From: Mikko Rapeli To: openembedded-core@lists.openembedded.org Cc: Mikko Rapeli Subject: [PATCH v9 11/11] oeqa selftest wic.py: fix missing ext4 image Date: Thu, 17 Oct 2024 11:45:52 +0300 Message-ID: <20241017084552.182136-12-mikko.rapeli@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241017084552.182136-1-mikko.rapeli@linaro.org> References: <20241017084552.182136-1-mikko.rapeli@linaro.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 17 Oct 2024 08:46:43 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/206006 test_rawcopy_plugin fails if machine does not build ext4 images by default. Make the ext4 image build explicit in the test. Fixes test on genericarm64 machine which defaults to wic image only. Signed-off-by: Mikko Rapeli --- meta/lib/oeqa/selftest/cases/wic.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py index 664d1aa427..43cdbc7e31 100644 --- a/meta/lib/oeqa/selftest/cases/wic.py +++ b/meta/lib/oeqa/selftest/cases/wic.py @@ -1180,6 +1180,10 @@ class Wic2(WicTestCase): self.assertEqual(1, len(out)) def test_rawcopy_plugin(self): + config = 'IMAGE_FSTYPES = "ext4"\n' + self.append_config(config) + self.assertEqual(0, bitbake('core-image-minimal').status) + self.remove_config(config) self._rawcopy_plugin('ext4') def test_rawcopy_plugin_unpack(self):