Block patches for 7.0-rc1:

- iotest fixes:
   - Fix some iotests for riscv targets
   - Use GNU sed in more places where required
   - Meson-related fixes (i.e. to print errors when they occur)
   - Have qemu-img calls (from Python tests) generally raise nicely
     formattable exceptions on errors
   - Fix iotest 207
 - Allow RBD images to be growable by writing zeroes past the end of
   file, fixing qcow2 on rbd
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEEy2LXoO44KeRfAE00ofpA0JgBnN8FAmI5uC4SHGhyZWl0ekBy
 ZWRoYXQuY29tAAoJEKH6QNCYAZzfsPIP/1iRUWmWd9h9m7gX5hSU+TWYXsH+Ua/G
 fKdDHqNlVjQHq6SDN+A3jDCjAV9I91vlHRVIMWXc4QlKbdNdY7yUP1zYKuRTbfig
 UXce6g1NQoZUIlBSHZDqzgEmrvjunwP1U2te2LWliQjmvlTJgdIHYUJn2VgmY3wg
 2vo8exE3YO1FArS9nFsiX/1Ju35Dm4+3w9NkI6KxnKvaFpY++jovVVy2Bj7Jmfsh
 bRnfiQtDVX+0H4FXYS02hDEX4h7PTzsd1DeapVbiiZW9KJrbb0rchTSGc+VKMdkC
 z2XDfU+Hw4jYlNomuWdSZy6qJMNzUaKEqJMji1OiLym4429OAyseL8EO5c6Utjcb
 RRqGKWBOp1ceFZcy8vmQ2Rxc7b3Nc/Jv41Ty7PbyHmrtd2nbgD+AVnlFH9qWDtZo
 clvFSaIHcHaC4k+MppsbGTKvbW7qRYUkdk1B+tFlZytwQpFvM4oK2CF8jNzoLYfY
 qJIvrBqgaBKnYzAGCV4qgH9I0gWY7WHwvwfevHy47rk7XDsErWKMfBFy294TYDyq
 +yU6K1VijWDEn/DdQZMSZQJeE7ByA4cfSSYGRmwtTLOZxmUi4mEBEEo6Lw3x4eI2
 eXj/fhRenbjfE+5p3xmWvEyaVvvyor9oXUPH45HN/LvGgUJmEsjs0XGwnNNwxJBT
 s2lp8U5Lo4Lb
 =0cG5
 -----END PGP SIGNATURE-----

Merge tag 'pull-block-2022-03-22' of https://gitlab.com/hreitz/qemu into staging

Block patches for 7.0-rc1:
- iotest fixes:
  - Fix some iotests for riscv targets
  - Use GNU sed in more places where required
  - Meson-related fixes (i.e. to print errors when they occur)
  - Have qemu-img calls (from Python tests) generally raise nicely
    formattable exceptions on errors
  - Fix iotest 207
- Allow RBD images to be growable by writing zeroes past the end of
  file, fixing qcow2 on rbd

# gpg: Signature made Tue 22 Mar 2022 11:51:10 GMT
# gpg:                using RSA key CB62D7A0EE3829E45F004D34A1FA40D098019CDF
# gpg:                issuer "hreitz@redhat.com"
# gpg: Good signature from "Hanna Reitz <hreitz@redhat.com>" [marginal]
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: CB62 D7A0 EE38 29E4 5F00  4D34 A1FA 40D0 9801 9CDF

* tag 'pull-block-2022-03-22' of https://gitlab.com/hreitz/qemu: (25 commits)
  iotests/207: Filter host fingerprint
  iotests.py: Filters for VM.run_job()
  iotests: make qemu_img_log and img_info_log raise on error
  iotests: remove qemu_img_pipe_and_status()
  iotests: replace qemu_img_log('create', ...) calls
  iotests: use qemu_img() in has_working_luks()
  iotests: remove remaining calls to qemu_img_pipe()
  iotests/149: Remove qemu_img_pipe() call
  iotests: replace unchecked calls to qemu_img_pipe()
  iotests: change supports_quorum to use qemu_img
  iotests: add qemu_img_map() function
  iotests/remove-bitmap-from-backing: use qemu_img_info()
  iotests: add qemu_img_info()
  iotests: use qemu_img_json() when applicable
  iotests: add qemu_img_json()
  iotests: fortify compare_images() against crashes
  iotests: make qemu_img raise on non-zero rc by default
  iotests: Remove explicit checks for qemu_img() == 0
  python/utils: add VerboseProcessError
  python/utils: add add_visual_margin() text decoration utility
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2022-03-22 12:44:11 +00:00
commit 9d36d5f7e0
50 changed files with 404 additions and 274 deletions

View File

@ -1107,6 +1107,20 @@ static int coroutine_fn qemu_rbd_start_co(BlockDriverState *bs,
assert(!qiov || qiov->size == bytes); assert(!qiov || qiov->size == bytes);
if (cmd == RBD_AIO_WRITE || cmd == RBD_AIO_WRITE_ZEROES) {
/*
* RBD APIs don't allow us to write more than actual size, so in order
* to support growing images, we resize the image before write
* operations that exceed the current size.
*/
if (offset + bytes > s->image_size) {
int r = qemu_rbd_resize(bs, offset + bytes);
if (r < 0) {
return r;
}
}
}
r = rbd_aio_create_completion(&task, r = rbd_aio_create_completion(&task,
(rbd_callback_t) qemu_rbd_completion_cb, &c); (rbd_callback_t) qemu_rbd_completion_cb, &c);
if (r < 0) { if (r < 0) {
@ -1182,18 +1196,6 @@ coroutine_fn qemu_rbd_co_pwritev(BlockDriverState *bs, int64_t offset,
int64_t bytes, QEMUIOVector *qiov, int64_t bytes, QEMUIOVector *qiov,
BdrvRequestFlags flags) BdrvRequestFlags flags)
{ {
BDRVRBDState *s = bs->opaque;
/*
* RBD APIs don't allow us to write more than actual size, so in order
* to support growing images, we resize the image before write
* operations that exceed the current size.
*/
if (offset + bytes > s->image_size) {
int r = qemu_rbd_resize(bs, offset + bytes);
if (r < 0) {
return r;
}
}
return qemu_rbd_start_co(bs, offset, bytes, qiov, flags, RBD_AIO_WRITE); return qemu_rbd_start_co(bs, offset, bytes, qiov, flags, RBD_AIO_WRITE);
} }

View File

@ -3,9 +3,9 @@ project('qemu', ['c'], meson_version: '>=0.59.3',
'b_staticpic=false', 'stdsplit=false'], 'b_staticpic=false', 'stdsplit=false'],
version: files('VERSION')) version: files('VERSION'))
add_test_setup('quick', exclude_suites: ['block', 'slow', 'thorough'], is_default: true) add_test_setup('quick', exclude_suites: ['slow', 'thorough'], is_default: true)
add_test_setup('slow', exclude_suites: ['block', 'thorough'], env: ['G_TEST_SLOW=1', 'SPEED=slow']) add_test_setup('slow', exclude_suites: ['thorough'], env: ['G_TEST_SLOW=1', 'SPEED=slow'])
add_test_setup('thorough', exclude_suites: ['block'], env: ['G_TEST_SLOW=1', 'SPEED=thorough']) add_test_setup('thorough', env: ['G_TEST_SLOW=1', 'SPEED=thorough'])
not_found = dependency('', required: false) not_found = dependency('', required: false)
keyval = import('keyval') keyval = import('keyval')

View File

