diff mbox series

[2/4] tests/vm: Add a dependency to qemu-img

Message ID 20180628153535.1411-3-f4bug@amsat.org
State New
Headers show
Series tests/vm: various trivial fixes | expand

Commit Message

Philippe Mathieu-Daudé June 28, 2018, 3:35 p.m. UTC
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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/vm/Makefile.include | 3 +++
 1 file changed, 3 insertions(+)

Comments

Philippe Mathieu-Daudé June 28, 2018, 3:47 p.m. UTC | #1
On 06/28/2018 12:35 PM, Philippe Mathieu-Daudé wrote:
> 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
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/vm/Makefile.include | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include
> index 5daa2a3b73..e5e8146267 100644
> --- a/tests/vm/Makefile.include
> +++ b/tests/vm/Makefile.include
> @@ -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:. \

>  		$< \
>  		$(if $(V)$(DEBUG), --debug) \
>  		--image "$@" \
>
Fam Zheng July 2, 2018, 7:18 a.m. UTC | #2
On Thu, 06/28 12:35, Philippe Mathieu-Daudé wrote:
> 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
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/vm/Makefile.include | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include
> index 5daa2a3b73..e5e8146267 100644
> --- a/tests/vm/Makefile.include
> +++ b/tests/vm/Makefile.include
> @@ -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

> +
>  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 "$@" \
> -- 
> 2.18.0
>
Philippe Mathieu-Daudé July 2, 2018, 3:19 p.m. UTC | #3
On 07/02/2018 04:18 AM, Fam Zheng wrote:
> On Thu, 06/28 12:35, Philippe Mathieu-Daudé wrote:
>> 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
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>  tests/vm/Makefile.include | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include
>> index 5daa2a3b73..e5e8146267 100644
>> --- a/tests/vm/Makefile.include
>> +++ b/tests/vm/Makefile.include
>> @@ -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.

OK.

>> +
>>  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 "$@" \
>> -- 
>> 2.18.0
>>
>
Philippe Mathieu-Daudé July 3, 2018, 3:56 p.m. UTC | #4
Hi Fam,

On 07/02/2018 12:19 PM, Philippe Mathieu-Daudé wrote:
> On 07/02/2018 04:18 AM, Fam Zheng wrote:
>> On Thu, 06/28 12:35, Philippe Mathieu-Daudé wrote:
>>> 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
>>>
>>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>> ---
>>>  tests/vm/Makefile.include | 3 +++
>>>  1 file changed, 3 insertions(+)
>>>
>>> diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include
>>> index 5daa2a3b73..e5e8146267 100644
>>> --- a/tests/vm/Makefile.include
>>> +++ b/tests/vm/Makefile.include
>>> @@ -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.
> 
> 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.

>>> +
>>>  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 "$@" \
>>> -- 
>>> 2.18.0
>>>
>>
Fam Zheng July 11, 2018, 2:16 a.m. UTC | #5
On Tue, 07/03 12:56, Philippe Mathieu-Daudé wrote:
> Hi Fam,
> 
> On 07/02/2018 12:19 PM, Philippe Mathieu-Daudé wrote:
> > On 07/02/2018 04:18 AM, Fam Zheng wrote:
> >> On Thu, 06/28 12:35, Philippe Mathieu-Daudé wrote:
> >>> 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
> >>>
> >>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> >>> ---
> >>>  tests/vm/Makefile.include | 3 +++
> >>>  1 file changed, 3 insertions(+)
> >>>
> >>> diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include
> >>> index 5daa2a3b73..e5e8146267 100644
> >>> --- a/tests/vm/Makefile.include
> >>> +++ b/tests/vm/Makefile.include
> >>> @@ -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.
> > 
> > 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.

Maybe you can add a BaseVM.qemu_img() method that looks up for available
qemu-img on the system or build dir.

Fam

> 
> >>> +
> >>>  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 "$@" \
> >>> -- 
> >>> 2.18.0
> >>>
> >>
diff mbox series

Patch

diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include
index 5daa2a3b73..e5e8146267 100644
--- a/tests/vm/Makefile.include
+++ b/tests/vm/Makefile.include
@@ -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 "$@" \