From 0236bd090720da7ba6d6743ceace6fd45038b7c4 Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Tue, 14 Nov 2023 16:26:44 -0500 Subject: [PATCH] qemu: fix panic from missing resources block (#19089) The `qemu` driver uses our universal executor to run the qemu command line tool. Because qemu owns the resource isolation, we don't pass in the resource block that the universal executor uses to configure cgroups and core pinning. This resulted in a panic. Fix the panic by returning early in the cgroup configuration in the universal executor. This fixes `qemu` but also any third-party drivers that might exist and are using our executor code without passing in the resource block. In future work, we should ensure that the `resources` block is being translated into qemu equivalents, so that we have support for things like NUMA-aware scheduling for that driver. Fixes: https://github.com/hashicorp/nomad/issues/19078 --- drivers/shared/executor/executor_universal_linux.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/shared/executor/executor_universal_linux.go b/drivers/shared/executor/executor_universal_linux.go index 93629d6a3..4aab9199d 100644 --- a/drivers/shared/executor/executor_universal_linux.go +++ b/drivers/shared/executor/executor_universal_linux.go @@ -176,6 +176,12 @@ func (e *UniversalExecutor) enterCG1(statsCgroup, cpusetCgroup string) func() { } func (e *UniversalExecutor) configureCG1(cgroup string, command *ExecCommand) { + + // some drivers like qemu entirely own resource management + if command.Resources == nil || command.Resources.LinuxResources == nil { + return + } + // write memory limits memHard, memSoft := e.computeMemory(command) ed := cgroupslib.OpenFromFreezerCG1(cgroup, "memory") @@ -205,6 +211,12 @@ func (e *UniversalExecutor) configureCG1(cgroup string, command *ExecCommand) { } func (e *UniversalExecutor) configureCG2(cgroup string, command *ExecCommand) { + + // some drivers like qemu entirely own resource management + if command.Resources == nil || command.Resources.LinuxResources == nil { + return + } + // write memory cgroup files memHard, memSoft := e.computeMemory(command) ed := cgroupslib.OpenPath(cgroup)