From ada46fb2dbcae2919e884b2155b7f0e7630c62e3 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Thu, 10 Dec 2020 09:45:25 -0800 Subject: [PATCH] test-runner: set processor count for VM For better reliability the processor count is now set to qemu. In cases of low CPU count (< 2) hosts the processor count is limited to 1. Otherwise half of the host cores will be used for the VM. --- tools/test-runner | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/test-runner b/tools/test-runner index c2ff7eff..40b3c658 100755 --- a/tools/test-runner +++ b/tools/test-runner @@ -1402,6 +1402,19 @@ class Main: 'kernel' ] + nproc = multiprocessing.cpu_count() + + # + # Specially handle CPU systems with minimal cores, otherwise + # use half the host cores. + # + if nproc < 2: + smp = 1 + else: + smp = int(nproc / 2) + + print("Using %d cores for VM" % smp) + # # This passes through most of the command line options to # the kernel command line. Some are not relevant (e.g. qemu) @@ -1440,7 +1453,7 @@ class Main: rootflags=trans=virtio,version=9p2000.u \ acpi=off pci=noacpi %s ro \ mac80211_hwsim.radios=0 %s' % (kern_log, options), - '-cpu', 'host' + '-cpu', 'host', '-smp', str(smp) ] # Add two ethernet devices for testing EAD