qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 2/3] tests/vm: Do not abuse parallelism when


From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-devel] [PATCH v2 2/3] tests/vm: Do not abuse parallelism when KVM is not available
Date: Fri, 12 Oct 2018 01:48:14 +0200

On Thu, Oct 11, 2018 at 4:46 AM Fam Zheng <address@hidden> wrote:
> On Mon, 10/01 01:23, Philippe Mathieu-Daudé wrote:
> > Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
> > ---
> > 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.

You are right, I missed that.

>
> >          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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]