From ef6b0686ee948559dd4b493c539982ae45695fee Mon Sep 17 00:00:00 2001 From: Xynnn007 Date: Tue, 22 Jul 2025 09:57:46 +0800 Subject: [PATCH] agent: add debug flag to initdata The debug flag will be used to control guest-components log level for now, and in future it can have more abilities. As initdata is measured by attestation, the debug flag can be detected by the trustee side thus safe. Fixes: #11587 Signed-off-by: Xynnn007 --- src/agent/src/initdata.rs | 10 +++++++++- src/agent/src/main.rs | 15 +++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/agent/src/initdata.rs b/src/agent/src/initdata.rs index cd4efa6be2..76c0d27a0c 100644 --- a/src/agent/src/initdata.rs +++ b/src/agent/src/initdata.rs @@ -2,7 +2,7 @@ //! //! This module will do the following things if a proper initdata device with initdata exists. //! 1. Parse the initdata block device and extract the config files to [`INITDATA_PATH`]. -//! 2. Return the initdata and the policy (if any). +//! 2. Return the initdata, the policy (if any) and the guest components debug flag (defaults to `false`). // Copyright (c) 2025 Alibaba Cloud // @@ -26,6 +26,7 @@ pub const INITDATA_PATH: &str = "/run/confidential-containers/initdata"; const AA_CONFIG_KEY: &str = "aa.toml"; const CDH_CONFIG_KEY: &str = "cdh.toml"; const POLICY_KEY: &str = "policy.rego"; +const DEBUG_FLAG: &str = "debug"; /// The path of initdata toml pub const INITDATA_TOML_PATH: &str = concatcp!(INITDATA_PATH, "/initdata.toml"); @@ -100,6 +101,7 @@ pub async fn read_initdata(device_path: &str) -> Result> { pub struct InitdataReturnValue { pub _digest: Vec, pub _policy: Option, + pub debug: bool, } pub async fn initialize_initdata(logger: &Logger) -> Result> { @@ -150,11 +152,17 @@ pub async fn initialize_initdata(logger: &Logger) -> Result