Block layer patches

- Event throttling for BLOCK_IO_ERROR
 - iotests: Fix backup-discard-source test for XFS
 - Coverity fixes
 - raw-format: Fix error message for invalid offset/size
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEE3D3rFZqa+V09dFb+fwmycsiPL9YFAmcX1wQRHGt3b2xmQHJl
 ZGhhdC5jb20ACgkQfwmycsiPL9aWKA//cyG+Q3EXLouSu2Ob04RArX8HgAzLmHL3
 Fx9x6BbDtusPfzxKVLqhJhJ5/oRyk0QWkdZKGNSxinLD3DBJ6q6FMNaWhuvzOBcy
 iHnWlMfwEIBl5vFJwM5Q/d7F2afOUiVSeR7E4TQn063cBo96qIrAD7DRLM01jBEN
 d9+9nkBruwgmxZJIr3WTsqjDoTqflcjxA6Adp/WkzVXBMMYqcsuReXQtrgfFooKw
 yhjkHq5nFKzebvK+BLjA0ytuvUlsRqLYDXN+bAk/rC6oCgbzygAjNwL5kUEYnV1r
 lVRSOxRUlet4v2GFCvplxw5tX3aJzlWB50v7d+oaBYR72htTtPeIZzadBJySdtSk
 DxEUR5kTcGK/vSI+WOapTVK+qU+Wr+6lFwGOL0zEYZyfvpyoFwfAlkjAUbf27FzX
 BDIL+hi9aVr+ZDooqcs0XUjGe1/1B+8SaNqMexqDUjxGDN4OfZhdQKD6uTjabc07
 aiZqKH1ZWViQlNgMcqpXecXS+r+Qc+R6Qga/iwJuhhPKp3VhUEtuDaHajPiTx17q
 157CedcXxXKPRnNC/IneU0lOageknCLpRpIHZi3pYgcyfX1evE8CgF0aLZsN8tTv
 cdFJh7S89CknvK1sL18pcbV5/mtpDH/0DIWGg4d98O9X8Y/vluYEqSf6kPrjg6lR
 aVHU4/E8p8Y=
 =c+28
 -----END PGP SIGNATURE-----

Merge tag 'for-upstream' of https://repo.or.cz/qemu/kevin into staging

Block layer patches

- Event throttling for BLOCK_IO_ERROR
- iotests: Fix backup-discard-source test for XFS
- Coverity fixes
- raw-format: Fix error message for invalid offset/size

# -----BEGIN PGP SIGNATURE-----
#
# iQJFBAABCAAvFiEE3D3rFZqa+V09dFb+fwmycsiPL9YFAmcX1wQRHGt3b2xmQHJl
# ZGhhdC5jb20ACgkQfwmycsiPL9aWKA//cyG+Q3EXLouSu2Ob04RArX8HgAzLmHL3
# Fx9x6BbDtusPfzxKVLqhJhJ5/oRyk0QWkdZKGNSxinLD3DBJ6q6FMNaWhuvzOBcy
# iHnWlMfwEIBl5vFJwM5Q/d7F2afOUiVSeR7E4TQn063cBo96qIrAD7DRLM01jBEN
# d9+9nkBruwgmxZJIr3WTsqjDoTqflcjxA6Adp/WkzVXBMMYqcsuReXQtrgfFooKw
# yhjkHq5nFKzebvK+BLjA0ytuvUlsRqLYDXN+bAk/rC6oCgbzygAjNwL5kUEYnV1r
# lVRSOxRUlet4v2GFCvplxw5tX3aJzlWB50v7d+oaBYR72htTtPeIZzadBJySdtSk
# DxEUR5kTcGK/vSI+WOapTVK+qU+Wr+6lFwGOL0zEYZyfvpyoFwfAlkjAUbf27FzX
# BDIL+hi9aVr+ZDooqcs0XUjGe1/1B+8SaNqMexqDUjxGDN4OfZhdQKD6uTjabc07
# aiZqKH1ZWViQlNgMcqpXecXS+r+Qc+R6Qga/iwJuhhPKp3VhUEtuDaHajPiTx17q
# 157CedcXxXKPRnNC/IneU0lOageknCLpRpIHZi3pYgcyfX1evE8CgF0aLZsN8tTv
# cdFJh7S89CknvK1sL18pcbV5/mtpDH/0DIWGg4d98O9X8Y/vluYEqSf6kPrjg6lR
# aVHU4/E8p8Y=
# =c+28
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 22 Oct 2024 17:47:00 BST
# gpg:                using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6
# gpg:                issuer "kwolf@redhat.com"
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full]
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* tag 'for-upstream' of https://repo.or.cz/qemu/kevin:
  raw-format: Fix error message for invalid offset/size
  block-backend: per-device throttling of BLOCK_IO_ERROR reports
  qapi: add qom-path to BLOCK_IO_ERROR event
  iotests/backup-discard-source: don't use actual-size
  iotests/backup-discard-source: convert size variable to be int
  block/vdi.c: Make SECTOR_SIZE constant 64-bits
  tests/qemu-iotests/211.out: Update to expect MapEntry 'compressed' field
  block/ssh.c: Don't double-check that characters are hex digits
  block/gluster: Use g_autofree for string in qemu_gluster_parse_json()

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2024-10-24 11:23:46 +01:00
commit e67b7aef7c
9 changed files with 70 additions and 39 deletions

