From c71eee34774b3544120cbac946d4b605f9b93e2f Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Tue, 23 Dec 2025 15:08:06 -0800 Subject: [PATCH] run-vmtest: Allow specifying cpu and memory for vms The max-cpu parameter is currently unused by the script and therefore vmtest defaults to 2 CPU. There is not parameter available to specify the amount of memory to give to the vm, for this the vmtest defaults to 4G. These low defaults(specifically the memory) sometimes cause the bpf seltests to sporadically fail. So, add the option to specify memory and also start using the max-cpu parameter with vmtest. Signed-off-by: Puranjay Mohan --- .github/workflows/kernel-test.yml | 1 + run-vmtest/action.yml | 6 +++++- run-vmtest/run.sh | 23 +++++++++++++++++++---- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.github/workflows/kernel-test.yml b/.github/workflows/kernel-test.yml index 4c29851..2de9ced 100644 --- a/.github/workflows/kernel-test.yml +++ b/.github/workflows/kernel-test.yml @@ -79,6 +79,7 @@ jobs: vmlinuz: '${{ github.workspace }}/vmlinuz' kernel-root: ${{ env.REPO_ROOT }} max-cpu: 8 + max-memory: 16G kernel-test: ${{ inputs.test }} # Here we must use kbuild-output local to the repo, because # it was extracted from the artifacts. diff --git a/run-vmtest/action.yml b/run-vmtest/action.yml index 55b2dec..945d554 100644 --- a/run-vmtest/action.yml +++ b/run-vmtest/action.yml @@ -13,7 +13,10 @@ inputs: description: 'kernel source dir' default: '.' max-cpu: - description: 'Maximum number of CPU allocated to a VM (regardless of number of CPUs available on the host). Default is unset, e.g it will default to the number of CPU on the host.' + description: 'Number of CPUs allocated to the VM. Default is 2.' + default: '' + max-memory: + description: 'Amount of memory allocated to the VM (e.g., "4G", "16G"). Default is "4G".' default: '' kernel-test: description: 'Test to run' @@ -64,6 +67,7 @@ runs: KERNEL_ROOT: ${{ inputs.kernel-root }} KERNEL_TEST: ${{ inputs.kernel-test }} MAX_CPU: ${{ inputs.max-cpu }} + MAX_MEMORY: ${{ inputs.max-memory }} OUTPUT_DIR: ${{ inputs.output-dir }} VMLINUZ: ${{ inputs.vmlinuz || '' }} run: | diff --git a/run-vmtest/run.sh b/run-vmtest/run.sh index 7a8527c..4a9eb06 100755 --- a/run-vmtest/run.sh +++ b/run-vmtest/run.sh @@ -86,10 +86,25 @@ foldable start vmtest "Starting virtual machine..." # Tests may be comma-separated. vmtest_selftest expect them to come from CLI space-separated. TEST_RUNNERS=$(echo ${KERNEL_TEST} | tr -s ',' ' ') -vmtest -k "${VMLINUZ}" --kargs "panic=-1 sysctl.vm.panic_on_oom=1" \ - "${GITHUB_ACTION_PATH}/vmtest-init.sh && \ - cd '${GITHUB_WORKSPACE}' && \ - ${VMTEST_SCRIPT} ${TEST_RUNNERS}" + +# Configure VM resources +VMTEST_NUM_CPUS=${MAX_CPU:-2} +VMTEST_MEMORY=${MAX_MEMORY:-4G} + +# Generate vmtest.toml config file +cat > vmtest.toml <