@ -15,7 +15,11 @@ various tasks not directly related to the launching of a VM.
# the COPYING file in the top-level directory. # the COPYING file in the top-level directory.
# #
import os
import re import re
import shutil
from subprocess import CalledProcessError
import textwrap
from typing import Optional from typing import Optional
# pylint: disable=import-error # pylint: disable=import-error
@ -23,6 +27,8 @@ from .accel import kvm_available, list_accel, tcg_available
__all__ = ( __all__ = (
'VerboseProcessError',
'add_visual_margin',
'get_info_usernet_hostfwd_port', 'get_info_usernet_hostfwd_port',
'kvm_available', 'kvm_available',
'list_accel', 'list_accel',
@ -43,3 +49,114 @@ def get_info_usernet_hostfwd_port(info_usernet_output: str) -> Optional[int]:
if match is not None: if match is not None:
return int(match[1]) return int(match[1])
return None return None
# pylint: disable=too-many-arguments
def add_visual_margin(
content: str = '',
width: Optional[int] = None,
name: Optional[str] = None,
padding: int = 1,
upper_left: str = '',
lower_left: str = '',
horizontal: str = '',
vertical: str = '',
) -> str:
"""
Decorate and wrap some text with a visual decoration around it.
This function assumes that the text decoration characters are single
characters that display using a single monospace column.
Example
This is what this function looks like with text content that's
wrapped to 66 characters. The right-hand margin is left open to
accommodate the occasional unicode character that might make
predicting the total "visual" width of a line difficult. This
provides a visual distinction that's good-enough, though.
:param content: The text to wrap and decorate.
:param width:
The number of columns to use, including for the decoration
itself. The default (None) uses the the available width of the
current terminal, or a fallback of 72 lines. A negative number
subtracts a fixed-width from the default size. The default obeys
the COLUMNS environment variable, if set.
:param name: A label to apply to the upper-left of the box.
:param padding: How many columns of padding to apply inside.
:param upper_left: Upper-left single-width text decoration character.
:param lower_left: Lower-left single-width text decoration character.
:param horizontal: Horizontal single-width text decoration character.
:param vertical: Vertical single-width text decoration character.
"""
if width is None or width < 0:
avail = shutil.get_terminal_size(fallback=(72, 24))[0]
if width is None:
_width = avail
else:
_width = avail + width
else:
_width = width
prefix = vertical + (' ' * padding)
def _bar(name: Optional[str], top: bool = True) -> str:
ret = upper_left if top else lower_left
if name is not None:
ret += f"{horizontal} {name} "
filler_len = _width - len(ret)
ret += f"{horizontal * filler_len}"
return ret
def _wrap(line: str) -> str:
return os.linesep.join(
textwrap.wrap(
line, width=_width - padding, initial_indent=prefix,
subsequent_indent=prefix, replace_whitespace=False,
drop_whitespace=True, break_on_hyphens=False)
)
return os.linesep.join((
_bar(name, top=True),
os.linesep.join(_wrap(line) for line in content.splitlines()),
_bar(None, top=False),
))
class VerboseProcessError(CalledProcessError):
"""
The same as CalledProcessError, but more verbose.
This is useful for debugging failed calls during test executions.
The return code, signal (if any), and terminal output will be displayed
on unhandled exceptions.
"""
def summary(self) -> str:
"""Return the normal CalledProcessError str() output."""
return super().__str__()
def __str__(self) -> str:
lmargin = ' '
width = -len(lmargin)
sections = []
# Does self.stdout contain both stdout and stderr?
has_combined_output = self.stderr is None
name = 'output' if has_combined_output else 'stdout'
if self.stdout:
sections.append(add_visual_margin(self.stdout, width, name))
else:
sections.append(f"{name}: N/A")
if self.stderr:
sections.append(add_visual_margin(self.stderr, width, 'stderr'))
elif not has_combined_output:
sections.append("stderr: N/A")
return os.linesep.join((
self.summary(),
textwrap.indent(os.linesep.join(sections), prefix=lmargin),
))

View File

@ -101,10 +101,6 @@ targets = {t['id']: [os.path.relpath(f) for f in t['filename']]
testsuites = defaultdict(Suite) testsuites = defaultdict(Suite)
for test in introspect['tests']: for test in introspect['tests']:
process_tests(test, targets, testsuites) process_tests(test, targets, testsuites)
# HACK: check-block is a separate target so that it runs with --verbose;
# only write the dependencies
emit_suite_deps('block', testsuites['block'], 'check')
del testsuites['block']
emit_prolog(testsuites, 'check') emit_prolog(testsuites, 'check')
for name, suite in testsuites.items(): for name, suite in testsuites.items():
emit_suite(name, suite, 'check') emit_suite(name, suite, 'check')

View File

@ -147,16 +147,9 @@ check-acceptance: check-acceptance-deprecated-warning | check-avocado
# Consolidated targets # Consolidated targets
.PHONY: check-block check check-clean get-vm-images .PHONY: check check-clean get-vm-images
check: check:
ifneq ($(.check-block.deps),)
check: check-block
check-block: run-ninja
$(if $(MAKE.n),,+)$(MESON) test $(MTESTARGS) $(.mtestargs) --verbose \
--logbase iotestslog $(call .speed.$(SPEED), block block-slow block-thorough)
endif
check-build: run-ninja check-build: run-ninja
check-clean: check-clean:

View File

@ -24,7 +24,7 @@ import os
import re import re
import json import json
import iotests import iotests
from iotests import qemu_img, qemu_img_pipe, qemu_io from iotests import qemu_img, qemu_img_map, qemu_io
backing_img = os.path.join(iotests.test_dir, 'backing.img') backing_img = os.path.join(iotests.test_dir, 'backing.img')
target_backing_img = os.path.join(iotests.test_dir, 'target-backing.img') target_backing_img = os.path.join(iotests.test_dir, 'target-backing.img')
@ -1360,8 +1360,7 @@ class TestFilters(iotests.QMPTestCase):
self.vm.qmp('blockdev-del', node_name='target') self.vm.qmp('blockdev-del', node_name='target')
target_map = qemu_img_pipe('map', '--output=json', target_img) target_map = qemu_img_map(target_img)
target_map = json.loads(target_map)
assert target_map[0]['start'] == 0 assert target_map[0]['start'] == 0
assert target_map[0]['length'] == 512 * 1024 assert target_map[0]['length'] == 512 * 1024

View File

@ -24,7 +24,7 @@ import os
import re import re
import json import json
import iotests import iotests
from iotests import qemu_img, qemu_img_pipe from iotests import qemu_img, qemu_img_info
import unittest import unittest
test_img = os.path.join(iotests.test_dir, 'test.img') test_img = os.path.join(iotests.test_dir, 'test.img')
@ -49,13 +49,12 @@ class TestQemuImgInfo(TestImageInfoSpecific):
human_compare = None human_compare = None
def test_json(self): def test_json(self):
data = json.loads(qemu_img_pipe('info', '--output=json', test_img)) data = qemu_img_info(test_img)['format-specific']
data = data['format-specific']
self.assertEqual(data['type'], iotests.imgfmt) self.assertEqual(data['type'], iotests.imgfmt)
self.assertEqual(data['data'], self.json_compare) self.assertEqual(data['data'], self.json_compare)
def test_human(self): def test_human(self):
data = qemu_img_pipe('info', '--output=human', test_img).split('\n') data = qemu_img('info', '--output=human', test_img).stdout.split('\n')
data = data[(data.index('Format specific information:') + 1) data = data[(data.index('Format specific information:') + 1)
:data.index('')] :data.index('')]
for field in data: for field in data:

View File

@ -265,8 +265,11 @@ def qemu_img_create(config, size_mb):
"%dM" % size_mb] "%dM" % size_mb]
iotests.log("qemu-img " + " ".join(args), filters=[iotests.filter_test_dir]) iotests.log("qemu-img " + " ".join(args), filters=[iotests.filter_test_dir])
iotests.log(check_cipher_support(config, iotests.qemu_img_pipe(*args)), try:
filters=[iotests.filter_test_dir]) iotests.qemu_img(*args)
except subprocess.CalledProcessError as exc:
check_cipher_support(config, exc.output)
raise
def qemu_io_image_args(config, dev=False): def qemu_io_image_args(config, dev=False):
"""Get the args for access an image or device with qemu-io""" """Get the args for access an image or device with qemu-io"""

View File

@ -61,7 +61,6 @@ unlink TEST_DIR/luks-aes-256-xts-plain64-sha1.img
# ================= qemu-img aes-256-xts-plain64-sha1 ================= # ================= qemu-img aes-256-xts-plain64-sha1 =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-aes-256-xts-plain64-sha1.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-aes-256-xts-plain64-sha1.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha1.img qiotest-145-aes-256-xts-plain64-sha1 sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha1.img qiotest-145-aes-256-xts-plain64-sha1
# Write test pattern 0xa7 # Write test pattern 0xa7
@ -180,7 +179,6 @@ unlink TEST_DIR/luks-twofish-256-xts-plain64-sha1.img
# ================= qemu-img twofish-256-xts-plain64-sha1 ================= # ================= qemu-img twofish-256-xts-plain64-sha1 =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=twofish-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-twofish-256-xts-plain64-sha1.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=twofish-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-twofish-256-xts-plain64-sha1.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-twofish-256-xts-plain64-sha1.img qiotest-145-twofish-256-xts-plain64-sha1 sudo cryptsetup -q -v luksOpen TEST_DIR/luks-twofish-256-xts-plain64-sha1.img qiotest-145-twofish-256-xts-plain64-sha1
# Write test pattern 0xa7 # Write test pattern 0xa7
@ -299,7 +297,6 @@ unlink TEST_DIR/luks-serpent-256-xts-plain64-sha1.img
# ================= qemu-img serpent-256-xts-plain64-sha1 ================= # ================= qemu-img serpent-256-xts-plain64-sha1 =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=serpent-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-serpent-256-xts-plain64-sha1.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=serpent-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-serpent-256-xts-plain64-sha1.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-serpent-256-xts-plain64-sha1.img qiotest-145-serpent-256-xts-plain64-sha1 sudo cryptsetup -q -v luksOpen TEST_DIR/luks-serpent-256-xts-plain64-sha1.img qiotest-145-serpent-256-xts-plain64-sha1
# Write test pattern 0xa7 # Write test pattern 0xa7
@ -418,7 +415,6 @@ unlink TEST_DIR/luks-cast5-128-cbc-plain64-sha1.img
# ================= qemu-img cast5-128-cbc-plain64-sha1 ================= # ================= qemu-img cast5-128-cbc-plain64-sha1 =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=cast5-128,cipher-mode=cbc,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-cast5-128-cbc-plain64-sha1.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=cast5-128,cipher-mode=cbc,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-cast5-128-cbc-plain64-sha1.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-cast5-128-cbc-plain64-sha1.img qiotest-145-cast5-128-cbc-plain64-sha1 sudo cryptsetup -q -v luksOpen TEST_DIR/luks-cast5-128-cbc-plain64-sha1.img qiotest-145-cast5-128-cbc-plain64-sha1
# Write test pattern 0xa7 # Write test pattern 0xa7
@ -538,7 +534,6 @@ unlink TEST_DIR/luks-aes-256-cbc-plain-sha1.img
# ================= qemu-img aes-256-cbc-plain-sha1 ================= # ================= qemu-img aes-256-cbc-plain-sha1 =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=plain,hash-alg=sha1 TEST_DIR/luks-aes-256-cbc-plain-sha1.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=plain,hash-alg=sha1 TEST_DIR/luks-aes-256-cbc-plain-sha1.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-plain-sha1.img qiotest-145-aes-256-cbc-plain-sha1 sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-plain-sha1.img qiotest-145-aes-256-cbc-plain-sha1
# Write test pattern 0xa7 # Write test pattern 0xa7
@ -657,7 +652,6 @@ unlink TEST_DIR/luks-aes-256-cbc-plain64-sha1.img
# ================= qemu-img aes-256-cbc-plain64-sha1 ================= # ================= qemu-img aes-256-cbc-plain64-sha1 =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-aes-256-cbc-plain64-sha1.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-aes-256-cbc-plain64-sha1.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-plain64-sha1.img qiotest-145-aes-256-cbc-plain64-sha1 sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-plain64-sha1.img qiotest-145-aes-256-cbc-plain64-sha1
# Write test pattern 0xa7 # Write test pattern 0xa7
@ -776,7 +770,6 @@ unlink TEST_DIR/luks-aes-256-cbc-essiv-sha256-sha1.img
# ================= qemu-img aes-256-cbc-essiv-sha256-sha1 ================= # ================= qemu-img aes-256-cbc-essiv-sha256-sha1 =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=essiv,hash-alg=sha1,ivgen-hash-alg=sha256 TEST_DIR/luks-aes-256-cbc-essiv-sha256-sha1.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=essiv,hash-alg=sha1,ivgen-hash-alg=sha256 TEST_DIR/luks-aes-256-cbc-essiv-sha256-sha1.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-essiv-sha256-sha1.img qiotest-145-aes-256-cbc-essiv-sha256-sha1 sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-essiv-sha256-sha1.img qiotest-145-aes-256-cbc-essiv-sha256-sha1
# Write test pattern 0xa7 # Write test pattern 0xa7
@ -895,7 +888,6 @@ unlink TEST_DIR/luks-aes-256-xts-essiv-sha256-sha1.img
# ================= qemu-img aes-256-xts-essiv-sha256-sha1 ================= # ================= qemu-img aes-256-xts-essiv-sha256-sha1 =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=essiv,hash-alg=sha1,ivgen-hash-alg=sha256 TEST_DIR/luks-aes-256-xts-essiv-sha256-sha1.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=essiv,hash-alg=sha1,ivgen-hash-alg=sha256 TEST_DIR/luks-aes-256-xts-essiv-sha256-sha1.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-essiv-sha256-sha1.img qiotest-145-aes-256-xts-essiv-sha256-sha1 sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-essiv-sha256-sha1.img qiotest-145-aes-256-xts-essiv-sha256-sha1
# Write test pattern 0xa7 # Write test pattern 0xa7
@ -1014,7 +1006,6 @@ unlink TEST_DIR/luks-aes-128-xts-plain64-sha256-sha1.img
# ================= qemu-img aes-128-xts-plain64-sha256-sha1 ================= # ================= qemu-img aes-128-xts-plain64-sha256-sha1 =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-128,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-aes-128-xts-plain64-sha256-sha1.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-128,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-aes-128-xts-plain64-sha256-sha1.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-128-xts-plain64-sha256-sha1.img qiotest-145-aes-128-xts-plain64-sha256-sha1 sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-128-xts-plain64-sha256-sha1.img qiotest-145-aes-128-xts-plain64-sha256-sha1
# Write test pattern 0xa7 # Write test pattern 0xa7
@ -1133,7 +1124,6 @@ unlink TEST_DIR/luks-aes-192-xts-plain64-sha256-sha1.img
# ================= qemu-img aes-192-xts-plain64-sha256-sha1 ================= # ================= qemu-img aes-192-xts-plain64-sha256-sha1 =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-192,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-aes-192-xts-plain64-sha256-sha1.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-192,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-aes-192-xts-plain64-sha256-sha1.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-192-xts-plain64-sha256-sha1.img qiotest-145-aes-192-xts-plain64-sha256-sha1 sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-192-xts-plain64-sha256-sha1.img qiotest-145-aes-192-xts-plain64-sha256-sha1
# Write test pattern 0xa7 # Write test pattern 0xa7
@ -1252,7 +1242,6 @@ unlink TEST_DIR/luks-twofish-128-xts-plain64-sha1.img
# ================= qemu-img twofish-128-xts-plain64-sha1 ================= # ================= qemu-img twofish-128-xts-plain64-sha1 =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=twofish-128,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-twofish-128-xts-plain64-sha1.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=twofish-128,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-twofish-128-xts-plain64-sha1.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-twofish-128-xts-plain64-sha1.img qiotest-145-twofish-128-xts-plain64-sha1 sudo cryptsetup -q -v luksOpen TEST_DIR/luks-twofish-128-xts-plain64-sha1.img qiotest-145-twofish-128-xts-plain64-sha1
# Write test pattern 0xa7 # Write test pattern 0xa7
@ -1372,7 +1361,6 @@ unlink TEST_DIR/luks-serpent-128-xts-plain64-sha1.img
# ================= qemu-img serpent-128-xts-plain64-sha1 ================= # ================= qemu-img serpent-128-xts-plain64-sha1 =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=serpent-128,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-serpent-128-xts-plain64-sha1.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=serpent-128,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-serpent-128-xts-plain64-sha1.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-serpent-128-xts-plain64-sha1.img qiotest-145-serpent-128-xts-plain64-sha1 sudo cryptsetup -q -v luksOpen TEST_DIR/luks-serpent-128-xts-plain64-sha1.img qiotest-145-serpent-128-xts-plain64-sha1
# Write test pattern 0xa7 # Write test pattern 0xa7
@ -1491,7 +1479,6 @@ unlink TEST_DIR/luks-serpent-192-xts-plain64-sha1.img
# ================= qemu-img serpent-192-xts-plain64-sha1 ================= # ================= qemu-img serpent-192-xts-plain64-sha1 =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=serpent-192,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-serpent-192-xts-plain64-sha1.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=serpent-192,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-serpent-192-xts-plain64-sha1.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-serpent-192-xts-plain64-sha1.img qiotest-145-serpent-192-xts-plain64-sha1 sudo cryptsetup -q -v luksOpen TEST_DIR/luks-serpent-192-xts-plain64-sha1.img qiotest-145-serpent-192-xts-plain64-sha1
# Write test pattern 0xa7 # Write test pattern 0xa7
@ -1612,7 +1599,6 @@ unlink TEST_DIR/luks-aes-256-xts-plain64-sha224.img
# ================= qemu-img aes-256-xts-plain64-sha224 ================= # ================= qemu-img aes-256-xts-plain64-sha224 =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha224 TEST_DIR/luks-aes-256-xts-plain64-sha224.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha224 TEST_DIR/luks-aes-256-xts-plain64-sha224.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha224.img qiotest-145-aes-256-xts-plain64-sha224 sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha224.img qiotest-145-aes-256-xts-plain64-sha224
# Write test pattern 0xa7 # Write test pattern 0xa7
@ -1731,7 +1717,6 @@ unlink TEST_DIR/luks-aes-256-xts-plain64-sha256.img
# ================= qemu-img aes-256-xts-plain64-sha256 ================= # ================= qemu-img aes-256-xts-plain64-sha256 =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha256 TEST_DIR/luks-aes-256-xts-plain64-sha256.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha256 TEST_DIR/luks-aes-256-xts-plain64-sha256.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha256.img qiotest-145-aes-256-xts-plain64-sha256 sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha256.img qiotest-145-aes-256-xts-plain64-sha256
# Write test pattern 0xa7 # Write test pattern 0xa7
@ -1850,7 +1835,6 @@ unlink TEST_DIR/luks-aes-256-xts-plain64-sha384.img
# ================= qemu-img aes-256-xts-plain64-sha384 ================= # ================= qemu-img aes-256-xts-plain64-sha384 =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha384 TEST_DIR/luks-aes-256-xts-plain64-sha384.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha384 TEST_DIR/luks-aes-256-xts-plain64-sha384.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha384.img qiotest-145-aes-256-xts-plain64-sha384 sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha384.img qiotest-145-aes-256-xts-plain64-sha384
# Write test pattern 0xa7 # Write test pattern 0xa7
@ -1969,7 +1953,6 @@ unlink TEST_DIR/luks-aes-256-xts-plain64-sha512.img
# ================= qemu-img aes-256-xts-plain64-sha512 ================= # ================= qemu-img aes-256-xts-plain64-sha512 =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha512 TEST_DIR/luks-aes-256-xts-plain64-sha512.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha512 TEST_DIR/luks-aes-256-xts-plain64-sha512.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha512.img qiotest-145-aes-256-xts-plain64-sha512 sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha512.img qiotest-145-aes-256-xts-plain64-sha512
# Write test pattern 0xa7 # Write test pattern 0xa7
@ -2088,7 +2071,6 @@ unlink TEST_DIR/luks-aes-256-xts-plain64-ripemd160.img
# ================= qemu-img aes-256-xts-plain64-ripemd160 ================= # ================= qemu-img aes-256-xts-plain64-ripemd160 =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=ripemd160 TEST_DIR/luks-aes-256-xts-plain64-ripemd160.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=ripemd160 TEST_DIR/luks-aes-256-xts-plain64-ripemd160.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-ripemd160.img qiotest-145-aes-256-xts-plain64-ripemd160 sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-ripemd160.img qiotest-145-aes-256-xts-plain64-ripemd160
# Write test pattern 0xa7 # Write test pattern 0xa7
@ -2281,7 +2263,6 @@ unlink TEST_DIR/luks-aes-256-xts-plain-sha1-pwallslots.img
# ================= qemu-img aes-256-xts-plain-sha1-pwallslots ================= # ================= qemu-img aes-256-xts-plain-sha1-pwallslots =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=c2xvdDE=,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain,hash-alg=sha1 TEST_DIR/luks-aes-256-xts-plain-sha1-pwallslots.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=c2xvdDE=,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain,hash-alg=sha1 TEST_DIR/luks-aes-256-xts-plain-sha1-pwallslots.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain-sha1-pwallslots.img qiotest-145-aes-256-xts-plain-sha1-pwallslots sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain-sha1-pwallslots.img qiotest-145-aes-256-xts-plain-sha1-pwallslots
# Write test pattern 0xa7 # Write test pattern 0xa7
@ -2400,7 +2381,6 @@ unlink TEST_DIR/luks-aes-256-cbc-essiv-auto-sha1.img
# ================= qemu-img aes-256-cbc-essiv-auto-sha1 ================= # ================= qemu-img aes-256-cbc-essiv-auto-sha1 =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=essiv,hash-alg=sha1 TEST_DIR/luks-aes-256-cbc-essiv-auto-sha1.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=essiv,hash-alg=sha1 TEST_DIR/luks-aes-256-cbc-essiv-auto-sha1.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-essiv-auto-sha1.img qiotest-145-aes-256-cbc-essiv-auto-sha1 sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-essiv-auto-sha1.img qiotest-145-aes-256-cbc-essiv-auto-sha1
# Write test pattern 0xa7 # Write test pattern 0xa7
@ -2519,7 +2499,6 @@ unlink TEST_DIR/luks-aes-256-cbc-plain64-sha256-sha1.img
# ================= qemu-img aes-256-cbc-plain64-sha256-sha1 ================= # ================= qemu-img aes-256-cbc-plain64-sha256-sha1 =================
# Create image # Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=plain64,hash-alg=sha1,ivgen-hash-alg=sha256 TEST_DIR/luks-aes-256-cbc-plain64-sha256-sha1.img 4194304M qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=plain64,hash-alg=sha1,ivgen-hash-alg=sha256 TEST_DIR/luks-aes-256-cbc-plain64-sha256-sha1.img 4194304M
# Open dev # Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-plain64-sha256-sha1.img qiotest-145-aes-256-cbc-plain64-sha256-sha1 sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-plain64-sha256-sha1.img qiotest-145-aes-256-cbc-plain64-sha256-sha1
# Write test pattern 0xa7 # Write test pattern 0xa7

View File

@ -107,8 +107,7 @@ class ShrinkBaseClass(iotests.QMPTestCase):
if iotests.imgfmt == 'raw': if iotests.imgfmt == 'raw':
return return
self.assertEqual(qemu_img('check', test_img), 0, qemu_img('check', test_img)
"Verifying image corruption")
def test_empty_image(self): def test_empty_image(self):
qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img, qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img,
@ -130,8 +129,7 @@ class ShrinkBaseClass(iotests.QMPTestCase):
qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img, qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img,
self.shrink_size) self.shrink_size)
self.assertEqual(qemu_img("compare", test_img, check_img), 0, qemu_img("compare", test_img, check_img)
"Verifying image content")
self.image_verify() self.image_verify()
@ -146,8 +144,7 @@ class ShrinkBaseClass(iotests.QMPTestCase):
qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img, qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img,
self.shrink_size) self.shrink_size)
self.assertEqual(qemu_img("compare", test_img, check_img), 0, qemu_img("compare", test_img, check_img)
"Verifying image content")
self.image_verify() self.image_verify()

