mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 18:44:58 -06:00
simplebench/bench-backup: support qcow2 source files
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> Reviewed-by: John Snow <jsnow@redhat.com>
This commit is contained in:
parent
4ad7a5c065
commit
0dc9f816d4
2 changed files with 11 additions and 1 deletions
|
@ -58,6 +58,8 @@ def bench(args):
|
||||||
|
|
||||||
if src == 'nbd':
|
if src == 'nbd':
|
||||||
source = nbd_drv
|
source = nbd_drv
|
||||||
|
elif args.qcow2_sources:
|
||||||
|
source = drv_qcow2(drv_file(dirs[src] + '/test-source.qcow2'))
|
||||||
else:
|
else:
|
||||||
source = drv_file(dirs[src] + '/test-source')
|
source = drv_file(dirs[src] + '/test-source')
|
||||||
|
|
||||||
|
@ -199,6 +201,9 @@ Tests, in form source-dir-label:target-dir-label''',
|
||||||
Use compressed backup. It automatically means
|
Use compressed backup. It automatically means
|
||||||
automatically creating qcow2 target with
|
automatically creating qcow2 target with
|
||||||
lazy_refcounts for each test run''', action='store_true')
|
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='''\
|
p.add_argument('--target-cache', help='''\
|
||||||
Setup cache for target nodes. Options:
|
Setup cache for target nodes. Options:
|
||||||
direct: default, use O_DIRECT and aio=native
|
direct: default, use O_DIRECT and aio=native
|
||||||
|
|
|
@ -88,6 +88,11 @@ def get_image_size(path):
|
||||||
return json.loads(out)['virtual-size']
|
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)
|
||||||
|
|
||||||
|
|
||||||
# Bench backup or mirror
|
# Bench backup or mirror
|
||||||
def bench_block_copy(qemu_binary, cmd, cmd_options, source, target):
|
def bench_block_copy(qemu_binary, cmd, cmd_options, source, target):
|
||||||
"""Helper to run bench_block_job() for mirror or backup"""
|
"""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',
|
subprocess.run(['qemu-img', 'create', '-f', 'qcow2',
|
||||||
target['file']['filename'],
|
target['file']['filename'],
|
||||||
str(get_image_size(source['filename']))],
|
str(get_blockdev_size(source))],
|
||||||
stdout=subprocess.DEVNULL,
|
stdout=subprocess.DEVNULL,
|
||||||
stderr=subprocess.DEVNULL, check=True)
|
stderr=subprocess.DEVNULL, check=True)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue