On Mon, 07/16 23:48, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> tests/vm/basevm.py | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
> index 1f4ad04c32..715e433142 100755
> --- a/tests/vm/basevm.py
> +++ b/tests/vm/basevm.py
> @@ -233,7 +233,7 @@ def main(vmcls):
> return 1
> logging.basicConfig(level=(logging.DEBUG if args.debug
> else logging.WARN))
> - vm = vmcls(debug=args.debug, vcpus=args.jobs)
> + vm = vmcls(debug=args.debug, vcpus=args.jobs if kvm_available() else 0)
> if args.build_image:
> if os.path.exists(args.image) and not args.force:
> sys.stderr.writelines(["Image file exists: %s\n" % args.image,
> @@ -244,7 +244,7 @@ def main(vmcls):
> vm.add_source_dir(args.build_qemu)
> cmd = [vm.BUILD_SCRIPT.format(
> configure_opts = " ".join(argv),
> - jobs=args.jobs)]
> + jobs=args.jobs if kvm_available() else 1)]
> else:
> cmd = argv
> vm.boot(args.image + ",snapshot=on")
> --
> 2.18.0
>
Could you instead change this line
parser.add_option("--jobs", type=int, default=multiprocessing.cpu_count() / 2,
help="number of virtual CPUs")
to use kvm_available()? With another helper function to contain the line width,
probably:
..., default=get_default_jobs(), help=...
and
def get_default_jobs():
if kvm_available():
return ...
else:
return ...
Fam