View File

@ -33,8 +33,8 @@ with iotests.FilePath('source.img') as source_img_path, \
iotests.VM('dest') as dest_vm: iotests.VM('dest') as dest_vm:
img_size = '1G' img_size = '1G'
iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, source_img_path, img_size) iotests.qemu_img_create('-f', iotests.imgfmt, source_img_path, img_size)
iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, dest_img_path, img_size) iotests.qemu_img_create('-f', iotests.imgfmt, dest_img_path, img_size)
iotests.log('Launching VMs...') iotests.log('Launching VMs...')
(source_vm.add_drive(source_img_path) (source_vm.add_drive(source_img_path)

View File

@ -35,8 +35,8 @@ with iotests.FilePath('disk0.img') as disk0_img_path, \
iotests.VM() as vm: iotests.VM() as vm:
img_size = '10M' img_size = '10M'
iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, disk0_img_path, img_size) iotests.qemu_img_create('-f', iotests.imgfmt, disk0_img_path, img_size)
iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, disk1_img_path, img_size) iotests.qemu_img_create('-f', iotests.imgfmt, disk1_img_path, img_size)
iotests.log('Launching VM...') iotests.log('Launching VM...')
vm.launch() vm.launch()

View File

@ -33,8 +33,8 @@ with iotests.FilePath('disk0.img') as disk0_img_path, \
iotests.VM() as vm: iotests.VM() as vm:
img_size = '10M' img_size = '10M'
iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, disk0_img_path, img_size) iotests.qemu_img_create('-f', iotests.imgfmt, disk0_img_path, img_size)
iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, disk1_img_path, img_size) iotests.qemu_img_create('-f', iotests.imgfmt, disk1_img_path, img_size)
iotests.log('Launching VM...') iotests.log('Launching VM...')
(vm.add_object('iothread,id=iothread0') (vm.add_object('iothread,id=iothread0')

View File

@ -35,7 +35,12 @@ def filter_hash(qmsg):
if key == 'hash' and re.match('[0-9a-f]+', value): if key == 'hash' and re.match('[0-9a-f]+', value):
return 'HASH' return 'HASH'
return value return value
return iotests.filter_qmp(qmsg, _filter) if isinstance(qmsg, str):
# Strip key type and fingerprint
p = r"\S+ (key fingerprint) '(md5|sha1|sha256):[0-9a-f]+'"
return re.sub(p, r"\1 '\2:HASH'", qmsg)
else:
return iotests.filter_qmp(qmsg, _filter)
def blockdev_create(vm, options): def blockdev_create(vm, options):
vm.blockdev_create(options, filters=[iotests.filter_qmp_testfiles, filter_hash]) vm.blockdev_create(options, filters=[iotests.filter_qmp_testfiles, filter_hash])

View File

@ -42,7 +42,7 @@ virtual size: 4 MiB (4194304 bytes)
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "ssh", "location": {"host-key-check": {"hash": "wrong", "mode": "hash", "type": "md5"}, "path": "TEST_DIR/PID-t.img", "server": {"host": "127.0.0.1", "port": "22"}}, "size": 2097152}}} {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "ssh", "location": {"host-key-check": {"hash": "wrong", "mode": "hash", "type": "md5"}, "path": "TEST_DIR/PID-t.img", "server": {"host": "127.0.0.1", "port": "22"}}, "size": 2097152}}}
{"return": {}} {"return": {}}
Job failed: remote host key does not match host_key_check 'wrong' Job failed: remote host key fingerprint 'md5:HASH' does not match host_key_check 'md5:wrong'
{"execute": "job-dismiss", "arguments": {"id": "job0"}} {"execute": "job-dismiss", "arguments": {"id": "job0"}}
{"return": {}} {"return": {}}
@ -59,7 +59,7 @@ virtual size: 8 MiB (8388608 bytes)
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "ssh", "location": {"host-key-check": {"hash": "wrong", "mode": "hash", "type": "sha1"}, "path": "TEST_DIR/PID-t.img", "server": {"host": "127.0.0.1", "port": "22"}}, "size": 2097152}}} {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "ssh", "location": {"host-key-check": {"hash": "wrong", "mode": "hash", "type": "sha1"}, "path": "TEST_DIR/PID-t.img", "server": {"host": "127.0.0.1", "port": "22"}}, "size": 2097152}}}
{"return": {}} {"return": {}}
Job failed: remote host key does not match host_key_check 'wrong' Job failed: remote host key fingerprint 'sha1:HASH' does not match host_key_check 'sha1:wrong'
{"execute": "job-dismiss", "arguments": {"id": "job0"}} {"execute": "job-dismiss", "arguments": {"id": "job0"}}
{"return": {}} {"return": {}}
@ -76,7 +76,7 @@ virtual size: 4 MiB (4194304 bytes)
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "ssh", "location": {"host-key-check": {"hash": "wrong", "mode": "hash", "type": "sha256"}, "path": "TEST_DIR/PID-t.img", "server": {"host": "127.0.0.1", "port": "22"}}, "size": 2097152}}} {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "ssh", "location": {"host-key-check": {"hash": "wrong", "mode": "hash", "type": "sha256"}, "path": "TEST_DIR/PID-t.img", "server": {"host": "127.0.0.1", "port": "22"}}, "size": 2097152}}}
{"return": {}} {"return": {}}
Job failed: remote host key does not match host_key_check 'wrong' Job failed: remote host key fingerprint 'sha256:HASH' does not match host_key_check 'sha256:wrong'
{"execute": "job-dismiss", "arguments": {"id": "job0"}} {"execute": "job-dismiss", "arguments": {"id": "job0"}}
{"return": {}} {"return": {}}

