diff --git a/virtcontainers/pkg/annotations/annotations.go b/virtcontainers/pkg/annotations/annotations.go index f2cfb51075..08ce422f07 100644 --- a/virtcontainers/pkg/annotations/annotations.go +++ b/virtcontainers/pkg/annotations/annotations.go @@ -180,6 +180,7 @@ const ( BlockDeviceCacheNoflush = kataAnnotHypervisorPrefix + "block_device_cache_noflush" ) +// Agent related annotations const ( kataAnnotRuntimePrefix = kataConfAnnotationsPrefix + "runtime." @@ -215,6 +216,15 @@ const ( // The first word is considered as the module name and the rest as its parameters. // KernelModules = kataAnnotAgentPrefix + "kernel_modules" + + // AgentTrace is a sandbox annotation to enable tracing for the agent. + AgentTrace = kataAnnotAgentPrefix + "enable_tracing" + + // AgentTraceMode is a sandbox annotation to specify the trace mode for the agent. + AgentTraceMode = kataAnnotAgentPrefix + "trace_mode" + + // AgentTraceMode is a sandbox annotation to specify the trace type for the agent. + AgentTraceType = kataAnnotAgentPrefix + "trace_type" ) const ( diff --git a/virtcontainers/pkg/oci/utils.go b/virtcontainers/pkg/oci/utils.go index d6406ca166..1143cd5df0 100644 --- a/virtcontainers/pkg/oci/utils.go +++ b/virtcontainers/pkg/oci/utils.go @@ -714,14 +714,35 @@ func addRuntimeConfigOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConfig) e } func addAgentConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig) error { - if value, ok := ocispec.Annotations[vcAnnotations.KernelModules]; ok { - if c, ok := config.AgentConfig.(vc.KataAgentConfig); ok { - modules := strings.Split(value, KernelModulesSeparator) - c.KernelModules = modules - config.AgentConfig = c - } + c, ok := config.AgentConfig.(vc.KataAgentConfig) + if !ok { + return nil } + if value, ok := ocispec.Annotations[vcAnnotations.KernelModules]; ok { + modules := strings.Split(value, KernelModulesSeparator) + c.KernelModules = modules + config.AgentConfig = c + } + + if value, ok := ocispec.Annotations[vcAnnotations.AgentTrace]; ok { + trace, err := strconv.ParseBool(value) + if err != nil { + return fmt.Errorf("Error parsing annotation for agent.trace: Please specify boolean value 'true|false'") + } + c.Trace = trace + } + + if value, ok := ocispec.Annotations[vcAnnotations.AgentTraceMode]; ok { + c.TraceMode = value + } + + if value, ok := ocispec.Annotations[vcAnnotations.AgentTraceType]; ok { + c.TraceType = value + } + + config.AgentConfig = c + return nil }