tests/vm: various trivial fixes
cover tests/vm: various trivial fixes
Hi,
These are various fixes I added to have the VM tests working for me.
Regards,
Phil.
Philippe Mathieu-Daudé (4):
tests/vm: Support proxy / corporate firewall tests/vm: Add a dependency to qemu-img tests/vm: Only use -cpu 'host' if KVM is available tests/vm: Add flex and bison to the vm image
tests/vm/Makefile.include | 3 +++ tests/vm/basevm.py | 3 ++- tests/vm/ubuntu.i386 | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-)
Signature · 1 line
2.18.0
PATCH 1/4 tests/vm: Support proxy / corporate firewall
If ftp_proxy/http_proxy/https_proxy standard environment variables are available, pass them to the vm images.
As per 06cc3551714:
This is required when building behind corporate proxy/firewall, but also help when using local cache server (ie: apt/yum).
--- tests/vm/ubuntu.i386 | 4 ++++ 1 file changed, 4 insertions(+)
tests/vm/ubuntu.i386 +4 -0
@@ -68,6 +68,10 @@ class UbuntuX86VM(basevm.BaseVM): self.boot(img_tmp, extra_args = ["-cdrom", self._gen_cloud_init_iso()]) self.wait_ssh() self.ssh_root_check("touch /etc/cloud/cloud-init.disabled") + for k, v in os.environ.iteritems(): + kl = k.lower() + if kl in ['ftp_proxy', 'http_proxy', 'https_proxy']: + self.ssh_root_check("echo 'Acquire::{}::Proxy \"{}\";' >> /etc/apt/apt.conf.d/01proxy".format(kl[:-6].upper(), v)) self.ssh_root_check("apt-get update") self.ssh_root_check("apt-get install -y cloud-initramfs-growroot") # Don't check the status in case the guest hang up too quickly
Signature · 1 line
2.18.0
Re: [Qemu-devel] [PATCH 1/4] tests/vm: Support proxy / corporate firewall
Quoted 17 lines · Philippe Mathieu-Daudé
If ftp_proxy/http_proxy/https_proxy standard environment variables are available, pass them to the vm images.
As per
06cc3551714:
This is required when building behind corporate proxy/firewall, but also help when using local cache server (ie: apt/yum).Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/vm/ubuntu.i386 | 4 ++++ 1 file changed, 4 insertions(+)tests/vm/ubuntu.i386 +0
-0
tests/vm/ubuntu.i386 class UbuntuX86VM(basevm.BaseVM): · line 74
Quoted 7 lines
tests/vm/ubuntu.i386 +4
-0@@ -68,6 +68,10 @@ class UbuntuX86VM(basevm.BaseVM): self.boot(img_tmp, extra_args = ["-cdrom", self._gen_cloud_init_iso()]) self.wait_ssh() self.ssh_root_check("touch /etc/cloud/cloud-init.disabled") + for k, v in os.environ.iteritems(): + kl = k.lower() + if kl in ['ftp_proxy', 'http_proxy', 'https_proxy']: + self.ssh_root_check("echo 'Acquire::{}::Proxy \"{}\";' >> /etc/apt/apt.conf.d/01proxy".format(kl[:-6].upper(), v))
Reasonable, but do we want it for other apps and images? How about setting these env vars to ssh commands?
Fam
Quoted 6 lines
tests/vm/ubuntu.i386 +0
-0self.ssh_root_check("apt-get update") self.ssh_root_check("apt-get install -y cloud-initramfs-growroot") # Don't check the status in case the guest hang up too quicklySignature · 1 line
2.18.0
Re: [Qemu-devel] [PATCH 1/4] tests/vm: Support proxy / corporate firewall
Hi Fam,
Quoted 13 lines · Fam Zheng
Quoted 12 lines · Philippe Mathieu-Daudé
If ftp_proxy/http_proxy/https_proxy standard environment variables are available, pass them to the vm images.
As per
06cc3551714:
This is required when building behind corporate proxy/firewall, but also help when using local cache server (ie: apt/yum).Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/vm/ubuntu.i386 | 4 ++++ 1 file changed, 4 insertions(+)
Quoted 15 lines
tests/vm/ubuntu.i386 class UbuntuX86VM(basevm.BaseVM): · line 74
Quoted 12 lines
tests/vm/ubuntu.i386 +4
-0@@ -68,6 +68,10 @@ class UbuntuX86VM(basevm.BaseVM): self.boot(img_tmp, extra_args = ["-cdrom", self._gen_cloud_init_iso()]) self.wait_ssh() self.ssh_root_check("touch /etc/cloud/cloud-init.disabled") + for k, v in os.environ.iteritems(): + kl = k.lower() + if kl in ['ftp_proxy', 'http_proxy', 'https_proxy']: + self.ssh_root_check("echo 'Acquire::{}::Proxy \"{}\";' >> /etc/apt/apt.conf.d/01proxy".format(kl[:-6].upper(), v))Reasonable, but do we want it for other apps and images? How about setting these env vars to ssh commands?
I see 2 different network usages:
1/ how the guest connect to the outer world, this goes via the firewall. Here the change only affects apt* based commands (via the apt.conf file). Do we have other commands requiring network connectivity? If we have, then yes, we should add the same env vars in the guest.
One case I think of is "git submodule init" calling "git clone".
2/ how the host connect to the guest (ex: SSH).
In this case we use the loopback interface, thus no need to change.
Quoted 6 lines
Quoted 6 lines
tests/vm/ubuntu.i386 +0
-0self.ssh_root_check("apt-get update") self.ssh_root_check("apt-get install -y cloud-initramfs-growroot") # Don't check the status in case the guest hang up too quicklySignature · 1 line
2.18.0
Re: [Qemu-devel] [PATCH 1/4] tests/vm: Support proxy / corporate firewall
Quoted 32 lines · Philippe Mathieu-Daudé
Hi Fam,
Quoted 13 lines · Fam Zheng
Quoted 12 lines · Philippe Mathieu-Daudé
If ftp_proxy/http_proxy/https_proxy standard environment variables are available, pass them to the vm images.
As per
06cc3551714:
This is required when building behind corporate proxy/firewall, but also help when using local cache server (ie: apt/yum).Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/vm/ubuntu.i386 | 4 ++++ 1 file changed, 4 insertions(+)Quoted 15 lines
tests/vm/ubuntu.i386 class UbuntuX86VM(basevm.BaseVM): · line 74
Quoted 12 lines
tests/vm/ubuntu.i386 +4
-0@@ -68,6 +68,10 @@ class UbuntuX86VM(basevm.BaseVM): self.boot(img_tmp, extra_args = ["-cdrom", self._gen_cloud_init_iso()]) self.wait_ssh() self.ssh_root_check("touch /etc/cloud/cloud-init.disabled") + for k, v in os.environ.iteritems(): + kl = k.lower() + if kl in ['ftp_proxy', 'http_proxy', 'https_proxy']: + self.ssh_root_check("echo 'Acquire::{}::Proxy \"{}\";' >> /etc/apt/apt.conf.d/01proxy".format(kl[:-6].upper(), v))Reasonable, but do we want it for other apps and images? How about setting these env vars to ssh commands?
Quoted 7 lines
I see 2 different network usages:
1/ how the guest connect to the outer world, this goes via the firewall. Here the change only affects apt* based commands (via the apt.conf file). Do we have other commands requiring network connectivity? If we have, then yes, we should add the same env vars in the guest.
One case I think of is "git submodule init" calling "git clone".
Yes, I think this case is what we are looking at here. But this patch is very
specific: it only affects one command in one VM, albeit we don't have many. Doing this means we'll need to specially open code tests/vm/fedora, tests/vm/debian, or any other images we introduce later, to be consistent with ubuntu.i386. It is a poor way to do this, IMO.
What I mean is, can we do it more generically? Like setting the env var in guest /etc/profile or change BaseVM._ssh_do() to inject env vars:
tests/vm/basevm.py +3 -1
@@ -106,7 +106,9 @@ class BaseVM(object): if interactive: ssh_cmd += ['-t'] assert not isinstance(cmd, str) - ssh_cmd += ["%[email protected]" % user] + list(cmd) + env = ["%s=%s" % (k, v) for k, v in os.environ.items() if k in \ + ["ftp_proxy", "http_proxy", "https_proxy"]] + ssh_cmd += ["%[email protected]" % user] + env + list(cmd) logging.debug("ssh_cmd: %s", " ".join(ssh_cmd)) r = subprocess.call(ssh_cmd) if check and r != 0:
PATCH 2/4 tests/vm: Add a dependency to qemu-img
In reply to Philippe Mathieu-DaudéBefore the first use, the VM image are resized with qemu-img.
Add a dependency to the qemu-img tool to fix:
$ make vm-build-ubuntu.i386
Traceback (most recent call last):
File "source/qemu/tests/vm/basevm.py", line 236, in main
return vm.build_image(args.image)
File "tests/vm/ubuntu.i386", line 67, in build_image
subprocess.check_call(["qemu-img", "resize", img_tmp, "50G"])
OSError: [Errno 2] No such file or directory
tests/vm/Makefile.include:23: recipe for target 'tests/vm/ubuntu.i386.img' failed
make: *** [tests/vm/ubuntu.i386.img] Error 2--- tests/vm/Makefile.include | 3 +++ 1 file changed, 3 insertions(+)
tests/vm/Makefile.include +3 -0
@@ -17,10 +17,13 @@ vm-test: vm-build-all: $(addprefix vm-build-, $(IMAGES)) +$(IMAGE_FILES): qemu-img$(EXESUF) + tests/vm/%.img: $(SRC_PATH)/tests/vm/% \ $(SRC_PATH)/tests/vm/basevm.py \ $(SRC_PATH)/tests/vm/Makefile.include $(call quiet-command, \ + PATH=$(PATH):. \ $< \ $(if $(V)$(DEBUG), --debug) \ --image "$@" \
Signature · 1 line
2.18.0
Re: [Qemu-devel] [PATCH 2/4] tests/vm: Add a dependency to qemu-img
Quoted 24 lines · Philippe Mathieu-Daudé
Before the first use, the VM image are resized with qemu-img.
Add a dependency to the qemu-img tool to fix:
$ make vm-build-ubuntu.i386 Traceback (most recent call last): File "source/qemu/tests/vm/basevm.py", line 236, in main return vm.build_image(args.image) File "tests/vm/ubuntu.i386", line 67, in build_image subprocess.check_call(["qemu-img", "resize", img_tmp, "50G"]) OSError: [Errno 2] No such file or directory tests/vm/Makefile.include:23: recipe for target 'tests/vm/ubuntu.i386.img' failed make: *** [tests/vm/ubuntu.i386.img] Error 2Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/vm/Makefile.include | 3 +++ 1 file changed, 3 insertions(+)tests/vm/Makefile.include +0
-0
tests/vm/Makefile.include vm-test: · line 26
Quoted 10 lines
tests/vm/Makefile.include +3
-0@@ -17,10 +17,13 @@ vm-test: vm-build-all: $(addprefix vm-build-, $(IMAGES)) +$(IMAGE_FILES): qemu-img$(EXESUF) + tests/vm/%.img: $(SRC_PATH)/tests/vm/% \ $(SRC_PATH)/tests/vm/basevm.py \ $(SRC_PATH)/tests/vm/Makefile.include $(call quiet-command, \ + PATH=$(PATH):. \
Oh since we want to use the shell PATH and not a make variable, it could be cleaner to rather use:
+ PATH=$$PATH:. \
Quoted 4 lines
tests/vm/Makefile.include +0
-0$< \ $(if $(V)$(DEBUG), --debug) \ --image "$@" \
Re: [Qemu-devel] [PATCH 2/4] tests/vm: Add a dependency to qemu-img
In reply to Philippe Mathieu-DaudéQuoted 24 lines · Philippe Mathieu-Daudé
Before the first use, the VM image are resized with qemu-img.
Add a dependency to the qemu-img tool to fix:
$ make vm-build-ubuntu.i386 Traceback (most recent call last): File "source/qemu/tests/vm/basevm.py", line 236, in main return vm.build_image(args.image) File "tests/vm/ubuntu.i386", line 67, in build_image subprocess.check_call(["qemu-img", "resize", img_tmp, "50G"]) OSError: [Errno 2] No such file or directory tests/vm/Makefile.include:23: recipe for target 'tests/vm/ubuntu.i386.img' failed make: *** [tests/vm/ubuntu.i386.img] Error 2Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/vm/Makefile.include | 3 +++ 1 file changed, 3 insertions(+)tests/vm/Makefile.include +0
-0
tests/vm/Makefile.include vm-test: · line 20
Quoted 4 lines
tests/vm/Makefile.include +1
-0@@ -17,10 +17,13 @@ vm-test: vm-build-all: $(addprefix vm-build-, $(IMAGES)) +$(IMAGE_FILES): qemu-img$(EXESUF)
No, please don't do this. Let's keep on supporting vm tests from a clean source tree. Similar to qemu_bin, this can be handled in basevm.py.
Fam
Quoted 12 lines
tests/vm/Makefile.include +2
-0+ tests/vm/%.img: $(SRC_PATH)/tests/vm/% \ $(SRC_PATH)/tests/vm/basevm.py \ $(SRC_PATH)/tests/vm/Makefile.include $(call quiet-command, \ + PATH=$(PATH):. \ $< \ $(if $(V)$(DEBUG), --debug) \ --image "$@" \Signature · 1 line
2.18.0
Re: [Qemu-devel] [PATCH 2/4] tests/vm: Add a dependency to qemu-img
Quoted 26 lines · Fam Zheng
Quoted 25 lines · Philippe Mathieu-Daudé
Before the first use, the VM image are resized with qemu-img.
Add a dependency to the qemu-img tool to fix:
$ make vm-build-ubuntu.i386 Traceback (most recent call last): File "source/qemu/tests/vm/basevm.py", line 236, in main return vm.build_image(args.image) File "tests/vm/ubuntu.i386", line 67, in build_image subprocess.check_call(["qemu-img", "resize", img_tmp, "50G"]) OSError: [Errno 2] No such file or directory tests/vm/Makefile.include:23: recipe for target 'tests/vm/ubuntu.i386.img' failed make: *** [tests/vm/ubuntu.i386.img] Error 2Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/vm/Makefile.include | 3 +++ 1 file changed, 3 insertions(+)tests/vm/Makefile.include +0
-0@@ -17,10 +17,13 @@ vm-test:
Quoted 6 lines
tests/vm/Makefile.include vm-test: · line 20
Quoted 3 lines
tests/vm/Makefile.include +1
-0vm-build-all: $(addprefix vm-build-, $(IMAGES)) +$(IMAGE_FILES): qemu-img$(EXESUF)No, please don't do this. Let's keep on supporting vm tests from a clean source tree. Similar to
qemu_bin, this can be handled inbasevm.py.
OK.
Quoted 13 lines
Quoted 12 lines
tests/vm/Makefile.include +2
-0+ tests/vm/%.img: $(SRC_PATH)/tests/vm/% \ $(SRC_PATH)/tests/vm/basevm.py \ $(SRC_PATH)/tests/vm/Makefile.include $(call quiet-command, \ + PATH=$(PATH):. \ $< \ $(if $(V)$(DEBUG), --debug) \ --image "$@" \Signature · 1 line
2.18.0
Re: [Qemu-devel] [PATCH 2/4] tests/vm: Add a dependency to qemu-img
Hi Fam,
Quoted 27 lines · Philippe Mathieu-Daudé
Quoted 26 lines · Fam Zheng
Quoted 25 lines · Philippe Mathieu-Daudé
Before the first use, the VM image are resized with qemu-img.
Add a dependency to the qemu-img tool to fix:
$ make vm-build-ubuntu.i386 Traceback (most recent call last): File "source/qemu/tests/vm/basevm.py", line 236, in main return vm.build_image(args.image) File "tests/vm/ubuntu.i386", line 67, in build_image subprocess.check_call(["qemu-img", "resize", img_tmp, "50G"]) OSError: [Errno 2] No such file or directory tests/vm/Makefile.include:23: recipe for target 'tests/vm/ubuntu.i386.img' failed make: *** [tests/vm/ubuntu.i386.img] Error 2Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/vm/Makefile.include | 3 +++ 1 file changed, 3 insertions(+)tests/vm/Makefile.include +0
-0@@ -17,10 +17,13 @@ vm-test:
Quoted 8 lines
Quoted 6 lines
tests/vm/Makefile.include vm-test: · line 20
Quoted 3 lines
tests/vm/Makefile.include +1
-0vm-build-all: $(addprefix vm-build-, $(IMAGES)) +$(IMAGE_FILES): qemu-img$(EXESUF)No, please don't do this. Let's keep on supporting vm tests from a clean source tree. Similar to
qemu_bin, this can be handled inbasevm.py.OK.
The ubuntu.i386 VM is the only one using the qemu-img tool in his build_image() method implementation. Is it OK to add this check there? The basevm.build_image() is only an abstract method.
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
tests/vm/Makefile.include +2
-0+ tests/vm/%.img: $(SRC_PATH)/tests/vm/% \ $(SRC_PATH)/tests/vm/basevm.py \ $(SRC_PATH)/tests/vm/Makefile.include $(call quiet-command, \ + PATH=$(PATH):. \ $< \ $(if $(V)$(DEBUG), --debug) \ --image "$@" \Signature · 1 line
2.18.0
Re: [Qemu-devel] [PATCH 2/4] tests/vm: Add a dependency to qemu-img
Quoted 37 lines · Philippe Mathieu-Daudé
Hi Fam,
Quoted 34 lines · Philippe Mathieu-Daudé
Quoted 32 lines · Fam Zheng
Quoted 24 lines · Philippe Mathieu-Daudé
Before the first use, the VM image are resized with qemu-img.
Add a dependency to the qemu-img tool to fix:
$ make vm-build-ubuntu.i386 Traceback (most recent call last): File "source/qemu/tests/vm/basevm.py", line 236, in main return vm.build_image(args.image) File "tests/vm/ubuntu.i386", line 67, in build_image subprocess.check_call(["qemu-img", "resize", img_tmp, "50G"]) OSError: [Errno 2] No such file or directory tests/vm/Makefile.include:23: recipe for target 'tests/vm/ubuntu.i386.img' failed make: *** [tests/vm/ubuntu.i386.img] Error 2Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/vm/Makefile.include | 3 +++ 1 file changed, 3 insertions(+)tests/vm/Makefile.include +0
-0tests/vm/Makefile.include vm-test: · line 20
Quoted 4 lines
tests/vm/Makefile.include +1
-0@@ -17,10 +17,13 @@ vm-test: vm-build-all: $(addprefix vm-build-, $(IMAGES)) +$(IMAGE_FILES): qemu-img$(EXESUF)No, please don't do this. Let's keep on supporting vm tests from a clean source tree. Similar to
qemu_bin, this can be handled inbasevm.py.
Quoted 5 lines
Quoted 1 line
OK.
The ubuntu.i386 VM is the only one using the qemu-img tool in his
build_image()method implementation. Is it OK to add this check there? Thebasevm.build_image()is only an abstract method.
Maybe you can add a BaseVM.qemu_img() method that looks up for available qemu-img on the system or build dir.
Fam
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
tests/vm/Makefile.include +2
-0+ tests/vm/%.img: $(SRC_PATH)/tests/vm/% \ $(SRC_PATH)/tests/vm/basevm.py \ $(SRC_PATH)/tests/vm/Makefile.include $(call quiet-command, \ + PATH=$(PATH):. \ $< \ $(if $(V)$(DEBUG), --debug) \ --image "$@" \Signature · 1 line
2.18.0
PATCH 3/4 tests/vm: Only use -cpu 'host' if KVM is available
In reply to Philippe Mathieu-DaudéIf KVM is not available, then use the 'max' cpu.
This fixes:
ERROR:root:Log:
ERROR:root:qemu-system-x86_64: CPU model 'host' requires KVM
Failed to prepare guest environment
error: [Errno 104] Connection reset by peer source/qemu/tests/vm/Makefile.include:25: recipe for target 'tests/vm/ubuntu.i386.img' failed
make: *** [tests/vm/ubuntu.i386.img] Error 2
--- tests/vm/basevm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tests/vm/basevm.py +2 -1
@@ -65,7 +65,6 @@ class BaseVM(object): self._stdout = self._devnull self._args = [ \ "-nodefaults", "-m", "2G", - "-cpu", "host", "-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",
@@ -73,9 +72,11 @@ class BaseVM(object): if vcpus: self._args += ["-smp", str(vcpus)] if os.access("/dev/kvm", os.R_OK | os.W_OK): + self._args += ["-cpu", "host"] self._args += ["-enable-kvm"] else: logging.info("KVM not available, not using -enable-kvm") + self._args += ["-cpu", "max"] self._data_args = [] def _download_with_cache(self, url, sha256sum=None):
Signature · 1 line
2.18.0
PATCH 4/4 tests/vm: Add flex and bison to the vm image
In reply to Philippe Mathieu-DaudéSimilar to 79f24568e5e70, this fixes the following warnings:
CHK version_gen.h
LEX convert-dtsv0-lexer.lex.c
make[1]: flex: Command not found
BISON dtc-parser.tab.c
make[1]: bison: Command not found
LEX dtc-lexer.lex.c
make[1]: flex: Command not found
--- tests/vm/ubuntu.i386 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/vm/ubuntu.i386 +1 -1
@@ -81,7 +81,7 @@ class UbuntuX86VM(basevm.BaseVM): # The previous update sometimes doesn't survive a reboot, so do it again self.ssh_root_check("apt-get update") self.ssh_root_check("apt-get build-dep -y qemu") - self.ssh_root_check("apt-get install -y libfdt-dev") + self.ssh_root_check("apt-get install -y libfdt-dev flex bison") self.ssh_root("poweroff") self.wait() if os.path.exists(img):
Signature · 1 line
2.18.0
Fam Zheng
AppliedQuoted 3 lines · Philippe Mathieu-Daudé
Hi,
These are various fixes I added to have the VM tests working for me.
Queued the last two patches. Thanks.
Fam