public inbox for cip-dev@lists.cip-project.org
 help / color / mirror / Atom feed
* [isar-cip-core][PATCH] start-qemu: allow more variable injections
@ 2026-03-20 10:10 Benedikt Niedermayr
  2026-03-21 14:43 ` Jan Kiszka
  0 siblings, 1 reply; 3+ messages in thread
From: Benedikt Niedermayr @ 2026-03-20 10:10 UTC (permalink / raw)
  To: cip-dev

This allows to inject specific variables into the script so a local kas
menu run isn't mandatory anymore and thus it could be reused in
different environments by adjusting related environment variables only.

Currently the script parses the .config.yaml which is only available
after running kas menu locally. In cases the isar-cip-core is included into
custom layers where it mostly happens that the kas menu of the
including custom layer is called rather than kas menu of isar-cip-core,
(in some cases the including custom layer doesn't use kas menu at all)
one might still want to reuse the start-qemu.sh script.

This patch specifically allows to inject the BASE_DIR and FTPM_STMM variables
via environment variables from now on.

Signed-off-by: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
---
 start-qemu.sh | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/start-qemu.sh b/start-qemu.sh
index 7ccbefeb5f47..5a0924257b37 100755
--- a/start-qemu.sh
+++ b/start-qemu.sh
@@ -80,8 +80,12 @@ else
 	fi
 fi
 
+if grep -s -q "FTPM_STMM: true" .config.yaml; then
+	FTPM_STMM="true"
+fi
+
 if grep -s -q "IMAGE_DATA_ENCRYPTION: true" .config.yaml && \
-   ! grep -s -q "FTPM_STMM: true" .config.yaml; then
+   [ -z "${FTPM_STMM}" ] ; then
 	case "${arch}" in
 		x86|x86_64|amd64)
 			TPM2_DEVICE="tpm-tis"
@@ -124,7 +128,7 @@ case "${arch}" in
 			-device virtio-serial-device \
 			-device virtconsole,chardev=con -chardev vc,id=con \
 			-device virtio-net-device,netdev=net"
-		if grep -s -q "FTPM_STMM: true" .config.yaml; then
+		if [ -n "${FTPM_STMM}" ]; then
 			QEMU_EXTRA_ARGS="${QEMU_EXTRA_ARGS} \
 				-machine virt,secure=on \
 				-device sdhci-pci -device emmc,drive=disk,rpmb-partition-size=2097152 \
@@ -175,7 +179,8 @@ case "${arch}" in
 		;;
 esac
 
-BASE_DIR=$(readlink -f $(dirname $0))
+BASE_DIR_DEFAULT=$(readlink -f $(dirname $0))
+BASE_DIR=${BASE_DIR:-$BASE_DIR_DEFAULT}
 IMAGE_PREFIX="${BASE_DIR}/build/tmp/deploy/images/qemu-${QEMU_ARCH}/${TARGET_IMAGE}-cip-core-${DISTRO_RELEASE}-qemu-${QEMU_ARCH}${TEST_IMAGE}"
 
 if [ -z "${DISPLAY}" ]; then
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [isar-cip-core][PATCH] start-qemu: allow more variable injections
  2026-03-20 10:10 [isar-cip-core][PATCH] start-qemu: allow more variable injections Benedikt Niedermayr
@ 2026-03-21 14:43 ` Jan Kiszka
  2026-03-23 10:07   ` Niedermayr, Benedikt (FT RPD CED OES-DE)
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kiszka @ 2026-03-21 14:43 UTC (permalink / raw)
  To: Benedikt Niedermayr, cip-dev

On 20.03.26 11:10, Benedikt Niedermayr wrote:
> This allows to inject specific variables into the script so a local kas
> menu run isn't mandatory anymore and thus it could be reused in
> different environments by adjusting related environment variables only.
> 
> Currently the script parses the .config.yaml which is only available
> after running kas menu locally. In cases the isar-cip-core is included into
> custom layers where it mostly happens that the kas menu of the
> including custom layer is called rather than kas menu of isar-cip-core,
> (in some cases the including custom layer doesn't use kas menu at all)
> one might still want to reuse the start-qemu.sh script.
> 
> This patch specifically allows to inject the BASE_DIR and FTPM_STMM variables
> via environment variables from now on.
> 

Did you check what is left afterwards? Would be good the solve things
completely, rather then adding another layer on top later on.

Please also document the variables under usage().

> Signed-off-by: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
> ---
>  start-qemu.sh | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/start-qemu.sh b/start-qemu.sh
> index 7ccbefeb5f47..5a0924257b37 100755
> --- a/start-qemu.sh
> +++ b/start-qemu.sh
> @@ -80,8 +80,12 @@ else
>  	fi
>  fi
>  
> +if grep -s -q "FTPM_STMM: true" .config.yaml; then
> +	FTPM_STMM="true"
> +fi
> +
>  if grep -s -q "IMAGE_DATA_ENCRYPTION: true" .config.yaml && \
> -   ! grep -s -q "FTPM_STMM: true" .config.yaml; then
> +   [ -z "${FTPM_STMM}" ] ; then
>  	case "${arch}" in
>  		x86|x86_64|amd64)
>  			TPM2_DEVICE="tpm-tis"
> @@ -124,7 +128,7 @@ case "${arch}" in
>  			-device virtio-serial-device \
>  			-device virtconsole,chardev=con -chardev vc,id=con \
>  			-device virtio-net-device,netdev=net"
> -		if grep -s -q "FTPM_STMM: true" .config.yaml; then
> +		if [ -n "${FTPM_STMM}" ]; then
>  			QEMU_EXTRA_ARGS="${QEMU_EXTRA_ARGS} \
>  				-machine virt,secure=on \
>  				-device sdhci-pci -device emmc,drive=disk,rpmb-partition-size=2097152 \
> @@ -175,7 +179,8 @@ case "${arch}" in
>  		;;
>  esac
>  
> -BASE_DIR=$(readlink -f $(dirname $0))
> +BASE_DIR_DEFAULT=$(readlink -f $(dirname $0))
> +BASE_DIR=${BASE_DIR:-$BASE_DIR_DEFAULT}
>  IMAGE_PREFIX="${BASE_DIR}/build/tmp/deploy/images/qemu-${QEMU_ARCH}/${TARGET_IMAGE}-cip-core-${DISTRO_RELEASE}-qemu-${QEMU_ARCH}${TEST_IMAGE}"
>  
>  if [ -z "${DISPLAY}" ]; then

Wouldn't it make more sense to export IMAGE_PREFIX? A downstream layer
may have a completely different image name.

Jan

-- 
Siemens AG, Foundational Technologies
Linux Expert Center


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [isar-cip-core][PATCH] start-qemu: allow more variable injections
  2026-03-21 14:43 ` Jan Kiszka