View File

@ -59,7 +59,7 @@ with iotests.FilePath('t.vdi') as disk_path, \
vm.shutdown() vm.shutdown()
iotests.img_info_log(disk_path) iotests.img_info_log(disk_path)
iotests.log(iotests.qemu_img_pipe('map', '--output=json', disk_path)) iotests.log(iotests.qemu_img_map(disk_path))
# #
# Successful image creation (explicit defaults) # Successful image creation (explicit defaults)
@ -83,7 +83,7 @@ with iotests.FilePath('t.vdi') as disk_path, \
vm.shutdown() vm.shutdown()
iotests.img_info_log(disk_path) iotests.img_info_log(disk_path)
iotests.log(iotests.qemu_img_pipe('map', '--output=json', disk_path)) iotests.log(iotests.qemu_img_map(disk_path))
# #
# Successful image creation (with non-default options) # Successful image creation (with non-default options)
@ -107,7 +107,7 @@ with iotests.FilePath('t.vdi') as disk_path, \
vm.shutdown() vm.shutdown()
iotests.img_info_log(disk_path) iotests.img_info_log(disk_path)
iotests.log(iotests.qemu_img_pipe('map', '--output=json', disk_path)) iotests.log(iotests.qemu_img_map(disk_path))
# #
# Invalid BlockdevRef # Invalid BlockdevRef

View File

@ -17,8 +17,7 @@ file format: IMGFMT
virtual size: 128 MiB (134217728 bytes) virtual size: 128 MiB (134217728 bytes)
cluster_size: 1048576 cluster_size: 1048576
[{ "start": 0, "length": 134217728, "depth": 0, "present": true, "zero": true, "data": false}] [{"data": false, "depth": 0, "length": 134217728, "present": true, "start": 0, "zero": true}]
=== Successful image creation (explicit defaults) === === Successful image creation (explicit defaults) ===
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.vdi", "size": 0}}} {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.vdi", "size": 0}}}
@ -36,8 +35,7 @@ file format: IMGFMT
virtual size: 64 MiB (67108864 bytes) virtual size: 64 MiB (67108864 bytes)
cluster_size: 1048576 cluster_size: 1048576
[{ "start": 0, "length": 67108864, "depth": 0, "present": true, "zero": true, "data": false}] [{"data": false, "depth": 0, "length": 67108864, "present": true, "start": 0, "zero": true}]
=== Successful image creation (with non-default options) === === Successful image creation (with non-default options) ===
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.vdi", "size": 0}}} {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.vdi", "size": 0}}}
@ -55,9 +53,7 @@ file format: IMGFMT
virtual size: 32 MiB (33554432 bytes) virtual size: 32 MiB (33554432 bytes)
cluster_size: 1048576 cluster_size: 1048576
[{ "start": 0, "length": 3072, "depth": 0, "present": true, "zero": false, "data": true, "offset": 1024}, [{"data": true, "depth": 0, "length": 3072, "offset": 1024, "present": true, "start": 0, "zero": false}, {"data": true, "depth": 0, "length": 33551360, "offset": 4096, "present": true, "start": 3072, "zero": true}]
{ "start": 3072, "length": 33551360, "depth": 0, "present": true, "zero": true, "data": true, "offset": 4096}]
=== Invalid BlockdevRef === === Invalid BlockdevRef ===
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vdi", "file": "this doesn't exist", "size": 33554432}}} {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vdi", "file": "this doesn't exist", "size": 33554432}}}

View File

@ -51,10 +51,10 @@ with iotests.FilePath('base.img') as base_img_path, \
log('--- Setting up images ---') log('--- Setting up images ---')
log('') log('')
assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') == 0 qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M')
assert qemu_io_silent(base_img_path, '-c', 'write -P 1 0M 1M') == 0 assert qemu_io_silent(base_img_path, '-c', 'write -P 1 0M 1M') == 0
assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path, qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
'-F', iotests.imgfmt, top_img_path) == 0 '-F', iotests.imgfmt, top_img_path)
assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') == 0 assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') == 0
log('Done') log('Done')

View File

@ -145,7 +145,7 @@ log('')
with iotests.VM() as vm, \ with iotests.VM() as vm, \
iotests.FilePath('src.img') as src_img_path: iotests.FilePath('src.img') as src_img_path:
assert qemu_img('create', '-f', iotests.imgfmt, src_img_path, '64M') == 0 qemu_img('create', '-f', iotests.imgfmt, src_img_path, '64M')
assert qemu_io_silent('-f', iotests.imgfmt, src_img_path, assert qemu_io_silent('-f', iotests.imgfmt, src_img_path,
'-c', 'write -P 42 0M 64M') == 0 '-c', 'write -P 42 0M 64M') == 0

View File

@ -47,12 +47,11 @@ for filter_node_name in False, True:
iotests.FilePath('top.img') as top_img_path, \ iotests.FilePath('top.img') as top_img_path, \
iotests.VM() as vm: iotests.VM() as vm:
assert qemu_img('create', '-f', iotests.imgfmt, qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M')
base_img_path, '64M') == 0 qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path, '-F', iotests.imgfmt, mid_img_path)
'-F', iotests.imgfmt, mid_img_path) == 0 qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path,
assert qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path, '-F', iotests.imgfmt, top_img_path)
'-F', iotests.imgfmt, top_img_path) == 0
# Something to commit # Something to commit
assert qemu_io_silent(mid_img_path, '-c', 'write -P 1 0 1M') == 0 assert qemu_io_silent(mid_img_path, '-c', 'write -P 1 0 1M') == 0

View File

@ -54,11 +54,11 @@ with iotests.FilePath('base.img') as base_img_path, \
iotests.FilePath('top.img') as top_img_path, \ iotests.FilePath('top.img') as top_img_path, \
iotests.VM() as vm: iotests.VM() as vm:
assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') == 0 qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M')
# Choose a funny way to describe the backing filename # Choose a funny way to describe the backing filename
assert qemu_img('create', '-f', iotests.imgfmt, '-b', qemu_img('create', '-f', iotests.imgfmt, '-b',
'file:' + base_img_path, '-F', iotests.imgfmt, 'file:' + base_img_path, '-F', iotests.imgfmt,
top_img_path) == 0 top_img_path)
vm.launch() vm.launch()
@ -172,8 +172,8 @@ with iotests.FilePath('base.img') as base_img_path, \
# (because qemu cannot "canonicalize"/"resolve" the backing # (because qemu cannot "canonicalize"/"resolve" the backing
# filename unless the backing file is opened implicitly with the # filename unless the backing file is opened implicitly with the
# overlay) # overlay)
assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path, qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
'-F', iotests.imgfmt, top_img_path) == 0 '-F', iotests.imgfmt, top_img_path)
# You can only reliably override backing options by using a node # You can only reliably override backing options by using a node
# reference (or by specifying file.filename, but, well...) # reference (or by specifying file.filename, but, well...)

View File

