Block patches:

- Fixes to qcow2's implementation of qemu-img check
 - Our SSH driver now supports bdrv_refresh_filename()
 - Miscellaneous fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQEcBAABAgAGBQJc0aFqAAoJEPQH2wBh1c9AfWoIAIDzFnhe4cFoLN9WLrZi9t4P
 F7bJAYwIZKPiZzeAmesMYh3NQIE4hcUHwfYiv7wgcCL6GCRPNW66QFj2yqBnPYjB
 XZ+CmDxGvWphkctzpn3wc3dC6ydiUDinMH0QRI5fMd07gAK+PnOb6YnvGYydJsFN
 X8qJeJ0PE//92KNdEr6oJHNNYT5KE01zdkcc1Hv7azcLMXquU9r3B/csOvqU/7iQ
 YLsqNs5rLnYehAgLh12v9A2NiDZOuOezPVGV9xjnmpsgg3gAVOPBccTwr7o6Wko2
 hPqYOzEU3ZEamEIfQROaVzBqt6QAKz9GsFPisbaTy5VoOKUOSsywd2jiWby4imA=
 =hahF
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2019-05-07' into staging

Block patches:
- Fixes to qcow2's implementation of qemu-img check
- Our SSH driver now supports bdrv_refresh_filename()
- Miscellaneous fixes

# gpg: Signature made Tue 07 May 2019 16:16:58 BST
# gpg:                using RSA key F407DB0061D5CF40
# gpg: Good signature from "Max Reitz <mreitz@redhat.com>" [full]
# Primary key fingerprint: 91BE B60A 30DB 3E88 57D1  1829 F407 DB00 61D5 CF40

* remotes/maxreitz/tags/pull-block-2019-05-07:
  iotests: Fix iotests 110 and 126
  commit: Use bdrv_append() in commit_start()
  block: Assert that drv->bdrv_child_perm is set in bdrv_child_perm()
  block/ssh: Implement .bdrv_dirname()
  block/ssh: Implement .bdrv_refresh_filename()
  qcow2: discard bitmap when removed
  qcow2-refcount: don't mask corruptions under internal errors
  qcow2-refcount: check_refcounts_l2: don't count fixed cluster as allocated
  qcow2-refcount: check_refcounts_l2: reduce ignored overlaps
  qcow2-refcount: avoid eating RAM
  qcow2-refcount: fix check_oflag_copied

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2019-05-09 16:31:12 +01:00
commit 812b835fb4
13 changed files with 159 additions and 77 deletions

View file

@ -53,8 +53,12 @@ TEST_IMG="$TEST_IMG.base" _make_test_img 64M
_make_test_img -b "$TEST_IMG_REL.base" 64M
# qemu should be able to reconstruct the filename, so relative backing names
# should work
# (We have to filter the backing file format because vmdk always
# reports it (as vmdk), whereas other image formats would do so only
# with the backing_fmt creation option, which neither vmdk nor qcow
# support)
TEST_IMG="json:{'driver':'$IMGFMT','file':{'driver':'file','filename':'$TEST_IMG'}}" \
_img_info | _filter_img_info
_img_info | _filter_img_info | grep -v 'backing file format'
echo
echo '=== Non-reconstructable filename ==='
@ -78,7 +82,7 @@ TEST_IMG="json:{
}
]
}
}" _img_info | _filter_img_info
}" _img_info | _filter_img_info | grep -v 'backing file format'
echo
echo '=== Backing name is always relative to the backed image ==='
@ -110,7 +114,7 @@ TEST_IMG="json:{
}
]
}
}" _img_info | _filter_img_info
}" _img_info | _filter_img_info | grep -v 'backing file format'
# success, all done

View file

@ -62,8 +62,12 @@ TOP_IMG="$TEST_DIR/image:top.$IMGFMT"
TEST_IMG=$BASE_IMG _make_test_img 64M
TEST_IMG=$TOP_IMG _make_test_img -b ./image:base.$IMGFMT
# The default cluster size depends on the image format
TEST_IMG=$TOP_IMG _img_info | grep -v 'cluster_size'
# (1) The default cluster size depends on the image format
# (2) vmdk only supports vmdk backing files, so it always reports the
# format of its backing file as such (but neither it nor qcow
# support the backing_fmt creation option, so we cannot use that to
# harmonize the output across all image formats this test supports)
TEST_IMG=$TOP_IMG _img_info | grep -ve 'cluster_size' -e 'backing file format'
_rm_test_img "$BASE_IMG"
_rm_test_img "$TOP_IMG"
@ -79,7 +83,7 @@ TOP_IMG="file:image:top.$IMGFMT"
TEST_IMG=$BASE_IMG _make_test_img 64M
TEST_IMG=$TOP_IMG _make_test_img -b "$BASE_IMG"
TEST_IMG=$TOP_IMG _img_info | grep -v 'cluster_size'
TEST_IMG=$TOP_IMG _img_info | grep -ve 'cluster_size' -e 'backing file format'
_rm_test_img "$BASE_IMG"
_rm_test_img "image:top.$IMGFMT"

View file

