tests/vm: various minor improvements
cover tests/vm: various minor improvements
The setup I had for my BSD VMs broke today, so I thought I'd have a look at using the tests/vm/ support for building QEMU inside BSD VMs rather than re-rolling my own. This patchset fixes some rough edges I ran into along the way:
* fixes support for non-KVM accelerators
* propagates J=n setting into 'make check' in the VM
* propagates V=1 setting into 'make' and 'make check' in the VM
* uses --output-sync so that J=n settings don't mangle output
* bumps the RAM settings so J=n doesn't cause the guest to run out of memory and kill the compiler
Ideally I'd like to be able to separately invoke commands for "build in VM" and "run make check in VM for that build"; for instance I only want V=1 on the make-check, not the make, and in some cases might want to do a build but not check, and so on. But that seemed too complicated for the moment.
Is it possible for the VMs to be persistent? Currently it looks like they throw away their contents and start afresh for every invocation. Doing build tests as incremental is faster than doing every one as a from-clean...
Also, I notice that the OpenBSD VM setup is using SDL 1.2, which means that configure complains and suggests switching to SDL 2.0. How do we update the base image?
thanks
-- PMM
Peter Maydell (5):
tests/vm: Use -cpu max rather than -cpu host tests/vm: Pass the jobs parallelism setting to 'make check' tests/vm: Propagate V=1 down into the make inside the VM tests/vm: Bump guest RAM up from 2G to 4G tests/vm: Use make's --output-sync option
tests/vm/Makefile.include | 1 + docs/devel/testing.rst | 1 + tests/vm/basevm.py | 9 ++++++--- tests/vm/freebsd | 4 ++-- tests/vm/netbsd | 4 ++-- tests/vm/openbsd | 4 ++-- tests/vm/ubuntu.i386 | 4 ++-- 7 files changed, 16 insertions(+), 11 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/5 tests/vm: Use -cpu max rather than -cpu host
Currently attempting to run the vm-build-* tests on a system where the user does not have access to KVM will fail, because although they avoid using -enable-kvm, they use "-cpu host", which only works with KVM. Switch to "-cpu max" instead, which works with any accelerator.
--- tests/vm/basevm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/vm/basevm.py +1 -1
@@ -65,7 +65,7 @@ class BaseVM(object): self._stdout = self._devnull self._args = [ \ "-nodefaults", "-m", "2G", - "-cpu", "host", + "-cpu", "max", "-netdev", "user,id=vnet,hostfwd=:127.0.0.1:0-:22", "-device", "virtio-net-pci,netdev=vnet", "-vnc", "127.0.0.1:0,to=20",
Signature · 1 line
2.17.1
PATCH 2/5 tests/vm: Pass the jobs parallelism setting to 'make check'
In reply to Peter MaydellOur test suite works for parallel execution too, and this can noticeably speed up a test run; pass the 'jobs' setting to it as well as to the build proper.
--- tests/vm/freebsd | 2 +- tests/vm/netbsd | 2 +- tests/vm/openbsd | 2 +- tests/vm/ubuntu.i386 | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
tests/vm/freebsd +1 -1
@@ -24,7 +24,7 @@ class FreeBSDVM(basevm.BaseVM): tar -xf /dev/vtbd1; ./configure {configure_opts}; gmake -j{jobs}; - gmake check; + gmake -j{jobs} check; """ def build_image(self, img):
tests/vm/netbsd +1 -1
@@ -24,7 +24,7 @@ class NetBSDVM(basevm.BaseVM): tar -xf /dev/rld1a; ./configure --python=python2.7 {configure_opts}; gmake -j{jobs}; - gmake check; + gmake -j{jobs} check; """ def build_image(self, img):
tests/vm/openbsd +1 -1
@@ -25,7 +25,7 @@ class OpenBSDVM(basevm.BaseVM): ./configure --cc=x86_64-unknown-openbsd6.1-gcc-4.9.4 --python=python2.7 {configure_opts}; gmake -j{jobs}; # XXX: "gmake check" seems to always hang or fail - #gmake check; + #gmake -j{jobs} check; """ def build_image(self, img):
tests/vm/ubuntu.i386 +1 -1
@@ -26,7 +26,7 @@ class UbuntuX86VM(basevm.BaseVM): tar -xf /dev/vdb; ./configure {configure_opts}; make -j{jobs}; - make check; + make -j{jobs} check; """ def _gen_cloud_init_iso(self):
Signature · 1 line
2.17.1
PATCH 3/5 tests/vm: Propagate V=1 down into the make inside the VM
In reply to Peter MaydellInvoking 'make vm-build-freebsd' and friends with V=1 should propagate that verbosity setting down into the build run inside the VM. Make sure we do that. This brings it into line with how the container tests handle V=1.
--- tests/vm/Makefile.include | 1 + docs/devel/testing.rst | 1 + tests/vm/basevm.py | 5 ++++- tests/vm/freebsd | 4 ++-- tests/vm/netbsd | 4 ++-- tests/vm/openbsd | 4 ++-- tests/vm/ubuntu.i386 | 2 +- 7 files changed, 13 insertions(+), 8 deletions(-)
tests/vm/Makefile.include +1 -0
@@ -36,6 +36,7 @@ vm-build-%: tests/vm/%.img $(if $(V)$(DEBUG), --debug) \ $(if $(DEBUG), --interactive) \ $(if $(J),--jobs $(J)) \ + $(if $(V),--verbose) \ --image "$<" \ --build-qemu $(SRC_PATH), \ " VM-BUILD $*")
docs/devel/testing.rst +1 -0
@@ -423,6 +423,7 @@ Debugging Add ``DEBUG=1`` and/or ``V=1`` to the make command to allow interactive debugging and verbose output. If this is not enough, see the next section. +``V=1`` will be propagated down into the make jobs in the guest. Manual invocation -----------------
tests/vm/basevm.py +4 -1
@@ -210,6 +210,8 @@ def parse_args(vm_name): help="force build image even if image exists") parser.add_option("--jobs", type=int, default=multiprocessing.cpu_count() / 2, help="number of virtual CPUs") + parser.add_option("--verbose", "-V", action="store_true", + help="Pass V=1 to builds within the guest") parser.add_option("--build-image", "-b", action="store_true", help="build image") parser.add_option("--build-qemu",
@@ -238,7 +240,8 @@ 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, + verbose = "V=1" if args.verbose else "")] else: cmd = argv vm.boot(args.image + ",snapshot=on")
tests/vm/freebsd +2 -2
@@ -23,8 +23,8 @@ class FreeBSDVM(basevm.BaseVM): cd $(mktemp -d /var/tmp/qemu-test.XXXXXX); tar -xf /dev/vtbd1; ./configure {configure_opts}; - gmake -j{jobs}; - gmake -j{jobs} check; + gmake -j{jobs} {verbose}; + gmake -j{jobs} check {verbose}; """ def build_image(self, img):
tests/vm/netbsd +2 -2
@@ -23,8 +23,8 @@ class NetBSDVM(basevm.BaseVM): cd $(mktemp -d /var/tmp/qemu-test.XXXXXX); tar -xf /dev/rld1a; ./configure --python=python2.7 {configure_opts}; - gmake -j{jobs}; - gmake -j{jobs} check; + gmake -j{jobs} {verbose}; + gmake -j{jobs} check {verbose}; """ def build_image(self, img):
tests/vm/openbsd +2 -2
@@ -23,9 +23,9 @@ class OpenBSDVM(basevm.BaseVM): cd $(mktemp -d /var/tmp/qemu-test.XXXXXX); tar -xf /dev/rsd1c; ./configure --cc=x86_64-unknown-openbsd6.1-gcc-4.9.4 --python=python2.7 {configure_opts}; - gmake -j{jobs}; + gmake -j{jobs} {verbose}; # XXX: "gmake check" seems to always hang or fail - #gmake -j{jobs} check; + #gmake -j{jobs} check {verbose}; """ def build_image(self, img):
tests/vm/ubuntu.i386 +1 -1
@@ -26,7 +26,7 @@ class UbuntuX86VM(basevm.BaseVM): tar -xf /dev/vdb; ./configure {configure_opts}; make -j{jobs}; - make -j{jobs} check; + make check -j{jobs} {verbose}; """ def _gen_cloud_init_iso(self):
Signature · 1 line
2.17.1
PATCH 4/5 tests/vm: Bump guest RAM up from 2G to 4G
In reply to Peter MaydellCurrently we run the guests in a VM which is given only 2G of RAM. Since the guests are configured without any swap space, builds can fail because the system runs out of memory and kills the compiler, especially if the job count is set for a lot of parallelism. Bump the setting up from 2G to 4G to give us some more headroom.
---
Specifically I found the NetBSD build was falling over with a J=16 level of parallelism.
--- tests/vm/basevm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/vm/basevm.py +1 -1
@@ -64,7 +64,7 @@ class BaseVM(object): else: self._stdout = self._devnull self._args = [ \ - "-nodefaults", "-m", "2G", + "-nodefaults", "-m", "4G", "-cpu", "max", "-netdev", "user,id=vnet,hostfwd=:127.0.0.1:0-:22", "-device", "virtio-net-pci,netdev=vnet",
Signature · 1 line
2.17.1
PATCH 5/5 tests/vm: Use make's --output-sync option
In reply to Peter MaydellUse make's --output-sync option when running tests inside VMs, so that if we're building with parallelization the output doesn't get scrambled.
--- tests/vm/freebsd | 4 ++-- tests/vm/netbsd | 4 ++-- tests/vm/openbsd | 4 ++-- tests/vm/ubuntu.i386 | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-)
tests/vm/freebsd +2 -2
@@ -23,8 +23,8 @@ class FreeBSDVM(basevm.BaseVM): cd $(mktemp -d /var/tmp/qemu-test.XXXXXX); tar -xf /dev/vtbd1; ./configure {configure_opts}; - gmake -j{jobs} {verbose}; - gmake -j{jobs} check {verbose}; + gmake --output-sync -j{jobs} {verbose}; + gmake --output-sync -j{jobs} check {verbose}; """ def build_image(self, img):
tests/vm/netbsd +2 -2
@@ -23,8 +23,8 @@ class NetBSDVM(basevm.BaseVM): cd $(mktemp -d /var/tmp/qemu-test.XXXXXX); tar -xf /dev/rld1a; ./configure --python=python2.7 {configure_opts}; - gmake -j{jobs} {verbose}; - gmake -j{jobs} check {verbose}; + gmake --output-sync -j{jobs} {verbose}; + gmake --output-sync -j{jobs} check {verbose}; """ def build_image(self, img):
tests/vm/openbsd +2 -2
@@ -23,9 +23,9 @@ class OpenBSDVM(basevm.BaseVM): cd $(mktemp -d /var/tmp/qemu-test.XXXXXX); tar -xf /dev/rsd1c; ./configure --cc=x86_64-unknown-openbsd6.1-gcc-4.9.4 --python=python2.7 {configure_opts}; - gmake -j{jobs} {verbose}; + gmake --output-sync -j{jobs} {verbose}; # XXX: "gmake check" seems to always hang or fail - #gmake -j{jobs} check {verbose}; + #gmake --output-sync -j{jobs} check {verbose}; """ def build_image(self, img):
tests/vm/ubuntu.i386 +2 -2
@@ -25,8 +25,8 @@ class UbuntuX86VM(basevm.BaseVM): sudo chmod a+r /dev/vdb; tar -xf /dev/vdb; ./configure {configure_opts}; - make -j{jobs}; - make check -j{jobs} {verbose}; + make --output-sync -j{jobs}; + make --output-sync check -j{jobs} {verbose}; """ def _gen_cloud_init_iso(self):
Signature · 1 line
2.17.1
Quoted 11 lines · Peter Maydell
The setup I had for my BSD VMs broke today, so I thought I'd have a look at using the tests/vm/ support for building QEMU inside BSD VMs rather than re-rolling my own. This patchset fixes some rough edges I ran into along the way:
* fixes support for non-KVM accelerators
* propagates J=n setting into 'make check' in the VM
* propagates V=1 setting into 'make' and 'make check' in the VM
* uses --output-sync so that J=n settings don't mangle output
* bumps the RAM settings so J=n doesn't cause the guest to run out of memory and kill the compiler
Quoted 5 lines
Ideally I'd like to be able to separately invoke commands for "build in VM" and "run make check in VM for that build"; for instance I only want V=1 on the make-check, not the make, and in some cases might want to do a build but not check, and so on. But that seemed too complicated for the moment.
If we can limit the abstraction to "build" and "check" (or "test"), it shouldn't be hard to add a --build-only option to the Python main() and VM_BUILD_ONLY=1 to Makefile.
Quoted 5 lines
Is it possible for the VMs to be persistent? Currently it looks like they throw away their contents and start afresh for every invocation. Doing build tests as incremental is faster than doing every one as a from-clean...
Yes, we'll do that in 3.1.
Quoted 4 lines
Also, I notice that the OpenBSD VM setup is using SDL 1.2, which means that configure complains and suggests switching to SDL 2.0. How do we update the base image?
I prepared the image by hand and uploaded it because I couldn't find a better way. So the easist way to update is probably booting the image by hand, do the modifications, then upload it again.
Quoted 24 lines
thanks
-- PMMPeter Maydell (5):
tests/vm: Use -cpu max rather than -cpu host tests/vm: Pass the jobs parallelism setting to 'make check' tests/vm: Propagate V=1 down into the make inside the VM tests/vm: Bump guest RAM up from 2G to 4G tests/vm: Use make's --output-sync optiontests/vm/Makefile.include | 1 + docs/devel/testing.rst | 1 + tests/vm/basevm.py | 9 ++++++--- tests/vm/freebsd | 4 ++-- tests/vm/netbsd | 4 ++-- tests/vm/openbsd | 4 ++-- tests/vm/ubuntu.i386 | 4 ++-- 7 files changed, 16 insertions(+), 11 deletions(-)Signature · 1 line
2.17.1
Fam Zheng
AppliedQuoted 10 lines · Peter Maydell
The setup I had for my BSD VMs broke today, so I thought I'd have a look at using the tests/vm/ support for building QEMU inside BSD VMs rather than re-rolling my own. This patchset fixes some rough edges I ran into along the way:
* fixes support for non-KVM accelerators
* propagates J=n setting into 'make check' in the VM
* propagates V=1 setting into 'make' and 'make check' in the VM
* uses --output-sync so that J=n settings don't mangle output
* bumps the RAM settings so J=n doesn't cause the guest to run out of memory and kill the compiler
Queued for 3.1. Thanks!
Fam