@ -34,8 +34,8 @@ with iotests.FilePath('img') as img_path, \
iotests.VM(path_suffix='a') as vm_a, \ iotests.VM(path_suffix='a') as vm_a, \
iotests.VM(path_suffix='b') as vm_b: iotests.VM(path_suffix='b') as vm_b:
iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, backing_path, '64M') iotests.qemu_img_create('-f', iotests.imgfmt, backing_path, '64M')
iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, img_path, '64M') iotests.qemu_img_create('-f', iotests.imgfmt, img_path, '64M')
os.mkfifo(fifo_a) os.mkfifo(fifo_a)
os.mkfifo(fifo_b) os.mkfifo(fifo_b)

View File

@ -165,8 +165,7 @@ with iotests.FilePath('t.vmdk') as disk_path, \
iotests.log("") iotests.log("")
for path in [ extent1_path, extent2_path, extent3_path ]: for path in [ extent1_path, extent2_path, extent3_path ]:
msg = iotests.qemu_img_pipe('create', '-f', imgfmt, path, '0') iotests.qemu_img_create('-f', imgfmt, path, '0')
iotests.log(msg, [iotests.filter_testfiles])
vm.add_blockdev('driver=file,filename=%s,node-name=ext1' % (extent1_path)) vm.add_blockdev('driver=file,filename=%s,node-name=ext1' % (extent1_path))
vm.add_blockdev('driver=file,filename=%s,node-name=ext2' % (extent2_path)) vm.add_blockdev('driver=file,filename=%s,node-name=ext2' % (extent2_path))

View File

@ -129,9 +129,6 @@ Job failed: Cannot find device='this doesn't exist' nor node-name='this doesn't
=== Other subformats === === Other subformats ===
== Missing extent == == Missing extent ==
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vmdk", "file": "node0", "size": 33554432, "subformat": "monolithicFlat"}}} {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vmdk", "file": "node0", "size": 33554432, "subformat": "monolithicFlat"}}}

View File

@ -22,7 +22,7 @@
import iotests import iotests
import json import json
import struct import struct
from iotests import qemu_img_create, qemu_io, qemu_img_pipe, \ from iotests import qemu_img_create, qemu_io, qemu_img_info, \
file_path, img_info_log, log, filter_qemu_io file_path, img_info_log, log, filter_qemu_io
iotests.script_initialize(supported_fmts=['qcow2'], iotests.script_initialize(supported_fmts=['qcow2'],
@ -39,8 +39,7 @@ flag_offset = 0x5000f
def print_bitmap(extra_args): def print_bitmap(extra_args):
log('qemu-img info dump:\n') log('qemu-img info dump:\n')
img_info_log(disk, extra_args=extra_args) img_info_log(disk, extra_args=extra_args)
result = json.loads(qemu_img_pipe('info', '--force-share', result = qemu_img_info('--force-share', disk)
'--output=json', disk))
if 'bitmaps' in result['format-specific']['data']: if 'bitmaps' in result['format-specific']['data']:
bitmaps = result['format-specific']['data']['bitmaps'] bitmaps = result['format-specific']['data']['bitmaps']
log('The same bitmaps in JSON format:') log('The same bitmaps in JSON format:')
@ -101,7 +100,7 @@ add_bitmap(1, True, False)
log('Write an unknown bitmap flag \'{}\' into a new QCOW2 image at offset {}' log('Write an unknown bitmap flag \'{}\' into a new QCOW2 image at offset {}'
.format(hex(bitmap_flag_unknown), flag_offset)) .format(hex(bitmap_flag_unknown), flag_offset))
toggle_flag(flag_offset) toggle_flag(flag_offset)
img_info_log(disk) img_info_log(disk, check=False)
toggle_flag(flag_offset) toggle_flag(flag_offset)
log('Unset the unknown bitmap flag \'{}\' in the bitmap directory entry:\n' log('Unset the unknown bitmap flag \'{}\' in the bitmap directory entry:\n'
.format(hex(bitmap_flag_unknown))) .format(hex(bitmap_flag_unknown)))

View File

@ -42,8 +42,8 @@ with iotests.FilePath('t.qcow2') as disk_path, \
size_str = str(size) size_str = str(size)
iotests.create_image(base_path, size) iotests.create_image(base_path, size)
iotests.qemu_img_log('create', '-f', iotests.imgfmt, mid_path, size_str) iotests.qemu_img_create('-f', iotests.imgfmt, mid_path, size_str)
iotests.qemu_img_log('create', '-f', iotests.imgfmt, disk_path, size_str) iotests.qemu_img_create('-f', iotests.imgfmt, disk_path, size_str)
# Create a backing chain like this: # Create a backing chain like this:
# base <- [throttled: bps-read=4096] <- mid <- overlay # base <- [throttled: bps-read=4096] <- mid <- overlay
@ -92,8 +92,8 @@ with iotests.FilePath('src.qcow2') as src_path, \
size = 128 * 1024 * 1024 size = 128 * 1024 * 1024
size_str = str(size) size_str = str(size)
iotests.qemu_img_log('create', '-f', iotests.imgfmt, src_path, size_str) iotests.qemu_img_create('-f', iotests.imgfmt, src_path, size_str)
iotests.qemu_img_log('create', '-f', iotests.imgfmt, dst_path, size_str) iotests.qemu_img_create('-f', iotests.imgfmt, dst_path, size_str)
iotests.log(iotests.qemu_io('-f', iotests.imgfmt, '-c', 'write 0 1M', iotests.log(iotests.qemu_io('-f', iotests.imgfmt, '-c', 'write 0 1M',
src_path), src_path),

View File

@ -3,8 +3,6 @@ Finishing a commit job with background reads
=== Create backing chain and start VM === === Create backing chain and start VM ===
=== Start background read requests === === Start background read requests ===
=== Run a commit job === === Run a commit job ===
@ -21,8 +19,6 @@ Closing the VM while a job is being cancelled
=== Create images and start VM === === Create images and start VM ===
wrote 1048576/1048576 bytes at offset 0 wrote 1048576/1048576 bytes at offset 0
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)

View File

@ -240,13 +240,14 @@ def compare_images(image, reference, baseimg=None, expected_match=True):
""" """
expected_ret = 0 if expected_match else 1 expected_ret = 0 if expected_match else 1
if baseimg: if baseimg:
assert qemu_img("rebase", "-u", "-b", baseimg, '-F', iotests.imgfmt, qemu_img("rebase", "-u", "-b", baseimg, '-F', iotests.imgfmt, image)
image) == 0
ret = qemu_img("compare", image, reference) sub = qemu_img("compare", image, reference, check=False)
log('qemu_img compare "{:s}" "{:s}" ==> {:s}, {:s}'.format( log('qemu_img compare "{:s}" "{:s}" ==> {:s}, {:s}'.format(
image, reference, image, reference,
"Identical" if ret == 0 else "Mismatch", "Identical" if sub.returncode == 0 else "Mismatch",
"OK!" if ret == expected_ret else "ERROR!"), "OK!" if sub.returncode == expected_ret else "ERROR!"),
filters=[iotests.filter_testfiles]) filters=[iotests.filter_testfiles])
def test_bitmap_sync(bsync_mode, msync_mode='bitmap', failure=None): def test_bitmap_sync(bsync_mode, msync_mode='bitmap', failure=None):

View File

@ -75,13 +75,13 @@ def test_concurrent_finish(write_to_stream_node):
# It is important to use raw for the base layer (so that # It is important to use raw for the base layer (so that
# permissions are just handed through to the protocol layer) # permissions are just handed through to the protocol layer)
assert qemu_img('create', '-f', 'raw', node0_path, '64M') == 0 qemu_img('create', '-f', 'raw', node0_path, '64M')
stream_throttle=None stream_throttle=None
commit_throttle=None commit_throttle=None
for path in [node1_path, node2_path, node3_path, node4_path]: for path in [node1_path, node2_path, node3_path, node4_path]:
assert qemu_img('create', '-f', iotests.imgfmt, path, '64M') == 0 qemu_img('create', '-f', iotests.imgfmt, path, '64M')
if write_to_stream_node: if write_to_stream_node:
# This is what (most of the time) makes commit finish # This is what (most of the time) makes commit finish

View File

@ -51,7 +51,7 @@ with iotests.FilePath('img') as img_path, \
vm.add_device('virtio-blk,drive=%s,iothread=iothread0' % root) vm.add_device('virtio-blk,drive=%s,iothread=iothread0' % root)
iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, img_path, '64M') iotests.qemu_img_create('-f', iotests.imgfmt, img_path, '64M')
os.mkfifo(fifo) os.mkfifo(fifo)

View File

@ -137,7 +137,7 @@ def main():
iotests.log('') iotests.log('')
vm.shutdown() vm.shutdown()
iotests.img_info_log(file_path) iotests.img_info_log(file_path, check=False)
iotests.script_main(main, iotests.script_main(main,

View File

@ -31,12 +31,11 @@ size_long = 2 * 1024 * 1024
size_diff = size_long - size_short size_diff = size_long - size_short
def create_chain() -> None: def create_chain() -> None:
iotests.qemu_img_log('create', '-f', iotests.imgfmt, base, iotests.qemu_img_create('-f', iotests.imgfmt, base, str(size_long))
str(size_long)) iotests.qemu_img_create('-f', iotests.imgfmt, '-b', base,
iotests.qemu_img_log('create', '-f', iotests.imgfmt, '-b', base, '-F', iotests.imgfmt, mid, str(size_short))
'-F', iotests.imgfmt, mid, str(size_short)) iotests.qemu_img_create('-f', iotests.imgfmt, '-b', mid,
iotests.qemu_img_log('create', '-f', iotests.imgfmt, '-b', mid, '-F', iotests.imgfmt, top, str(size_long))
'-F', iotests.imgfmt, top, str(size_long))
iotests.qemu_io_log('-c', 'write -P 1 0 %d' % size_long, base) iotests.qemu_io_log('-c', 'write -P 1 0 %d' % size_long, base)
@ -160,9 +159,9 @@ with iotests.FilePath('base') as base, \
('off', '512k', '256k', '500k', '436k')]: ('off', '512k', '256k', '500k', '436k')]:
iotests.log('=== preallocation=%s ===' % prealloc) iotests.log('=== preallocation=%s ===' % prealloc)
iotests.qemu_img_log('create', '-f', iotests.imgfmt, base, base_size) iotests.qemu_img_create('-f', iotests.imgfmt, base, base_size)
iotests.qemu_img_log('create', '-f', iotests.imgfmt, '-b', base, iotests.qemu_img_create('-f', iotests.imgfmt, '-b', base,
'-F', iotests.imgfmt, top, top_size_old) '-F', iotests.imgfmt, top, top_size_old)
iotests.qemu_io_log('-c', 'write -P 1 %s 64k' % off, base) iotests.qemu_io_log('-c', 'write -P 1 %s 64k' % off, base)
# After this, top_size_old to base_size should be allocated/zeroed. # After this, top_size_old to base_size should be allocated/zeroed.

View File

@ -1,7 +1,4 @@
== Commit tests == == Commit tests ==
wrote 2097152/2097152 bytes at offset 0 wrote 2097152/2097152 bytes at offset 0
2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@ -63,9 +60,6 @@ read 1048576/1048576 bytes at offset 1048576
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
=== Testing HMP commit (top -> mid) === === Testing HMP commit (top -> mid) ===
wrote 2097152/2097152 bytes at offset 0 wrote 2097152/2097152 bytes at offset 0
2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@ -92,9 +86,6 @@ read 1048576/1048576 bytes at offset 1048576
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
=== Testing QMP active commit (top -> mid) === === Testing QMP active commit (top -> mid) ===
wrote 2097152/2097152 bytes at offset 0 wrote 2097152/2097152 bytes at offset 0
2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@ -127,9 +118,6 @@ read 1048576/1048576 bytes at offset 1048576
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
=== Testing qemu-img commit (top -> base) === === Testing qemu-img commit (top -> base) ===
wrote 2097152/2097152 bytes at offset 0 wrote 2097152/2097152 bytes at offset 0
2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@ -154,9 +142,6 @@ read 1048576/1048576 bytes at offset 1048576
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
=== Testing QMP active commit (top -> base) === === Testing QMP active commit (top -> base) ===
wrote 2097152/2097152 bytes at offset 0 wrote 2097152/2097152 bytes at offset 0
2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@ -190,8 +175,6 @@ read 1048576/1048576 bytes at offset 1048576
== Resize tests == == Resize tests ==
=== preallocation=off === === preallocation=off ===
wrote 65536/65536 bytes at offset 5368709120 wrote 65536/65536 bytes at offset 5368709120
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@ -207,8 +190,6 @@ read 65536/65536 bytes at offset 5368709120
{ "start": 1073741824, "length": 7516192768, "depth": 0, "present": true, "zero": true, "data": false}] { "start": 1073741824, "length": 7516192768, "depth": 0, "present": true, "zero": true, "data": false}]
=== preallocation=metadata === === preallocation=metadata ===
wrote 65536/65536 bytes at offset 33285996544 wrote 65536/65536 bytes at offset 33285996544
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@ -229,8 +210,6 @@ read 65536/65536 bytes at offset 33285996544
{ "start": 34896609280, "length": 536870912, "depth": 0, "present": true, "zero": true, "data": false, "offset": 2685075456}] { "start": 34896609280, "length": 536870912, "depth": 0, "present": true, "zero": true, "data": false, "offset": 2685075456}]
=== preallocation=falloc === === preallocation=falloc ===
wrote 65536/65536 bytes at offset 9437184 wrote 65536/65536 bytes at offset 9437184
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@ -246,8 +225,6 @@ read 65536/65536 bytes at offset 9437184
{ "start": 5242880, "length": 10485760, "depth": 0, "present": true, "zero": false, "data": true, "offset": 327680}] { "start": 5242880, "length": 10485760, "depth": 0, "present": true, "zero": false, "data": true, "offset": 327680}]
=== preallocation=full === === preallocation=full ===
wrote 65536/65536 bytes at offset 11534336 wrote 65536/65536 bytes at offset 11534336
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@ -263,8 +240,6 @@ read 65536/65536 bytes at offset 11534336
{ "start": 8388608, "length": 4194304, "depth": 0, "present": true, "zero": false, "data": true, "offset": 327680}] { "start": 8388608, "length": 4194304, "depth": 0, "present": true, "zero": false, "data": true, "offset": 327680}]
=== preallocation=off === === preallocation=off ===
wrote 65536/65536 bytes at offset 259072 wrote 65536/65536 bytes at offset 259072
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@ -281,8 +256,6 @@ read 65536/65536 bytes at offset 259072
{ "start": 262144, "length": 262144, "depth": 0, "present": true, "zero": true, "data": false}] { "start": 262144, "length": 262144, "depth": 0, "present": true, "zero": true, "data": false}]
=== preallocation=off === === preallocation=off ===
wrote 65536/65536 bytes at offset 344064 wrote 65536/65536 bytes at offset 344064
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@ -298,8 +271,6 @@ read 65536/65536 bytes at offset 344064
{ "start": 262144, "length": 262144, "depth": 0, "present": true, "zero": true, "data": false}] { "start": 262144, "length": 262144, "depth": 0, "present": true, "zero": true, "data": false}]
=== preallocation=off === === preallocation=off ===
wrote 65536/65536 bytes at offset 446464 wrote 65536/65536 bytes at offset 446464
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)

View File

@ -33,7 +33,7 @@ with iotests.FilePath('base') as base_path , \
iotests.FilePath('top') as top_path, \ iotests.FilePath('top') as top_path, \
iotests.VM() as vm: iotests.VM() as vm:
iotests.qemu_img_log('create', '-f', iotests.imgfmt, base_path, '64M') iotests.qemu_img_create('-f', iotests.imgfmt, base_path, '64M')
iotests.log('=== Launch VM ===') iotests.log('=== Launch VM ===')
vm.add_object('iothread,id=iothread0') vm.add_object('iothread,id=iothread0')

View File

@ -1,4 +1,3 @@
=== Launch VM === === Launch VM ===
Enabling migration QMP events on VM... Enabling migration QMP events on VM...
{"return": {}} {"return": {}}

View File

@ -76,7 +76,7 @@ class EncryptionSetupTestCase(iotests.QMPTestCase):
# create the encrypted block device using qemu-img # create the encrypted block device using qemu-img
def createImg(self, file, secret): def createImg(self, file, secret):
output = iotests.qemu_img_pipe( iotests.qemu_img(
'create', 'create',
'--object', *secret.to_cmdline_object(), '--object', *secret.to_cmdline_object(),
'-f', iotests.imgfmt, '-f', iotests.imgfmt,
@ -84,8 +84,7 @@ class EncryptionSetupTestCase(iotests.QMPTestCase):
'-o', 'iter-time=10', '-o', 'iter-time=10',
file, file,
'1M') '1M')
iotests.log('')
iotests.log(output, filters=[iotests.filter_test_dir])
# attempts to add a key using qemu-img # attempts to add a key using qemu-img
def addKey(self, file, secret, new_secret): def addKey(self, file, secret, new_secret):
@ -99,7 +98,7 @@ class EncryptionSetupTestCase(iotests.QMPTestCase):
} }
} }
output = iotests.qemu_img_pipe( output = iotests.qemu_img(
'amend', 'amend',
'--object', *secret.to_cmdline_object(), '--object', *secret.to_cmdline_object(),
'--object', *new_secret.to_cmdline_object(), '--object', *new_secret.to_cmdline_object(),
@ -108,8 +107,9 @@ class EncryptionSetupTestCase(iotests.QMPTestCase):
'-o', 'new-secret=' + new_secret.id(), '-o', 'new-secret=' + new_secret.id(),
'-o', 'iter-time=10', '-o', 'iter-time=10',
"json:" + json.dumps(image_options) "json:" + json.dumps(image_options),
) check=False # Expected to fail. Log output.
).stdout
iotests.log(output, filters=[iotests.filter_test_dir]) iotests.log(output, filters=[iotests.filter_test_dir])

View File

@ -38,7 +38,7 @@ def create_bitmap(bitmap_number, disabled):
if disabled: if disabled:
args.append('--disable') args.append('--disable')
iotests.qemu_img_pipe(*args) iotests.qemu_img(*args)
def write_to_disk(offset, size): def write_to_disk(offset, size):

View File

@ -43,15 +43,15 @@ with iotests.FilePath('base.img') as base_img_path, \
log('--- Setting up images ---') log('--- Setting up images ---')
log('') log('')
assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') == 0 qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M')
assert qemu_io_silent(base_img_path, '-c', 'write -P 1 0M 1M') == 0 assert qemu_io_silent(base_img_path, '-c', 'write -P 1 0M 1M') == 0
assert qemu_io_silent(base_img_path, '-c', 'write -P 1 3M 1M') == 0 assert qemu_io_silent(base_img_path, '-c', 'write -P 1 3M 1M') == 0
assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path, qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
'-F', iotests.imgfmt, mid_img_path) == 0 '-F', iotests.imgfmt, mid_img_path)
assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 2M 1M') == 0 assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 2M 1M') == 0
assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 4M 1M') == 0 assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 4M 1M') == 0
assert qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path, qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path,
'-F', iotests.imgfmt, top_img_path) == 0 '-F', iotests.imgfmt, top_img_path)
assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') == 0 assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') == 0
# 0 1 2 3 4 # 0 1 2 3 4
@ -105,8 +105,7 @@ with iotests.FilePath('base.img') as base_img_path, \
log('') log('')
# Detach backing to check that we can read the data from the top level now # Detach backing to check that we can read the data from the top level now
assert qemu_img('rebase', '-u', '-b', '', '-f', iotests.imgfmt, qemu_img('rebase', '-u', '-b', '', '-f', iotests.imgfmt, top_img_path)
top_img_path) == 0
assert qemu_io_silent(top_img_path, '-c', 'read -P 0 0 1M') == 0 assert qemu_io_silent(top_img_path, '-c', 'read -P 0 0 1M') == 0
assert qemu_io_silent(top_img_path, '-c', 'read -P 2 1M 1M') == 0 assert qemu_io_silent(top_img_path, '-c', 'read -P 2 1M 1M') == 0

View File

@ -106,13 +106,13 @@ _filter_hmp()
# replace block job offset # replace block job offset
_filter_block_job_offset() _filter_block_job_offset()
{ {
sed -e 's/, "offset": [0-9]\+,/, "offset": OFFSET,/' gsed -e 's/, "offset": [0-9]\+,/, "offset": OFFSET,/'
} }
# replace block job len # replace block job len
_filter_block_job_len() _filter_block_job_len()
{ {
sed -e 's/, "len": [0-9]\+,/, "len": LEN,/g' gsed -e 's/, "len": [0-9]\+,/, "len": LEN,/g'
} }
# replace actual image size (depends on the host filesystem) # replace actual image size (depends on the host filesystem)

View File