@ -54,15 +54,13 @@ $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io
# Put the data cluster at a multiple of 2 TB, resulting in the image apparently
# having a multiple of 2^32 clusters
# (To be more specific: It is at 32 PB)
poke_file "$TEST_IMG" 2048 "\x80\x80\x00\x00\x00\x00\x00\x00"
poke_file "$TEST_IMG" $((2048 + 8)) "\x00\x80\x00\x00\x00\x00\x00\x00"
# An offset of 32 PB results in qemu-img check having to allocate an in-memory
# refcount table of 128 TB (16 bit refcounts, 512 byte clusters).
# This should be generally too much for any system and thus fail.
# What this test is checking is that the qcow2 driver actually tries to allocate
# such a large amount of memory (and is consequently aborting) instead of having
# truncated the cluster count somewhere (which would result in much less memory
# being allocated and then a segfault occurring).
# refcount table of 128 TB (16 bit refcounts, 512 byte clusters), if qemu-img
# don't check that referenced data cluster is far beyond the end of file.
# But starting from 4.0, qemu-img does this check, and instead of "Cannot
# allocate memory", we have an error showing that l2 entry is invalid.
_check_test_img
# success, all done

View file

@ -5,5 +5,8 @@ QA output created by 138
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=512
wrote 512/512 bytes at offset 0
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
qemu-img: Check failed: Cannot allocate memory
ERROR: counting reference for region exceeding the end of the file by one cluster or more: offset 0x80000000000000 size 0x200
1 errors were found on the image.
Data may be corrupted, or further writes to the image may corrupt it.
*** done

View file

@ -66,7 +66,7 @@ with iotests.FilePath('t.img') as disk_path, \
'size': 4194304 })
vm.shutdown()
iotests.img_info_log(remote_path, filter_path=disk_path)
iotests.img_info_log(remote_path)
iotests.log("")
iotests.img_info_log(disk_path)
@ -91,7 +91,7 @@ with iotests.FilePath('t.img') as disk_path, \
'size': 8388608 })
vm.shutdown()
iotests.img_info_log(remote_path, filter_path=disk_path)
iotests.img_info_log(remote_path)
vm.launch()
blockdev_create(vm, { 'driver': 'ssh',
@ -108,7 +108,7 @@ with iotests.FilePath('t.img') as disk_path, \
'size': 4194304 })
vm.shutdown()
iotests.img_info_log(remote_path, filter_path=disk_path)
iotests.img_info_log(remote_path)
md5_key = subprocess.check_output(
'ssh-keyscan -t rsa 127.0.0.1 2>/dev/null | grep -v "\\^#" | ' +
@ -146,7 +146,7 @@ with iotests.FilePath('t.img') as disk_path, \
'size': 8388608 })
vm.shutdown()
iotests.img_info_log(remote_path, filter_path=disk_path)
iotests.img_info_log(remote_path)
sha1_key = subprocess.check_output(
'ssh-keyscan -t rsa 127.0.0.1 2>/dev/null | grep -v "\\^#" | ' +
@ -184,7 +184,7 @@ with iotests.FilePath('t.img') as disk_path, \
'size': 4194304 })
vm.shutdown()
iotests.img_info_log(remote_path, filter_path=disk_path)
iotests.img_info_log(remote_path)
#
# Invalid path and user

View file

@ -5,7 +5,7 @@
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
{"return": {}}
image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.port": "22", "driver": "ssh", "path": "TEST_IMG"}}
image: TEST_IMG
file format: IMGFMT
virtual size: 4 MiB (4194304 bytes)
@ -21,7 +21,7 @@ virtual size: 4 MiB (4194304 bytes)
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
{"return": {}}
image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.port": "22", "driver": "ssh", "path": "TEST_IMG"}}
image: TEST_IMG
file format: IMGFMT
virtual size: 8 MiB (8388608 bytes)
@ -30,7 +30,7 @@ virtual size: 8 MiB (8388608 bytes)
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
{"return": {}}
image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.port": "22", "driver": "ssh", "path": "TEST_IMG"}}
image: TEST_IMG
file format: IMGFMT
virtual size: 4 MiB (4194304 bytes)
@ -45,7 +45,7 @@ Job failed: remote host key does not match host_key_check 'wrong'
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
{"return": {}}
image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.port": "22", "driver": "ssh", "path": "TEST_IMG"}}
image: TEST_IMG
file format: IMGFMT
virtual size: 8 MiB (8388608 bytes)
@ -60,7 +60,7 @@ Job failed: remote host key does not match host_key_check 'wrong'
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
{"return": {}}
image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.port": "22", "driver": "ssh", "path": "TEST_IMG"}}
image: TEST_IMG
file format: IMGFMT
virtual size: 4 MiB (4194304 bytes)

View file

@ -158,7 +158,7 @@ else
TEST_IMG="nbd:127.0.0.1:10810"
elif [ "$IMGPROTO" = "ssh" ]; then
TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT
REMOTE_TEST_DIR="ssh://127.0.0.1$TEST_DIR"
REMOTE_TEST_DIR="ssh://\\($USER@\\)\\?127.0.0.1\\(:[0-9]\\+\\)\\?$TEST_DIR"
TEST_IMG="ssh://127.0.0.1$TEST_IMG_FILE"
elif [ "$IMGPROTO" = "nfs" ]; then
TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT

View file

@ -411,7 +411,7 @@ def remote_filename(path):
if imgproto == 'file':
return path
elif imgproto == 'ssh':
return "ssh://127.0.0.1%s" % (path)
return "ssh://%s@127.0.0.1:22%s" % (os.environ.get('USER'), path)
else:
raise Exception("Protocol %s not supported" % (imgproto))