diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-09-25 21:36:19 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-09-25 21:36:19 +0200 |
commit | 6586659716d960fdab1ec0977a84645b9d06fc36 (patch) | |
tree | 19b2bb8ea42f2ad1c77f4cb9e1d35d83935c01c0 /scripts | |
parent | 440cb4befa1ed9b354a3483deeaac948db873fbb (diff) | |
download | vyos-build-6586659716d960fdab1ec0977a84645b9d06fc36.tar.gz vyos-build-6586659716d960fdab1ec0977a84645b9d06fc36.zip |
Testsuite: automatically determine number of CPUs used
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/check-qemu-install | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/scripts/check-qemu-install b/scripts/check-qemu-install index 3f68648b..77b65c9e 100755 --- a/scripts/check-qemu-install +++ b/scripts/check-qemu-install @@ -42,6 +42,7 @@ import random import traceback import logging import re + from io import BytesIO, StringIO from datetime import datetime @@ -97,6 +98,13 @@ class StreamToLogger(object): def flush(self): pass +def get_half_cpus(): + """ return 1/2 of the numbers of available CPUs """ + cpu = os.cpu_count() + if cpu > 1: + cpu /= 2 + return int(cpu) + def get_qemu_cmd(name, enable_kvm, disk_img, iso_img=None): kvm = "" cpu = "-cpu host" @@ -108,9 +116,12 @@ def get_qemu_cmd(name, enable_kvm, disk_img, iso_img=None): if iso_img: cdrom = "-boot d -cdrom {}".format(iso_img) + # test using half of the available CPUs on the system + cpucount = get_half_cpus() + cmd = f'qemu-system-x86_64 \ -name "{name}" \ - -smp 2 \ + -smp {cpucount} \ -m 2G \ -nic user,model=virtio,mac=52:54:99:12:34:56 \ -nic user,model=virtio,mac=52:54:99:12:34:57 \ |