@ -37,9 +37,10 @@ import unittest
from contextlib import contextmanager from contextlib import contextmanager
from qemu.aqmp.legacy import QEMUMonitorProtocol
from qemu.machine import qtest from qemu.machine import qtest
from qemu.qmp import QMPMessage from qemu.qmp import QMPMessage
from qemu.aqmp.legacy import QEMUMonitorProtocol from qemu.utils import VerboseProcessError
# Use this logger for logging messages directly from the iotests module # Use this logger for logging messages directly from the iotests module
logger = logging.getLogger('qemu.iotests') logger = logging.getLogger('qemu.iotests')
@ -206,18 +207,50 @@ def qemu_img_create_prepare_args(args: List[str]) -> List[str]:
return result return result
def qemu_img_pipe_and_status(*args: str) -> Tuple[str, int]: def qemu_img(*args: str, check: bool = True, combine_stdio: bool = True
) -> 'subprocess.CompletedProcess[str]':
""" """
Run qemu-img and return both its output and its exit code Run qemu_img and return the status code and console output.
"""
is_create = bool(args and args[0] == 'create') This function always prepends QEMU_IMG_OPTIONS and may further alter
full_args = qemu_img_args + qemu_img_create_prepare_args(list(args)) the args for 'create' commands.
return qemu_tool_pipe_and_status('qemu-img', full_args,
drop_successful_output=is_create) :param args: command-line arguments to qemu-img.
:param check: Enforce a return code of zero.
:param combine_stdio: set to False to keep stdout/stderr separated.
:raise VerboseProcessError:
When the return code is negative, or on any non-zero exit code
when 'check=True' was provided (the default). This exception has
'stdout', 'stderr', and 'returncode' properties that may be
inspected to show greater detail. If this exception is not
handled, the command-line, return code, and all console output
will be included at the bottom of the stack trace.
:return:
a CompletedProcess. This object has args, returncode, and stdout
properties. If streams are not combined, it will also have a
stderr property.
"""
full_args = qemu_img_args + qemu_img_create_prepare_args(list(args))
subp = subprocess.run(
full_args,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT if combine_stdio else subprocess.PIPE,
universal_newlines=True,
check=False
)
if check and subp.returncode or (subp.returncode < 0):
raise VerboseProcessError(
subp.returncode, full_args,
output=subp.stdout,
stderr=subp.stderr,
)
return subp
def qemu_img(*args: str) -> int:
'''Run qemu-img and return the exit code'''
return qemu_img_pipe_and_status(*args)[1]
def ordered_qmp(qmsg, conv_keys=True): def ordered_qmp(qmsg, conv_keys=True):
# Dictionaries are not ordered prior to 3.6, therefore: # Dictionaries are not ordered prior to 3.6, therefore:
@ -232,26 +265,63 @@ def ordered_qmp(qmsg, conv_keys=True):
return od return od
return qmsg return qmsg
def qemu_img_create(*args): def qemu_img_create(*args: str) -> 'subprocess.CompletedProcess[str]':
return qemu_img('create', *args) return qemu_img('create', *args)
def qemu_img_measure(*args): def qemu_img_json(*args: str) -> Any:
return json.loads(qemu_img_pipe("measure", "--output", "json", *args)) """
Run qemu-img and return its output as deserialized JSON.
def qemu_img_check(*args): :raise CalledProcessError:
return json.loads(qemu_img_pipe("check", "--output", "json", *args)) When qemu-img crashes, or returns a non-zero exit code without
producing a valid JSON document to stdout.
:raise JSONDecoderError:
When qemu-img returns 0, but failed to produce a valid JSON document.
def qemu_img_pipe(*args: str) -> str: :return: A deserialized JSON object; probably a dict[str, Any].
'''Run qemu-img and return its output''' """
return qemu_img_pipe_and_status(*args)[0] try:
res = qemu_img(*args, combine_stdio=False)
except subprocess.CalledProcessError as exc:
# Terminated due to signal. Don't bother.
if exc.returncode < 0:
raise
def qemu_img_log(*args): # Commands like 'check' can return failure (exit codes 2 and 3)
result = qemu_img_pipe(*args) # to indicate command completion, but with errors found. For
log(result, filters=[filter_testfiles]) # multi-command flexibility, ignore the exact error codes and
# *try* to load JSON.
try:
return json.loads(exc.stdout)
except json.JSONDecodeError:
# Nope. This thing is toast. Raise the /process/ error.
pass
raise
return json.loads(res.stdout)
def qemu_img_measure(*args: str) -> Any:
return qemu_img_json("measure", "--output", "json", *args)
def qemu_img_check(*args: str) -> Any:
return qemu_img_json("check", "--output", "json", *args)
def qemu_img_info(*args: str) -> Any:
return qemu_img_json('info', "--output", "json", *args)
def qemu_img_map(*args: str) -> Any:
return qemu_img_json('map', "--output", "json", *args)
def qemu_img_log(*args: str, check: bool = True
) -> 'subprocess.CompletedProcess[str]':
result = qemu_img(*args, check=check)
log(result.stdout, filters=[filter_testfiles])
return result return result
def img_info_log(filename, filter_path=None, use_image_opts=False, def img_info_log(filename: str, filter_path: Optional[str] = None,
extra_args=()): use_image_opts: bool = False, extra_args: Sequence[str] = (),
check: bool = True,
) -> None:
args = ['info'] args = ['info']
if use_image_opts: if use_image_opts:
args.append('--image-opts') args.append('--image-opts')
@ -260,7 +330,7 @@ def img_info_log(filename, filter_path=None, use_image_opts=False,
args += extra_args args += extra_args
args.append(filename) args.append(filename)
output = qemu_img_pipe(*args) output = qemu_img(*args, check=check).stdout
if not filter_path: if not filter_path:
filter_path = filename filter_path = filename
log(filter_img_info(output, filter_path)) log(filter_img_info(output, filter_path))
@ -465,10 +535,22 @@ def qemu_nbd_popen(*args):
p.kill() p.kill()
p.wait() p.wait()
def compare_images(img1, img2, fmt1=imgfmt, fmt2=imgfmt): def compare_images(img1: str, img2: str,
'''Return True if two image files are identical''' fmt1: str = imgfmt, fmt2: str = imgfmt) -> bool:
return qemu_img('compare', '-f', fmt1, """
'-F', fmt2, img1, img2) == 0 Compare two images with QEMU_IMG; return True if they are identical.
:raise CalledProcessError:
when qemu-img crashes or returns a status code of anything other
than 0 (identical) or 1 (different).
"""
try:
qemu_img('compare', '-f', fmt1, '-F', fmt2, img1, img2)
return True
except subprocess.CalledProcessError as exc:
if exc.returncode == 1:
return False
raise
def create_image(name, size): def create_image(name, size):
'''Create a fully-allocated raw image with sector markers''' '''Create a fully-allocated raw image with sector markers'''
@ -479,10 +561,14 @@ def create_image(name, size):
file.write(sector) file.write(sector)
i = i + 512 i = i + 512
def image_size(img): def image_size(img: str) -> int:
'''Return image's virtual size''' """Return image's virtual size"""
r = qemu_img_pipe('info', '--output=json', '-f', imgfmt, img) value = qemu_img_info('-f', imgfmt, img)['virtual-size']
return json.loads(r)['virtual-size'] if not isinstance(value, int):
type_name = type(value).__name__
raise TypeError("Expected 'int' for 'virtual-size', "
f"got '{value}' of type '{type_name}'")
return value
def is_str(val): def is_str(val):
return isinstance(val, str) return isinstance(val, str)
@ -521,8 +607,10 @@ def filter_qmp(qmsg, filter_fn):
# Iterate through either lists or dicts; # Iterate through either lists or dicts;
if isinstance(qmsg, list): if isinstance(qmsg, list):
items = enumerate(qmsg) items = enumerate(qmsg)
else: elif isinstance(qmsg, dict):
items = qmsg.items() items = qmsg.items()
else:
return filter_fn(None, qmsg)
for k, v in items: for k, v in items:
if isinstance(v, (dict, list)): if isinstance(v, (dict, list)):
@ -858,8 +946,12 @@ class VM(qtest.QEMUQtestMachine):
return result return result
# Returns None on success, and an error string on failure # Returns None on success, and an error string on failure
def run_job(self, job, auto_finalize=True, auto_dismiss=False, def run_job(self, job: str, auto_finalize: bool = True,
pre_finalize=None, cancel=False, wait=60.0): auto_dismiss: bool = False,
pre_finalize: Optional[Callable[[], None]] = None,
cancel: bool = False, wait: float = 60.0,
filters: Iterable[Callable[[Any], Any]] = (),
) -> Optional[str]:
""" """
run_job moves a job from creation through to dismissal. run_job moves a job from creation through to dismissal.
@ -889,7 +981,7 @@ class VM(qtest.QEMUQtestMachine):
while True: while True:
ev = filter_qmp_event(self.events_wait(events, timeout=wait)) ev = filter_qmp_event(self.events_wait(events, timeout=wait))
if ev['event'] != 'JOB_STATUS_CHANGE': if ev['event'] != 'JOB_STATUS_CHANGE':
log(ev) log(ev, filters=filters)
continue continue
status = ev['data']['status'] status = ev['data']['status']
if status == 'aborting': if status == 'aborting':
@ -897,18 +989,18 @@ class VM(qtest.QEMUQtestMachine):
for j in result['return']: for j in result['return']:
if j['id'] == job: if j['id'] == job:
error = j['error'] error = j['error']
log('Job failed: %s' % (j['error'])) log('Job failed: %s' % (j['error']), filters=filters)
elif status == 'ready': elif status == 'ready':
self.qmp_log('job-complete', id=job) self.qmp_log('job-complete', id=job, filters=filters)
elif status == 'pending' and not auto_finalize: elif status == 'pending' and not auto_finalize:
if pre_finalize: if pre_finalize:
pre_finalize() pre_finalize()
if cancel: if cancel:
self.qmp_log('job-cancel', id=job) self.qmp_log('job-cancel', id=job, filters=filters)
else: else:
self.qmp_log('job-finalize', id=job) self.qmp_log('job-finalize', id=job, filters=filters)
elif status == 'concluded' and not auto_dismiss: elif status == 'concluded' and not auto_dismiss:
self.qmp_log('job-dismiss', id=job) self.qmp_log('job-dismiss', id=job, filters=filters)
elif status == 'null': elif status == 'null':
return error return error
@ -921,7 +1013,7 @@ class VM(qtest.QEMUQtestMachine):
if 'return' in result: if 'return' in result:
assert result['return'] == {} assert result['return'] == {}
job_result = self.run_job(job_id) job_result = self.run_job(job_id, filters=filters)
else: else:
job_result = result['error'] job_result = result['error']
@ -1332,8 +1424,8 @@ def _verify_imgopts(unsupported: Sequence[str] = ()) -> None:
notrun(f'not suitable for this imgopts: {imgopts}') notrun(f'not suitable for this imgopts: {imgopts}')
def supports_quorum(): def supports_quorum() -> bool:
return 'quorum' in qemu_img_pipe('--help') return 'quorum' in qemu_img('--help').stdout
def verify_quorum(): def verify_quorum():
'''Skip test suite if quorum support is not available''' '''Skip test suite if quorum support is not available'''
@ -1349,20 +1441,20 @@ def has_working_luks() -> Tuple[bool, str]:
""" """
img_file = f'{test_dir}/luks-test.luks' img_file = f'{test_dir}/luks-test.luks'
(output, status) = \ res = qemu_img('create', '-f', 'luks',
qemu_img_pipe_and_status('create', '-f', 'luks', '--object', luks_default_secret_object,
'--object', luks_default_secret_object, '-o', luks_default_key_secret_opt,
'-o', luks_default_key_secret_opt, '-o', 'iter-time=10',
'-o', 'iter-time=10', img_file, '1G',
img_file, '1G') check=False)
try: try:
os.remove(img_file) os.remove(img_file)
except OSError: except OSError:
pass pass
if status != 0: if res.returncode:
reason = output reason = res.stdout
for line in output.splitlines(): for line in res.stdout.splitlines():
if img_file + ':' in line: if img_file + ':' in line:
reason = line.split(img_file + ':', 1)[1].strip() reason = line.split(img_file + ':', 1)[1].strip()
break break

View File

@ -235,6 +235,8 @@ class TestEnv(ContextManager['TestEnv']):
('aarch64', 'virt'), ('aarch64', 'virt'),
('avr', 'mega2560'), ('avr', 'mega2560'),
('m68k', 'virt'), ('m68k', 'virt'),
('riscv32', 'virt'),
('riscv64', 'virt'),
('rx', 'gdbsim-r5f562n8'), ('rx', 'gdbsim-r5f562n8'),
('tricore', 'tricore_testboard') ('tricore', 'tricore_testboard')
) )