@ 2026-03-23 10:07   ` Niedermayr, Benedikt (FT RPD CED OES-DE)
  0 siblings, 0 replies; 3+ messages in thread
From: Niedermayr, Benedikt (FT RPD CED OES-DE) @ 2026-03-23 10:07 UTC (permalink / raw)
  To: Kiszka, Jan (FT RPD CED), cip-dev@lists.cip-project.org

On 3/21/26 15:43, Kiszka, Jan (FT RPD CED) wrote:
> On 20.03.26 11:10, Benedikt Niedermayr wrote:
>> This allows to inject specific variables into the script so a local kas
>> menu run isn't mandatory anymore and thus it could be reused in
>> different environments by adjusting related environment variables only.
>>
>> Currently the script parses the .config.yaml which is only available
>> after running kas menu locally. In cases the isar-cip-core is included into
>> custom layers where it mostly happens that the kas menu of the
>> including custom layer is called rather than kas menu of isar-cip-core,
>> (in some cases the including custom layer doesn't use kas menu at all)
>> one might still want to reuse the start-qemu.sh script.
>>
>> This patch specifically allows to inject the BASE_DIR and FTPM_STMM variables
>> via environment variables from now on.
>>
> 
> Did you check what is left afterwards? Would be good the solve things
> completely, rather then adding another layer on top later on.

Just created a v2. IMAGE_DATA_ENCRYPTION was still extracted from 
.config.yaml only.

> 
> Please also document the variables under usage().
> 
>> Signed-off-by: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
>> ---
>>   start-qemu.sh | 11 ++++++++---
>>   1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/start-qemu.sh b/start-qemu.sh
>> index 7ccbefeb5f47..5a0924257b37 100755
>> --- a/start-qemu.sh
>> +++ b/start-qemu.sh
>> @@ -80,8 +80,12 @@ else
>>   	fi
>>   fi
>>   
>> +if grep -s -q "FTPM_STMM: true" .config.yaml; then
>> +	FTPM_STMM="true"
>> +fi
>> +
>>   if grep -s -q "IMAGE_DATA_ENCRYPTION: true" .config.yaml && \
>> -   ! grep -s -q "FTPM_STMM: true" .config.yaml; then
>> +   [ -z "${FTPM_STMM}" ] ; then
>>   	case "${arch}" in
>>   		x86|x86_64|amd64)
>>   			TPM2_DEVICE="tpm-tis"
>> @@ -124,7 +128,7 @@ case "${arch}" in
>>   			-device virtio-serial-device \
>>   			-device virtconsole,chardev=con -chardev vc,id=con \
>>   			-device virtio-net-device,netdev=net"
>> -		if grep -s -q "FTPM_STMM: true" .config.yaml; then
>> +		if [ -n "${FTPM_STMM}" ]; then
>>   			QEMU_EXTRA_ARGS="${QEMU_EXTRA_ARGS} \
>>   				-machine virt,secure=on \
>>   				-device sdhci-pci -device emmc,drive=disk,rpmb-partition-size=2097152 \
>> @@ -175,7 +179,8 @@ case "${arch}" in
>>   		;;
>>   esac
>>   
>> -BASE_DIR=$(readlink -f $(dirname $0))
>> +BASE_DIR_DEFAULT=$(readlink -f $(dirname $0))
>> +BASE_DIR=${BASE_DIR:-$BASE_DIR_DEFAULT}
>>   IMAGE_PREFIX="${BASE_DIR}/build/tmp/deploy/images/qemu-${QEMU_ARCH}/${TARGET_IMAGE}-cip-core-${DISTRO_RELEASE}-qemu-${QEMU_ARCH}${TEST_IMAGE}"
>>   
>>   if [ -z "${DISPLAY}" ]; then
> 
> Wouldn't it make more sense to export IMAGE_PREFIX? A downstream layer
> may have a completely different image name.

Yes makes this script even more robust. just posted a v2.

Thanks!
Benedikt

> 
> Jan
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-23 10:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-20 10:10 [isar-cip-core][PATCH] start-qemu: allow more variable injections Benedikt Niedermayr
2026-03-21 14:43 ` Jan Kiszka
2026-03-23 10:07   ` Niedermayr, Benedikt (FT RPD CED OES-DE)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox