All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] iotests: Check for zstd support
@ 2022-03-02 12:45 Hanna Reitz
  2022-03-02 12:45 ` [PATCH v2 1/3] iotests.py: Add supports_qcow2_zstd_compression() Hanna Reitz
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Hanna Reitz @ 2022-03-02 12:45 UTC (permalink / raw)
  To: qemu-block
  Cc: Thomas Huth, Kevin Wolf, Hanna Reitz,
	Vladimir Sementsov-Ogievskiy, qemu-devel

Hi,

v1 cover letter:

https://lists.nongnu.org/archive/html/qemu-devel/2022-02/msg04592.html

We have two tests (as far as I know) that use compression_type=zstd for
qcow2 but do not check whether that is actually supported.  Thomas
reported this for 065, but it’s also the case for 303.

This series makes 303 be skipped when zstd is not compiled in, and has
065 use zlib for each of its test cases then (it was made to use zstd
just to improve on coverage, so using zlib as a fallback is perfectly
fine).

v2:
- Add the first patch so that 065 and 303 can use these new iotests.py
  functions to check for zstd support instead of checking for their own
  qemu-img create’s output
- Have 065 fall back to zlib instead of skipping zstd test cases


Hanna Reitz (3):
  iotests.py: Add supports_qcow2_zstd_compression()
  iotests/065: Check for zstd support
  iotests/303: Check for zstd support

 tests/qemu-iotests/065        | 24 ++++++++++++++++++------
 tests/qemu-iotests/303        |  4 +++-
 tests/qemu-iotests/iotests.py | 21 +++++++++++++++++++++
 3 files changed, 42 insertions(+), 7 deletions(-)

-- 
2.34.1



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/3] iotests.py: Add supports_qcow2_zstd_compression()
  2022-03-02 12:45 [PATCH v2 0/3] iotests: Check for zstd support Hanna Reitz
@ 2022-03-02 12:45 ` Hanna Reitz
  2022-03-02 12:45 ` [PATCH v2 2/3] iotests/065: Check for zstd support Hanna Reitz
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Hanna Reitz @ 2022-03-02 12:45 UTC (permalink / raw)
  To: qemu-block
  Cc: Thomas Huth, Kevin Wolf, Hanna Reitz,
	Vladimir Sementsov-Ogievskiy, qemu-devel

Suggested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
---
 tests/qemu-iotests/iotests.py | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 6027780180..ce60abcadc 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -1377,6 +1377,27 @@ def verify_working_luks():
     if not working:
         notrun(reason)
 
+def supports_qcow2_zstd_compression() -> bool:
+    img_file = f'{test_dir}/qcow2-zstd-test.qcow2'
+    (output, status) = \
+        qemu_img_pipe_and_status('create', '-f', 'qcow2',
+                                 '-o', 'compression_type=zstd',
+                                 img_file, '0')
+    try:
+        os.remove(img_file)
+    except OSError:
+        pass
+
+    if status == 1 and \
+            "'compression-type' does not accept value 'zstd'" in output:
+        return False
+    else:
+        return True
+
+def verify_qcow2_zstd_compression():
+    if not supports_qcow2_zstd_compression():
+        notrun('zstd compression not supported')
+
 def qemu_pipe(*args: str) -> str:
     """
     Run qemu with an option to print something and exit (e.g. a help option).
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/3] iotests/065: Check for zstd support
  2022-03-02 12:45 [PATCH v2 0/3] iotests: Check for zstd support Hanna Reitz
  2022-03-02 12:45 ` [PATCH v2 1/3] iotests.py: Add supports_qcow2_zstd_compression() Hanna Reitz
@ 2022-03-02 12:45 ` Hanna Reitz
  2022-03-02 12:45 ` [PATCH v2 3/3] iotests/303: " Hanna Reitz
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Hanna Reitz @ 2022-03-02 12:45 UTC (permalink / raw)
  To: qemu-block
  Cc: Thomas Huth, Kevin Wolf, Hanna Reitz,
	Vladimir Sementsov-Ogievskiy, qemu-devel

Some test cases run in iotest 065 want to run with zstd compression just
for added coverage.  Run them with zlib if there is no zstd support
compiled in.

Reported-by: Thomas Huth <thuth@redhat.com>
Fixes: 12a936171d71f839dc907ff ("iotest 065: explicit compression type")
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
---
 tests/qemu-iotests/065 | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065
index f7c1b68dad..d1a72923c9 100755
--- a/tests/qemu-iotests/065
+++ b/tests/qemu-iotests/065
@@ -24,7 +24,7 @@ import os
 import re
 import json
 import iotests
-from iotests import qemu_img, qemu_img_pipe
+from iotests import qemu_img, qemu_img_pipe, supports_qcow2_zstd_compression
 import unittest
 
 test_img = os.path.join(iotests.test_dir, 'test.img')
@@ -96,11 +96,17 @@ class TestQCow2(TestQemuImgInfo):
 
 class TestQCow3NotLazy(TestQemuImgInfo):
     '''Testing a qcow2 version 3 image with lazy refcounts disabled'''
-    img_options = 'compat=1.1,lazy_refcounts=off,compression_type=zstd'
+    if supports_qcow2_zstd_compression():
+        compression_type = 'zstd'
+    else:
+        compression_type = 'zlib'
+
+    img_options = 'compat=1.1,lazy_refcounts=off'
+    img_options += f',compression_type={compression_type}'
     json_compare = { 'compat': '1.1', 'lazy-refcounts': False,
                      'refcount-bits': 16, 'corrupt': False,
-                     'compression-type': 'zstd', 'extended-l2': False }
-    human_compare = [ 'compat: 1.1', 'compression type: zstd',
+                     'compression-type': compression_type, 'extended-l2': False }
+    human_compare = [ 'compat: 1.1', f'compression type: {compression_type}',
                       'lazy refcounts: false', 'refcount bits: 16',
                       'corrupt: false', 'extended l2: false' ]
 
@@ -127,11 +133,17 @@ class TestQCow3NotLazyQMP(TestQMP):
 class TestQCow3LazyQMP(TestQMP):
     '''Testing a qcow2 version 3 image with lazy refcounts enabled, opening
        with lazy refcounts disabled'''
-    img_options = 'compat=1.1,lazy_refcounts=on,compression_type=zstd'
+    if supports_qcow2_zstd_compression():
+        compression_type = 'zstd'
+    else:
+        compression_type = 'zlib'
+
+    img_options = 'compat=1.1,lazy_refcounts=on'
+    img_options += f',compression_type={compression_type}'
     qemu_options = 'lazy-refcounts=off'
     compare = { 'compat': '1.1', 'lazy-refcounts': True,
                 'refcount-bits': 16, 'corrupt': False,
-                'compression-type': 'zstd', 'extended-l2': False }
+                'compression-type': compression_type, 'extended-l2': False }
 
 TestImageInfoSpecific = None
 TestQemuImgInfo = None
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 3/3] iotests/303: Check for zstd support
  2022-03-02 12:45 [PATCH v2 0/3] iotests: Check for zstd support Hanna Reitz
  2022-03-02 12:45 ` [PATCH v2 1/3] iotests.py: Add supports_qcow2_zstd_compression() Hanna Reitz
  2022-03-02 12:45 ` [PATCH v2 2/3] iotests/065: Check for zstd support Hanna Reitz
@ 2022-03-02 12:45 ` Hanna Reitz
  2022-03-22  9:48 ` [PATCH v2 0/3] iotests: " Hanna Reitz
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Hanna Reitz @ 2022-03-02 12:45 UTC (permalink / raw)
  To: qemu-block
  Cc: Thomas Huth, Kevin Wolf, Hanna Reitz,
	Vladimir Sementsov-Ogievskiy, qemu-devel

303 runs two test cases, one of which requires zstd support.
Unfortunately, given that this is not a unittest-style test, we cannot
easily skip that single case, and instead can only skip the whole test.

(Alternatively, we could split this test into a zlib and a zstd part,
but that seems excessive, given that this test is not in auto and thus
likely only run by developers who have zstd support compiled in.)

Fixes: 677e0bae686e7c670a71d1f ("iotest 303: explicit compression type")
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
---
 tests/qemu-iotests/303 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/qemu-iotests/303 b/tests/qemu-iotests/303
index 16c2e10827..25c3e7eaaa 100755
--- a/tests/qemu-iotests/303
+++ b/tests/qemu-iotests/303
@@ -21,10 +21,12 @@
 
 import iotests
 import subprocess
-from iotests import qemu_img_create, qemu_io, file_path, log, filter_qemu_io
+from iotests import qemu_img_create, qemu_io, file_path, log, filter_qemu_io, \
+        verify_qcow2_zstd_compression
 
 iotests.script_initialize(supported_fmts=['qcow2'],
                           unsupported_imgopts=['refcount_bits', 'compat'])
+verify_qcow2_zstd_compression()
 
 disk = file_path('disk')
 chunk = 1024 * 1024
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/3] iotests: Check for zstd support
  2022-03-02 12:45 [PATCH v2 0/3] iotests: Check for zstd support Hanna Reitz
                   ` (2 preceding siblings ...)
  2022-03-02 12:45 ` [PATCH v2 3/3] iotests/303: " Hanna Reitz
@ 2022-03-22  9:48 ` Hanna Reitz
  2022-03-22 10:50   ` Vladimir Sementsov-Ogievskiy
  2022-03-22  9:56 ` Thomas Huth
  2022-03-23 10:46 ` Hanna Reitz
  5 siblings, 1 reply; 8+ messages in thread
From: Hanna Reitz @ 2022-03-22  9:48 UTC (permalink / raw)
  To: qemu-block
  Cc: Kevin Wolf, Thomas Huth, Vladimir Sementsov-Ogievskiy, qemu-devel

Ping

On 02.03.22 13:45, Hanna Reitz wrote:
> Hi,
>
> v1 cover letter:
>
> https://lists.nongnu.org/archive/html/qemu-devel/2022-02/msg04592.html
>
> We have two tests (as far as I know) that use compression_type=zstd for
> qcow2 but do not check whether that is actually supported.  Thomas
> reported this for 065, but it’s also the case for 303.
>
> This series makes 303 be skipped when zstd is not compiled in, and has
> 065 use zlib for each of its test cases then (it was made to use zstd
> just to improve on coverage, so using zlib as a fallback is perfectly
> fine).
>
> v2:
> - Add the first patch so that 065 and 303 can use these new iotests.py
>    functions to check for zstd support instead of checking for their own
>    qemu-img create’s output
> - Have 065 fall back to zlib instead of skipping zstd test cases
>
>
> Hanna Reitz (3):
>    iotests.py: Add supports_qcow2_zstd_compression()
>    iotests/065: Check for zstd support
>    iotests/303: Check for zstd support
>
>   tests/qemu-iotests/065        | 24 ++++++++++++++++++------
>   tests/qemu-iotests/303        |  4 +++-
>   tests/qemu-iotests/iotests.py | 21 +++++++++++++++++++++
>   3 files changed, 42 insertions(+), 7 deletions(-)
>



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/3] iotests: Check for zstd support
  2022-03-02 12:45 [PATCH v2 0/3] iotests: Check for zstd support Hanna Reitz
                   ` (3 preceding siblings ...)
  2022-03-22  9:48 ` [PATCH v2 0/3] iotests: " Hanna Reitz
@ 2022-03-22  9:56 ` Thomas Huth
  2022-03-23 10:46 ` Hanna Reitz
  5 siblings, 0 replies; 8+ messages in thread
From: Thomas Huth @ 2022-03-22  9:56 UTC (permalink / raw)
  To: Hanna Reitz, qemu-block
  Cc: Kevin Wolf, Vladimir Sementsov-Ogievskiy, qemu-devel

On 02/03/2022 13.45, Hanna Reitz wrote:
> Hi,
> 
> v1 cover letter:
> 
> https://lists.nongnu.org/archive/html/qemu-devel/2022-02/msg04592.html
> 
> We have two tests (as far as I know) that use compression_type=zstd for
> qcow2 but do not check whether that is actually supported.  Thomas
> reported this for 065, but it’s also the case for 303.
> 
> This series makes 303 be skipped when zstd is not compiled in, and has
> 065 use zlib for each of its test cases then (it was made to use zstd
> just to improve on coverage, so using zlib as a fallback is perfectly
> fine).
> 
> v2:
> - Add the first patch so that 065 and 303 can use these new iotests.py
>    functions to check for zstd support instead of checking for their own
>    qemu-img create’s output
> - Have 065 fall back to zlib instead of skipping zstd test cases
> 
> 
> Hanna Reitz (3):
>    iotests.py: Add supports_qcow2_zstd_compression()
>    iotests/065: Check for zstd support
>    iotests/303: Check for zstd support
> 
>   tests/qemu-iotests/065        | 24 ++++++++++++++++++------
>   tests/qemu-iotests/303        |  4 +++-
>   tests/qemu-iotests/iotests.py | 21 +++++++++++++++++++++
>   3 files changed, 42 insertions(+), 7 deletions(-)

Thanks, this fixes the failures of 065 and 303 on my system!

Series
Tested-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/3] iotests: Check for zstd support
  2022-03-22  9:48 ` [PATCH v2 0/3] iotests: " Hanna Reitz
@ 2022-03-22 10:50   ` Vladimir Sementsov-Ogievskiy
  0 siblings, 0 replies; 8+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2022-03-22 10:50 UTC (permalink / raw)
  To: Hanna Reitz, qemu-block; +Cc: qemu-devel, Thomas Huth, Kevin Wolf

22.03.2022 12:48, Hanna Reitz wrote:
> Ping
> 
> On 02.03.22 13:45, Hanna Reitz wrote:
>> Hi,
>>
>> v1 cover letter:
>>
>> https://lists.nongnu.org/archive/html/qemu-devel/2022-02/msg04592.html
>>
>> We have two tests (as far as I know) that use compression_type=zstd for
>> qcow2 but do not check whether that is actually supported.  Thomas
>> reported this for 065, but it’s also the case for 303.
>>
>> This series makes 303 be skipped when zstd is not compiled in, and has
>> 065 use zlib for each of its test cases then (it was made to use zstd
>> just to improve on coverage, so using zlib as a fallback is perfectly
>> fine).
>>
>> v2:
>> - Add the first patch so that 065 and 303 can use these new iotests.py
>>    functions to check for zstd support instead of checking for their own
>>    qemu-img create’s output
>> - Have 065 fall back to zlib instead of skipping zstd test cases
>>
>>
>> Hanna Reitz (3):
>>    iotests.py: Add supports_qcow2_zstd_compression()
>>    iotests/065: Check for zstd support
>>    iotests/303: Check for zstd support
>>
>>   tests/qemu-iotests/065        | 24 ++++++++++++++++++------
>>   tests/qemu-iotests/303        |  4 +++-
>>   tests/qemu-iotests/iotests.py | 21 +++++++++++++++++++++
>>   3 files changed, 42 insertions(+), 7 deletions(-)
>>
> 

Reviewed-by: Vladimir Sementsov-Ogievskiy <v.sementsov-og@mail.ru>

-- 
Best regards,
Vladimir


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/3] iotests: Check for zstd support
  2022-03-02 12:45 [PATCH v2 0/3] iotests: Check for zstd support Hanna Reitz
                   ` (4 preceding siblings ...)
  2022-03-22  9:56 ` Thomas Huth
@ 2022-03-23 10:46 ` Hanna Reitz
  5 siblings, 0 replies; 8+ messages in thread
From: Hanna Reitz @ 2022-03-23 10:46 UTC (permalink / raw)
  To: qemu-block; +Cc: Kevin Wolf, Thomas Huth, qemu-devel

On 02.03.22 13:45, Hanna Reitz wrote:
> Hi,
>
> v1 cover letter:
>
> https://lists.nongnu.org/archive/html/qemu-devel/2022-02/msg04592.html
>
> We have two tests (as far as I know) that use compression_type=zstd for
> qcow2 but do not check whether that is actually supported.  Thomas
> reported this for 065, but it’s also the case for 303.
>
> This series makes 303 be skipped when zstd is not compiled in, and has
> 065 use zlib for each of its test cases then (it was made to use zstd
> just to improve on coverage, so using zlib as a fallback is perfectly
> fine).

Thanks a lot for the quick replies to my ping!

Regrettably, I forgot to consider that John’s recent changes would 
remove qemu_img_pipe_and_status(), which is used in patch 1...  I’m 
sorry, but I’ll have to send a v3. :/

Hanna



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-03-23 10:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-02 12:45 [PATCH v2 0/3] iotests: Check for zstd support Hanna Reitz
2022-03-02 12:45 ` [PATCH v2 1/3] iotests.py: Add supports_qcow2_zstd_compression() Hanna Reitz
2022-03-02 12:45 ` [PATCH v2 2/3] iotests/065: Check for zstd support Hanna Reitz
2022-03-02 12:45 ` [PATCH v2 3/3] iotests/303: " Hanna Reitz
2022-03-22  9:48 ` [PATCH v2 0/3] iotests: " Hanna Reitz
2022-03-22 10:50   ` Vladimir Sementsov-Ogievskiy
2022-03-22  9:56 ` Thomas Huth
2022-03-23 10:46 ` Hanna Reitz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.