qemu-block
[Top][All Lists]
Advanced

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

Re: [PATCH v2 6/8] simplebench/bench-backup: support qcow2 source files


From: John Snow
Subject: Re: [PATCH v2 6/8] simplebench/bench-backup: support qcow2 source files
Date: Thu, 4 Mar 2021 20:43:28 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0

On 3/4/21 5:17 AM, Vladimir Sementsov-Ogievskiy wrote:
Add support for qcow2 source. New option says to use test-source.qcow2
instead of test-source. Of course, test-source.qcow2 should be
precreated.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
  scripts/simplebench/bench-backup.py    | 5 +++++
  scripts/simplebench/bench_block_job.py | 7 ++++++-
  2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/scripts/simplebench/bench-backup.py 
b/scripts/simplebench/bench-backup.py
index fbc85f266f..a2120fcbf0 100755
--- a/scripts/simplebench/bench-backup.py
+++ b/scripts/simplebench/bench-backup.py
@@ -58,6 +58,8 @@ def bench(args):
if src == 'nbd':
              source = nbd_drv
+        elif args.qcow2_sources:
+            source = drv_qcow2(drv_file(dirs[src] + '/test-source.qcow2'))
          else:
              source = drv_file(dirs[src] + '/test-source')
@@ -199,6 +201,9 @@ def __call__(self, parser, namespace, values, option_string=None):
  Use compressed backup. It automatically means
  automatically creating qcow2 target with
  lazy_refcounts for each test run''', action='store_true')
+    p.add_argument('--qcow2-sources', help='''\
+Use test-source.qcow2 images as sources instead of
+test-source raw images''', action='store_true')
      p.add_argument('--target-cache', help='''\
  Setup cache for target nodes. Options:
     direct: default, use O_DIRECT and aio=native
diff --git a/scripts/simplebench/bench_block_job.py 
b/scripts/simplebench/bench_block_job.py
index 71d2e489c8..4f03c12169 100755
--- a/scripts/simplebench/bench_block_job.py
+++ b/scripts/simplebench/bench_block_job.py
@@ -88,6 +88,11 @@ def get_image_size(path):
      return json.loads(out)['virtual-size']
+def get_blockdev_size(obj):
+    img = obj['filename'] if 'filename' in obj else obj['file']['filename']
+    return get_image_size(img)
+

Well, as long as it works :)

+
  # Bench backup or mirror
  def bench_block_copy(qemu_binary, cmd, cmd_options, source, target):
      """Helper to run bench_block_job() for mirror or backup"""
@@ -101,7 +106,7 @@ def bench_block_copy(qemu_binary, cmd, cmd_options, source, 
target):
subprocess.run(['qemu-img', 'create', '-f', 'qcow2',
                          target['file']['filename'],
-                        str(get_image_size(source['filename']))],
+                        str(get_blockdev_size(source))],
                         stdout=subprocess.DEVNULL,
                         stderr=subprocess.DEVNULL, check=True)

Reviewed-by: John Snow <jsnow@redhat.com>




reply via email to

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