View File

@ -388,6 +388,7 @@ class TestRunner(ContextManager['TestRunner']):
if self.tap: if self.tap:
self.env.print_env('# ') self.env.print_env('# ')
print('1..%d' % len(tests))
else: else:
self.env.print_env() self.env.print_env()

View File

@ -22,7 +22,7 @@
import os import os
import signal import signal
import iotests import iotests
from iotests import qemu_img_create, qemu_img_pipe, qemu_nbd from iotests import qemu_img_create, qemu_img_map, qemu_nbd
image_size = 1 * 1024 * 1024 image_size = 1 * 1024 * 1024
@ -35,8 +35,7 @@ nbd_sock = os.path.join(iotests.sock_dir, 'nbd.sock')
class TestBscWithNbd(iotests.QMPTestCase): class TestBscWithNbd(iotests.QMPTestCase):
def setUp(self) -> None: def setUp(self) -> None:
"""Just create an empty image with a read-only NBD server on it""" """Just create an empty image with a read-only NBD server on it"""
assert qemu_img_create('-f', iotests.imgfmt, test_img, qemu_img_create('-f', iotests.imgfmt, test_img, str(image_size))
str(image_size)) == 0
# Pass --allocation-depth to enable the qemu:allocation-depth context, # Pass --allocation-depth to enable the qemu:allocation-depth context,
# which we are going to query to provoke a block-status inquiry with # which we are going to query to provoke a block-status inquiry with
@ -77,8 +76,7 @@ class TestBscWithNbd(iotests.QMPTestCase):
# to allocate the first sector to facilitate alignment probing), and # to allocate the first sector to facilitate alignment probing), and
# then the rest to be zero. The BSC will thus contain (if anything) # then the rest to be zero. The BSC will thus contain (if anything)
# one range covering the first sector. # one range covering the first sector.
map_pre = qemu_img_pipe('map', '--output=json', '--image-opts', map_pre = qemu_img_map('--image-opts', nbd_img_opts)
nbd_img_opts)
# qemu:allocation-depth maps for want_zero=false. # qemu:allocation-depth maps for want_zero=false.
# want_zero=false should (with the file driver, which the server is # want_zero=false should (with the file driver, which the server is
@ -112,14 +110,12 @@ class TestBscWithNbd(iotests.QMPTestCase):
# never loop too many times here. # never loop too many times here.
for _ in range(2): for _ in range(2):
# (Ignore the result, this is just to contaminate the cache) # (Ignore the result, this is just to contaminate the cache)
qemu_img_pipe('map', '--output=json', '--image-opts', qemu_img_map('--image-opts', nbd_img_opts_alloc_depth)
nbd_img_opts_alloc_depth)
# Now let's see whether the cache reports everything as data, or # Now let's see whether the cache reports everything as data, or
# whether we get correct information (i.e. the same as we got on our # whether we get correct information (i.e. the same as we got on our
# first attempt). # first attempt).
map_post = qemu_img_pipe('map', '--output=json', '--image-opts', map_post = qemu_img_map('--image-opts', nbd_img_opts)
nbd_img_opts)
if map_pre != map_post: if map_pre != map_post:
print('ERROR: Map information differs before and after querying ' + print('ERROR: Map information differs before and after querying ' +

View File

@ -34,16 +34,15 @@ def do_qemu_img_bench() -> None:
""" """
Do some I/O requests on `nbd_sock`. Do some I/O requests on `nbd_sock`.
""" """
assert qemu_img('bench', '-f', 'raw', '-c', '2000000', qemu_img('bench', '-f', 'raw', '-c', '2000000',
f'nbd+unix:///node0?socket={nbd_sock}') == 0 f'nbd+unix:///node0?socket={nbd_sock}')
class TestGraphChangesWhileIO(QMPTestCase): class TestGraphChangesWhileIO(QMPTestCase):
def setUp(self) -> None: def setUp(self) -> None:
# Create an overlay that can be added at runtime on top of the # Create an overlay that can be added at runtime on top of the
# null-co block node that will receive I/O # null-co block node that will receive I/O
assert qemu_img_create('-f', imgfmt, '-F', 'raw', '-b', 'null-co://', qemu_img_create('-f', imgfmt, '-F', 'raw', '-b', 'null-co://', top)
top) == 0
# QSD instance with a null-co block node in an I/O thread, # QSD instance with a null-co block node in an I/O thread,
# exported over NBD (on `nbd_sock`, export name "node0") # exported over NBD (on `nbd_sock`, export name "node0")

View File

@ -63,18 +63,18 @@ def do_test(vm, use_cbw, use_snapshot_access_filter, base_img_path,
log('--- Setting up images ---') log('--- Setting up images ---')
log('') log('')
assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') == 0 qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M')
if bitmap: if bitmap:
assert qemu_img('bitmap', '--add', base_img_path, 'bitmap0') == 0 qemu_img('bitmap', '--add', base_img_path, 'bitmap0')
if use_snapshot_access_filter: if use_snapshot_access_filter:
assert use_cbw assert use_cbw
assert qemu_img('create', '-f', 'raw', fleece_img_path, '64M') == 0 qemu_img('create', '-f', 'raw', fleece_img_path, '64M')
else: else:
assert qemu_img('create', '-f', 'qcow2', fleece_img_path, '64M') == 0 qemu_img('create', '-f', 'qcow2', fleece_img_path, '64M')
if push_backup: if push_backup:
assert qemu_img('create', '-f', 'qcow2', target_img_path, '64M') == 0 qemu_img('create', '-f', 'qcow2', target_img_path, '64M')
for p in patterns: for p in patterns:
qemu_io('-f', iotests.imgfmt, qemu_io('-f', iotests.imgfmt,

View File

@ -31,10 +31,8 @@ target = os.path.join(iotests.test_dir, 'target.img')
class TestMirrorReadyCancelError(iotests.QMPTestCase): class TestMirrorReadyCancelError(iotests.QMPTestCase):
def setUp(self) -> None: def setUp(self) -> None:
assert iotests.qemu_img_create('-f', iotests.imgfmt, source, iotests.qemu_img_create('-f', iotests.imgfmt, source, str(image_size))
str(image_size)) == 0 iotests.qemu_img_create('-f', iotests.imgfmt, target, str(image_size))
assert iotests.qemu_img_create('-f', iotests.imgfmt, target,
str(image_size)) == 0
# Ensure that mirror will copy something before READY so the # Ensure that mirror will copy something before READY so the
# target format layer will forward the pre-READY flush to its # target format layer will forward the pre-READY flush to its

View File

@ -34,8 +34,7 @@ source = os.path.join(iotests.test_dir, 'source.img')
class TestMirrorTopPerms(iotests.QMPTestCase): class TestMirrorTopPerms(iotests.QMPTestCase):
def setUp(self): def setUp(self):
assert qemu_img('create', '-f', iotests.imgfmt, source, qemu_img('create', '-f', iotests.imgfmt, source, str(image_size))
str(image_size)) == 0
self.vm = iotests.VM() self.vm = iotests.VM()
self.vm.add_drive(source) self.vm.add_drive(source)
self.vm.add_blockdev(f'null-co,node-name=null,size={image_size}') self.vm.add_blockdev(f'null-co,node-name=null,size={image_size}')

View File

@ -18,9 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
import json
import iotests import iotests
from iotests import qemu_nbd_popen, qemu_img_pipe, log, file_path from iotests import qemu_nbd_popen, qemu_img_map, log, file_path
iotests.script_initialize(supported_fmts=['parallels']) iotests.script_initialize(supported_fmts=['parallels'])
@ -36,8 +35,7 @@ iotests.unarchive_sample_image('parallels-with-bitmap', disk)
with qemu_nbd_popen('--read-only', f'--socket={nbd_sock}', with qemu_nbd_popen('--read-only', f'--socket={nbd_sock}',
f'--bitmap={bitmap}', '-f', iotests.imgfmt, disk): f'--bitmap={bitmap}', '-f', iotests.imgfmt, disk):
out = qemu_img_pipe('map', '--output=json', '--image-opts', nbd_opts) chunks = qemu_img_map('--image-opts', nbd_opts)
chunks = json.loads(out)
cluster = 64 * 1024 cluster = 64 * 1024
log('dirty clusters (cluster size is 64K):') log('dirty clusters (cluster size is 64K):')

View File

@ -19,7 +19,7 @@
# #
import iotests import iotests
from iotests import log, qemu_img_create, qemu_img, qemu_img_pipe from iotests import log, qemu_img_create, qemu_img, qemu_img_info
iotests.script_initialize(supported_fmts=['qcow2'], iotests.script_initialize(supported_fmts=['qcow2'],
unsupported_imgopts=['compat']) unsupported_imgopts=['compat'])
@ -27,13 +27,13 @@ iotests.script_initialize(supported_fmts=['qcow2'],
top, base = iotests.file_path('top', 'base') top, base = iotests.file_path('top', 'base')
size = '1M' size = '1M'
assert qemu_img_create('-f', iotests.imgfmt, base, size) == 0 qemu_img_create('-f', iotests.imgfmt, base, size)
assert qemu_img_create('-f', iotests.imgfmt, '-b', base, qemu_img_create('-f', iotests.imgfmt, '-b', base,
'-F', iotests.imgfmt, top, size) == 0 '-F', iotests.imgfmt, top, size)
assert qemu_img('bitmap', '--add', base, 'bitmap0') == 0 qemu_img('bitmap', '--add', base, 'bitmap0')
# Just assert that our method of checking bitmaps in the image works. # Just assert that our method of checking bitmaps in the image works.
assert 'bitmaps' in qemu_img_pipe('info', base) assert 'bitmaps' in qemu_img_info(base)['format-specific']['data']
vm = iotests.VM().add_drive(top, 'backing.node-name=base') vm = iotests.VM().add_drive(top, 'backing.node-name=base')
vm.launch() vm.launch()
@ -68,5 +68,5 @@ if result != {'return': {}}:
vm.shutdown() vm.shutdown()
if 'bitmaps' in qemu_img_pipe('info', base): if 'bitmaps' in qemu_img_info(base)['format-specific']['data']:
log('ERROR: Bitmap is still in the base image') log('ERROR: Bitmap is still in the base image')

View File

@ -54,9 +54,9 @@ class TestStreamErrorOnReset(QMPTestCase):
to it will result in an error to it will result in an error
- top image is attached to a virtio-scsi device - top image is attached to a virtio-scsi device
""" """
assert qemu_img_create('-f', imgfmt, base, str(image_size)) == 0 qemu_img_create('-f', imgfmt, base, str(image_size))
assert qemu_io_silent('-c', f'write 0 {data_size}', base) == 0 assert qemu_io_silent('-c', f'write 0 {data_size}', base) == 0
assert qemu_img_create('-f', imgfmt, top, str(image_size)) == 0 qemu_img_create('-f', imgfmt, top, str(image_size))
self.vm = iotests.VM() self.vm = iotests.VM()
self.vm.add_args('-accel', 'tcg') # Make throttling work properly self.vm.add_args('-accel', 'tcg') # Make throttling work properly