View file

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

View file

@ -28,20 +28,14 @@ from iotests import qemu_img_create, qemu_img_map, qemu_io
temp_img = os.path.join(iotests.test_dir, 'temp')
source_img = os.path.join(iotests.test_dir, 'source')
target_img = os.path.join(iotests.test_dir, 'target')
size = '1M'
def get_actual_size(vm, node_name):
nodes = vm.cmd('query-named-block-nodes', flat=True)
node = next(n for n in nodes if n['node-name'] == node_name)
return node['image']['actual-size']
size = 1024 * 1024
class TestBackup(iotests.QMPTestCase):
def setUp(self):
qemu_img_create('-f', iotests.imgfmt, source_img, size)
qemu_img_create('-f', iotests.imgfmt, temp_img, size)
qemu_img_create('-f', iotests.imgfmt, target_img, size)
qemu_img_create('-f', iotests.imgfmt, source_img, str(size))
qemu_img_create('-f', iotests.imgfmt, temp_img, str(size))
qemu_img_create('-f', iotests.imgfmt, target_img, str(size))
qemu_io('-c', 'write 0 1M', source_img)
self.vm = iotests.VM()
@ -84,7 +78,12 @@ class TestBackup(iotests.QMPTestCase):
}
})
self.assertLess(get_actual_size(self.vm, 'temp'), 512 * 1024)
self.bitmap = {
'node': 'temp',
'name': 'bitmap0'
}
self.vm.cmd('block-dirty-bitmap-add', self.bitmap)
def tearDown(self):
# That should fail, because region is discarded
@ -98,7 +97,7 @@ class TestBackup(iotests.QMPTestCase):
mapping = qemu_img_map(temp_img)
self.assertEqual(len(mapping), 1)
self.assertEqual(mapping[0]['start'], 0)
self.assertEqual(mapping[0]['length'], 1024 * 1024)
self.assertEqual(mapping[0]['length'], size)
self.assertEqual(mapping[0]['data'], False)
os.remove(temp_img)
@ -113,6 +112,13 @@ class TestBackup(iotests.QMPTestCase):
self.vm.event_wait(name='BLOCK_JOB_COMPLETED')
def get_bitmap_count(self):
nodes = self.vm.cmd('query-named-block-nodes', flat=True)
temp = next(n for n in nodes if n['node-name'] == 'temp')
bitmap = temp['dirty-bitmaps'][0]
assert bitmap['name'] == self.bitmap['name']
return bitmap['count']
def test_discard_written(self):
"""
1. Guest writes
@ -125,7 +131,7 @@ class TestBackup(iotests.QMPTestCase):
self.assert_qmp(result, 'return', '')
# Check that data is written to temporary image
self.assertGreater(get_actual_size(self.vm, 'temp'), 1024 * 1024)
self.assertEqual(self.get_bitmap_count(), size)
self.do_backup()
@ -138,13 +144,18 @@ class TestBackup(iotests.QMPTestCase):
"""
self.do_backup()
# backup job did discard operation and pollute the bitmap,
# we have to clean the bitmap, to check next write
self.assertEqual(self.get_bitmap_count(), size)
self.vm.cmd('block-dirty-bitmap-clear', self.bitmap)
# Try trigger copy-before-write operation
result = self.vm.hmp_qemu_io('cbw', 'write 0 1M')
self.assert_qmp(result, 'return', '')
# Check that data is not written to temporary image, as region
# is discarded from copy-before-write process
self.assertLess(get_actual_size(self.vm, 'temp'), 512 * 1024)
self.assertEqual(self.get_bitmap_count(), 0)
if __name__ == '__main__':