From: Fam Zheng <famz@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: "Alex Bennée" <alex.bennee@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 2/3] tests/vm: Do not abuse parallelism when KVM is not available
Date: Thu, 11 Oct 2018 10:46:11 +0800 [thread overview]
Message-ID: <20181011024611.GB17357@magic> (raw)
In-Reply-To: <20180930232312.16486-3-f4bug@amsat.org>
On Mon, 10/01 01:23, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> v2: Add get_default_jobs (Fam suggestion)
> ---
> tests/vm/basevm.py | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
> index 5a5fa09752..fc203e9f53 100755
> --- a/tests/vm/basevm.py
> +++ b/tests/vm/basevm.py
> @@ -202,6 +202,13 @@ class BaseVM(object):
> return self._guest.qmp(*args, **kwargs)
>
> def parse_args(vm_name):
> +
> + def get_default_jobs():
> + if kvm_available():
> + return multiprocessing.cpu_count() / 2
> + else:
> + return 1
> +
> parser = optparse.OptionParser(
> description="VM test utility. Exit codes: "
> "0 = success, "
> @@ -214,7 +221,7 @@ def parse_args(vm_name):
> help="image file name")
> parser.add_option("--force", "-f", action="store_true",
> help="force build image even if image exists")
> - parser.add_option("--jobs", type=int, default=multiprocessing.cpu_count() / 2,
> + parser.add_option("--jobs", type=int, default=get_default_jobs(),
> help="number of virtual CPUs")
> parser.add_option("--verbose", "-V", action="store_true",
> help="Pass V=1 to builds within the guest")
> @@ -237,7 +244,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)
What's wrong with just using args.jobs? It defaults to 1 if kvm_available()
returns false, so I don't think we need another condition here.
> if args.build_image:
> if os.path.exists(args.image) and not args.force:
> sys.stderr.writelines(["Image file exists: %s\n" % args.image,
> @@ -248,7 +255,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,
Again, can't we just use args.jobs?
> verbose = "V=1" if args.verbose else "")]
> else:
> cmd = argv
> --
> 2.19.0
>
Fam
next prev parent reply other threads:[~2018-10-11 2:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20180930232312.16486-1-f4bug@amsat.org>
2018-10-10 21:18 ` [Qemu-devel] [PATCH v2 0/3] tests/vm: Improvements when KVM is not available Philippe Mathieu-Daudé
[not found] ` <20180930232312.16486-3-f4bug@amsat.org>
2018-10-11 2:46 ` Fam Zheng [this message]
2018-10-11 23:48 ` [Qemu-devel] [PATCH v2 2/3] tests/vm: Do not abuse parallelism " Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181011024611.GB17357@magic \
--to=famz@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=f4bug@amsat.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).