From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7201062888117633024 X-Received: by 2002:a2e:a4b9:0:b0:293:5fb9:3c10 with SMTP id g25-20020a2ea4b9000000b002935fb93c10mr154238ljm.10.1676628124427; Fri, 17 Feb 2023 02:02:04 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:651c:b0c:b0:293:186a:1056 with SMTP id b12-20020a05651c0b0c00b00293186a1056ls112163ljr.10.-pod-prod-gmail; Fri, 17 Feb 2023 02:02:02 -0800 (PST) X-Google-Smtp-Source: AK7set8n9BrHKumpTh0wBpXb9pWNPvesXR4D5UkOqQQsfZ68T2TgItpVITkBnoqGIpfkGyczG/i9 X-Received: by 2002:a05:651c:b20:b0:293:3dd6:89a4 with SMTP id b32-20020a05651c0b2000b002933dd689a4mr4063916ljr.34.1676628122545; Fri, 17 Feb 2023 02:02:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676628122; cv=none; d=google.com; s=arc-20160816; b=E1dCYbH5xLskP5Nx9dlL+efNJORJeA49AvK+RfctEE2Y+mau8Kd6OoN7GN6/zUHhUZ DQ5aBoPzsff9Zhp4ObTIhurpxViHoTQjnZHKJBRne7sFZOKuMD9iJ/LIYjUMW+cz2zK0 PiYn0pU6QeYH+AtHHJ/0+B5O4lGJ0rsX31WyUvMZzccfUxlVkxpZBjiWHVAXt47ddTBW 1eOUhVgfXdWWrboWvWkoqP184hs1xIDWUMbW7S04kGK3iLs+eP8QCMKYkP51XS8pxlMy 0jHsybdz4VyENAq4sfWvYJunSZyPnkcJ6iipMFDuhNvDyLroH8mGfO/S1ABh7QTyigyr QvdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=feedback-id:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=FkZyZHXAY3quiF16advfPhb2wh47Rs61jwztLcwkAEc=; b=Vfbw6sgGRjSbBV70yxSEOjeQ+n3H5OrEC/0jHsbnx6sJboAE5bn4Ua9VNP3UMu7EQk tht6S3BBBH3SsfuwzALJ1CKzkPf+zo7NZ3UebzfUlIwZMHKoV67pv+9WdkEbtJ0/jn/5 7fHmSFSnt/x5j9LXdcW5Xyi39CnFNjjI9R1FLWdDoUfpKlwBiqaKE3l0x0C3RcWDupG4 po0TWNmd8fbOFPvQBSYWKJ58+qBOefCctmnmF9DwCNWSjD3x/yssTTLDgCH0G7M6+Xwq 6va+5tL9e1C4jNeG6IarltKnUY/UFRm1xKFJn0krz+WDeZ5vaCbEi29UXTEvcGZSUUCD 83fg== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=o8YzyNh7; spf=pass (google.com: domain of fm-72506-202302171002009320861578a92192b4-oqce_w@rts-flowmailer.siemens.com designates 185.136.65.226 as permitted sender) smtp.mailfrom=fm-72506-202302171002009320861578a92192b4-OQce_w@rts-flowmailer.siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from mta-65-226.siemens.flowmailer.net (mta-65-226.siemens.flowmailer.net. [185.136.65.226]) by gmr-mx.google.com with ESMTPS id o16-20020a05651c051000b0028ffa3d673asi122741ljp.3.2023.02.17.02.02.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Feb 2023 02:02:02 -0800 (PST) Received-SPF: pass (google.com: domain of fm-72506-202302171002009320861578a92192b4-oqce_w@rts-flowmailer.siemens.com designates 185.136.65.226 as permitted sender) client-ip=185.136.65.226; Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=o8YzyNh7; spf=pass (google.com: domain of fm-72506-202302171002009320861578a92192b4-oqce_w@rts-flowmailer.siemens.com designates 185.136.65.226 as permitted sender) smtp.mailfrom=fm-72506-202302171002009320861578a92192b4-OQce_w@rts-flowmailer.siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: by mta-65-226.siemens.flowmailer.net with ESMTPSA id 202302171002009320861578a92192b4 for ; Fri, 17 Feb 2023 11:02:01 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=felix.moessbauer@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=FkZyZHXAY3quiF16advfPhb2wh47Rs61jwztLcwkAEc=; b=o8YzyNh7Ic7IymT30K3Vq0fDR+HouL2cyhNwYNqN7Fjyb544kceN2v+DPlmRt/ZhIP0jKt Bs7YLMLfV5SjR0RBhRRM08fAXN9dWMRowj9rRJECs18dxTos+eWAoLoXveAYo6lw9qXvnvgH lusw5eSd4oithnAAZxDHaxfIdlI5I=; From: Felix Moessbauer To: isar-users@googlegroups.com Cc: adriaan.schmidt@siemens.com, jan.kiszka@siemens.com, Felix Moessbauer Subject: [PATCH 3/3] fix race-cond between default and custom initrd Date: Fri, 17 Feb 2023 10:01:18 +0000 Message-Id: <20230217100118.2912985-4-felix.moessbauer@siemens.com> In-Reply-To: <20230217100118.2912985-1-felix.moessbauer@siemens.com> References: <20230217100118.2912985-1-felix.moessbauer@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-72506:519-21489:flowmailer X-TUID: LooDUXYlGPA1 This patch fixes a data race happening when building a custom initrd. Previously, both custom and default initrds were deployed to the image deploy dir. The race is fixed by conditionally deploying either the custom or the default one. For that, we introduce a new variable INITRD_DEPLOY_FILE which provides the name of the initrd in the deploy directory. The existing INITRD_IMAGE variable is defaulted to the empty string and used to control if a custom initrd is requrested. Only if this variable is empty, the default one is deployed. Signed-off-by: Felix Moessbauer --- meta/classes/image.bbclass | 24 ++++++++++++++---------- scripts/start_vm | 4 ++-- testsuite/start_vm.py | 2 +- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass index e799d1d4..0d5a521e 100644 --- a/meta/classes/image.bbclass +++ b/meta/classes/image.bbclass @@ -3,7 +3,7 @@ # Make workdir and stamps machine-specific without changing common PN target WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}-${MACHINE}/${PV}-${PR}" -DEPLOYDIR = "${WORKDIR}/deploy-${PN}" +DEPLOYDIR = "${WORKDIR}/deploy" STAMP = "${STAMPS_DIR}/${DISTRO}-${DISTRO_ARCH}/${PN}-${MACHINE}/${PV}-${PR}" STAMPCLEAN = "${STAMPS_DIR}/${DISTRO}-${DISTRO_ARCH}/${PN}-${MACHINE}/*-*" @@ -22,8 +22,9 @@ IMAGE_INSTALL += "${KERNEL_IMAGE_PKG}" IMAGE_FULLNAME = "${PN}-${DISTRO}-${MACHINE}" # These variables are used by wic and start_vm -KERNEL_IMAGE ?= "${IMAGE_FULLNAME}-${KERNEL_FILE}" -INITRD_IMAGE ?= "${IMAGE_FULLNAME}-initrd.img" +KERNEL_IMAGE = "${IMAGE_FULLNAME}-${KERNEL_FILE}" +INITRD_IMAGE ?= "" +INITRD_DEPLOY_FILE = "${@d.getVar('INITRD_IMAGE') or '${IMAGE_FULLNAME}-initrd.img')" # This defines the deployed dtbs for reuse by imagers DTB_FILES ?= "" @@ -353,7 +354,7 @@ EOF # Default kernel, initrd and dtb image deploy paths (inside imager) KERNEL_IMG = "${PP_DEPLOY}/${KERNEL_IMAGE}" -INITRD_IMG = "${PP_DEPLOY}/${INITRD_IMAGE}" +INITRD_IMG = "${PP_DEPLOY}/${INITRD_DEPLOY_FILE}" # only one dtb file supported, pick the first DTB_IMG = "${PP_DEPLOY}/${@(d.getVar('DTB_FILES').split() or [''])[0]}" @@ -370,12 +371,15 @@ do_copy_boot_files() { sudo cat "$kernel" > "${DEPLOYDIR}/${KERNEL_IMAGE}" fi - initrd="$(realpath -q '${IMAGE_ROOTFS}/initrd.img')" - if [ ! -f "$initrd" ]; then - initrd="$(realpath -q '${IMAGE_ROOTFS}/boot/initrd.img')" - fi - if [ -f "$initrd" ]; then - cp -f "$initrd" '${DEPLOYDIR}/${INITRD_IMAGE}' + # deploy default initrd if no custom one is build + if [ -e "${INITRD_IMAGE}" ]; then + initrd="$(realpath -q '${IMAGE_ROOTFS}/initrd.img')" + if [ ! -f "$initrd" ]; then + initrd="$(realpath -q '${IMAGE_ROOTFS}/boot/initrd.img')" + fi + if [ -f "$initrd" ]; then + cp -f "$initrd" '${DEPLOYDIR}/${INITRD_DEPLOY_FILE}' + fi fi for file in ${DTB_FILES}; do diff --git a/scripts/start_vm b/scripts/start_vm index 17091d72..8c696a4a 100755 --- a/scripts/start_vm +++ b/scripts/start_vm @@ -125,10 +125,10 @@ case "$IMAGE_FSTYPES" in readonly ROOTFS_IMAGE=$IMAGE_FULLNAME.ext4 eval $(bitbake -e mc:qemu$ARCH-$DISTRO:isar-image-base | grep "^KERNEL_IMAGE=") - eval $(bitbake -e mc:qemu$ARCH-$DISTRO:isar-image-base | grep "^INITRD_IMAGE=") + eval $(bitbake -e mc:qemu$ARCH-$DISTRO:isar-image-base | grep "^INITRD_DEPLOY_FILE=") QKERNEL=$IMAGE_DIR/${KERNEL_IMAGE} QINITRD=/dev/null - [ -n "$INITRD_IMAGE" ] && QINITRD=$IMAGE_DIR/${INITRD_IMAGE} + [ -n "$INITRD_DEPLOY_FILE" ] && QINITRD=$IMAGE_DIR/${INITRD_DEPLOY_FILE} if [ "$ARCH" = "riscv64" ]; then EXTRA_ARGS="$EXTRA_ARGS -device loader,file=$QKERNEL,addr=0x80200000" QKERNEL="/usr/lib/riscv64-linux-gnu/opensbi/qemu/virt/fw_jump.elf" diff --git a/testsuite/start_vm.py b/testsuite/start_vm.py index 82ecc17d..ba1ba127 100755 --- a/testsuite/start_vm.py +++ b/testsuite/start_vm.py @@ -35,7 +35,7 @@ def format_qemu_cmdline(arch, build, distro, out, pid, enforce_pcbios=False): if image_type == 'ext4': rootfs_image = 'isar-image-base-' + base + '-' + distro + '-qemu' + arch + '.ext4' kernel_image = deploy_dir_image + '/' + get_bitbake_var(bb_output, 'KERNEL_IMAGE') - initrd_image = get_bitbake_var(bb_output, 'INITRD_IMAGE') + initrd_image = get_bitbake_var(bb_output, 'INITRD_DEPLOY_FILE') if not initrd_image: initrd_image = '/dev/null' -- 2.34.1