aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/qemu-iotests/04040
-rw-r--r--tests/qemu-iotests/040.out4
-rwxr-xr-xtests/qemu-iotests/05110
-rw-r--r--tests/qemu-iotests/051.pc.out10
-rwxr-xr-xtests/qemu-iotests/0939
-rwxr-xr-xtests/qemu-iotests/1361
-rwxr-xr-xtests/qemu-iotests/18620
-rw-r--r--tests/qemu-iotests/186.out152
-rwxr-xr-xtests/qemu-iotests/21855
-rw-r--r--tests/qemu-iotests/218.out4
-rwxr-xr-xtests/qemu-iotests/2274
-rw-r--r--tests/qemu-iotests/227.out4
-rwxr-xr-xtests/qemu-iotests/2382
-rwxr-xr-xtests/qemu-iotests/2408
-rwxr-xr-xtests/qemu-iotests/2552
-rw-r--r--tests/test-bdrv-drain.c147
-rw-r--r--tests/test-block-iothread.c40
17 files changed, 383 insertions, 129 deletions
diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040
index b81133a..aa0b184 100755
--- a/tests/qemu-iotests/040
+++ b/tests/qemu-iotests/040
@@ -92,9 +92,10 @@ class TestSingleDrive(ImageCommitTestCase):
self.vm.add_device("scsi-hd,id=scsi0,drive=drive0")
self.vm.launch()
+ self.has_quit = False
def tearDown(self):
- self.vm.shutdown()
+ self.vm.shutdown(has_quit=self.has_quit)
os.remove(test_img)
os.remove(mid_img)
os.remove(backing_img)
@@ -109,6 +110,43 @@ class TestSingleDrive(ImageCommitTestCase):
self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img).find("verification failed"))
self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img).find("verification failed"))
+ def test_commit_with_filter_and_quit(self):
+ result = self.vm.qmp('object-add', qom_type='throttle-group', id='tg')
+ self.assert_qmp(result, 'return', {})
+
+ # Add a filter outside of the backing chain
+ result = self.vm.qmp('blockdev-add', driver='throttle', node_name='filter', throttle_group='tg', file='mid')
+ self.assert_qmp(result, 'return', {})
+
+ result = self.vm.qmp('block-commit', device='drive0')
+ self.assert_qmp(result, 'return', {})
+
+ # Quit immediately, thus forcing a simultaneous cancel of the
+ # block job and a bdrv_drain_all()
+ result = self.vm.qmp('quit')
+ self.assert_qmp(result, 'return', {})
+
+ self.has_quit = True
+
+ # Same as above, but this time we add the filter after starting the job
+ def test_commit_plus_filter_and_quit(self):
+ result = self.vm.qmp('object-add', qom_type='throttle-group', id='tg')
+ self.assert_qmp(result, 'return', {})
+
+ result = self.vm.qmp('block-commit', device='drive0')
+ self.assert_qmp(result, 'return', {})
+
+ # Add a filter outside of the backing chain
+ result = self.vm.qmp('blockdev-add', driver='throttle', node_name='filter', throttle_group='tg', file='mid')
+ self.assert_qmp(result, 'return', {})
+
+ # Quit immediately, thus forcing a simultaneous cancel of the
+ # block job and a bdrv_drain_all()
+ result = self.vm.qmp('quit')
+ self.assert_qmp(result, 'return', {})
+
+ self.has_quit = True
+
def test_device_not_found(self):
result = self.vm.qmp('block-commit', device='nonexistent', top='%s' % mid_img)
self.assert_qmp(result, 'error/class', 'DeviceNotFound')
diff --git a/tests/qemu-iotests/040.out b/tests/qemu-iotests/040.out
index 802ffaa..220a5fa 100644
--- a/tests/qemu-iotests/040.out
+++ b/tests/qemu-iotests/040.out
@@ -1,5 +1,5 @@
-...........................................
+...............................................
----------------------------------------------------------------------
-Ran 43 tests
+Ran 47 tests
OK
diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051
index 200660f..ce942a5 100755
--- a/tests/qemu-iotests/051
+++ b/tests/qemu-iotests/051
@@ -251,11 +251,11 @@ echo
# Cannot use the test image because cache=none might not work on the host FS
# Use cdrom so that we won't get errors about missing media
-run_qemu -drive driver=null-co,cache=none
-run_qemu -drive driver=null-co,cache=directsync
-run_qemu -drive driver=null-co,cache=writeback
-run_qemu -drive driver=null-co,cache=writethrough
-run_qemu -drive driver=null-co,cache=unsafe
+run_qemu -drive driver=null-co,read-zeroes=on,cache=none
+run_qemu -drive driver=null-co,read-zeroes=on,cache=directsync
+run_qemu -drive driver=null-co,read-zeroes=on,cache=writeback
+run_qemu -drive driver=null-co,read-zeroes=on,cache=writethrough
+run_qemu -drive driver=null-co,read-zeroes=on,cache=unsafe
run_qemu -drive driver=null-co,cache=invalid_value
# Can't test direct=on here because O_DIRECT might not be supported on this FS
diff --git a/tests/qemu-iotests/051.pc.out b/tests/qemu-iotests/051.pc.out
index 2d811c1..000557c 100644
--- a/tests/qemu-iotests/051.pc.out
+++ b/tests/qemu-iotests/051.pc.out
@@ -245,23 +245,23 @@ QEMU X.Y.Z monitor - type 'help' for more information
=== Cache modes ===
-Testing: -drive driver=null-co,cache=none
+Testing: -drive driver=null-co,read-zeroes=on,cache=none
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) quit
-Testing: -drive driver=null-co,cache=directsync
+Testing: -drive driver=null-co,read-zeroes=on,cache=directsync
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) quit
-Testing: -drive driver=null-co,cache=writeback
+Testing: -drive driver=null-co,read-zeroes=on,cache=writeback
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) quit
-Testing: -drive driver=null-co,cache=writethrough
+Testing: -drive driver=null-co,read-zeroes=on,cache=writethrough
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) quit
-Testing: -drive driver=null-co,cache=unsafe
+Testing: -drive driver=null-co,read-zeroes=on,cache=unsafe
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) quit
diff --git a/tests/qemu-iotests/093 b/tests/qemu-iotests/093
index d88fbc1..4b2cac1 100755
--- a/tests/qemu-iotests/093
+++ b/tests/qemu-iotests/093
@@ -38,7 +38,7 @@ class ThrottleTestCase(iotests.QMPTestCase):
def setUp(self):
self.vm = iotests.VM()
for i in range(0, self.max_drives):
- self.vm.add_drive(self.test_img)
+ self.vm.add_drive(self.test_img, "file.read-zeroes=on")
self.vm.launch()
def tearDown(self):
@@ -273,7 +273,8 @@ class ThrottleTestGroupNames(iotests.QMPTestCase):
def setUp(self):
self.vm = iotests.VM()
for i in range(0, self.max_drives):
- self.vm.add_drive(self.test_img, "throttling.iops-total=100")
+ self.vm.add_drive(self.test_img,
+ "throttling.iops-total=100,file.read-zeroes=on")
self.vm.launch()
def tearDown(self):
@@ -378,10 +379,10 @@ class ThrottleTestRemovableMedia(iotests.QMPTestCase):
def test_removable_media(self):
# Add a couple of dummy nodes named cd0 and cd1
result = self.vm.qmp("blockdev-add", driver="null-aio",
- node_name="cd0")
+ read_zeroes=True, node_name="cd0")
self.assert_qmp(result, 'return', {})
result = self.vm.qmp("blockdev-add", driver="null-aio",
- node_name="cd1")
+ read_zeroes=True, node_name="cd1")
self.assert_qmp(result, 'return', {})
# Attach a CD drive with cd0 inserted
diff --git a/tests/qemu-iotests/136 b/tests/qemu-iotests/136
index af7ffa4..a46a7b7 100755
--- a/tests/qemu-iotests/136
+++ b/tests/qemu-iotests/136
@@ -74,6 +74,7 @@ sector = "%d"
(self.account_invalid and "on" or "off"))
drive_args.append("stats-account-failed=%s" %
(self.account_failed and "on" or "off"))
+ drive_args.append("file.image.read-zeroes=on")
self.create_blkdebug_file()
self.vm = iotests.VM().add_drive('blkdebug:%s:%s' %
(blkdebug_file, self.test_img),
diff --git a/tests/qemu-iotests/186 b/tests/qemu-iotests/186
index 7e7d45b..5f6b18c 100755
--- a/tests/qemu-iotests/186
+++ b/tests/qemu-iotests/186
@@ -86,8 +86,8 @@ echo "=== -blockdev/-device=<node-name> ==="
echo
for dev in $fixed $removable; do
- check_info_block -blockdev driver=null-co,node-name=null -device $dev,drive=null
- check_info_block -blockdev driver=null-co,node-name=null -device $dev,drive=null,id=qdev_id
+ check_info_block -blockdev driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=null
+ check_info_block -blockdev driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=null,id=qdev_id
done
echo
@@ -97,7 +97,7 @@ echo
# This creates two BlockBackends that will show up in 'info block'!
# A monitor-owned one from -drive, and anonymous one from -device
for dev in $fixed $removable; do
- check_info_block -drive if=none,driver=null-co,node-name=null -device $dev,drive=null,id=qdev_id
+ check_info_block -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=null,id=qdev_id
done
echo
@@ -105,8 +105,8 @@ echo "=== -drive if=none/-device=<bb-name> (with medium) ==="
echo
for dev in $fixed $removable; do
- check_info_block -drive if=none,driver=null-co,node-name=null -device $dev,drive=none0
- check_info_block -drive if=none,driver=null-co,node-name=null -device $dev,drive=none0,id=qdev_id
+ check_info_block -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=none0
+ check_info_block -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=none0,id=qdev_id
done
echo
@@ -125,15 +125,15 @@ echo "=== -drive if=... ==="
echo
check_info_block -drive if=floppy
-check_info_block -drive if=floppy,driver=null-co
+check_info_block -drive if=floppy,driver=null-co,read-zeroes=on
-check_info_block -drive if=ide,driver=null-co
+check_info_block -drive if=ide,driver=null-co,read-zeroes=on
check_info_block -drive if=ide,media=cdrom
-check_info_block -drive if=ide,driver=null-co,media=cdrom
+check_info_block -drive if=ide,driver=null-co,read-zeroes=on,media=cdrom
-check_info_block -drive if=virtio,driver=null-co
+check_info_block -drive if=virtio,driver=null-co,read-zeroes=on
-check_info_block -drive if=pflash,driver=null-co,size=1M
+check_info_block -drive if=pflash,driver=null-co,read-zeroes=on,size=1M
# success, all done
echo "*** done"
diff --git a/tests/qemu-iotests/186.out b/tests/qemu-iotests/186.out
index 716b01a..5b35040 100644
--- a/tests/qemu-iotests/186.out
+++ b/tests/qemu-iotests/186.out
@@ -54,103 +54,103 @@ qdev_id: [not inserted]
=== -blockdev/-device=<node-name> ===
-Testing: -blockdev driver=null-co,node-name=null -device ide-hd,drive=null
+Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device ide-hd,drive=null
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-null: null-co:// (null-co)
+null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
Attached to: PATH
Cache mode: writeback
(qemu) quit
-Testing: -blockdev driver=null-co,node-name=null -device ide-hd,drive=null,id=qdev_id
+Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device ide-hd,drive=null,id=qdev_id
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-null: null-co:// (null-co)
+null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
Attached to: qdev_id
Cache mode: writeback
(qemu) quit
-Testing: -blockdev driver=null-co,node-name=null -device scsi-hd,drive=null
+Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device scsi-hd,drive=null
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-null: null-co:// (null-co)
+null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
Attached to: PATH
Cache mode: writeback
(qemu) quit
-Testing: -blockdev driver=null-co,node-name=null -device scsi-hd,drive=null,id=qdev_id
+Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device scsi-hd,drive=null,id=qdev_id
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-null: null-co:// (null-co)
+null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
Attached to: qdev_id
Cache mode: writeback
(qemu) quit
-Testing: -blockdev driver=null-co,node-name=null -device virtio-blk-pci,drive=null
+Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device virtio-blk-pci,drive=null
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-null: null-co:// (null-co)
+null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
Attached to: PATH
Cache mode: writeback
(qemu) quit
-Testing: -blockdev driver=null-co,node-name=null -device virtio-blk-pci,drive=null,id=qdev_id
+Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device virtio-blk-pci,drive=null,id=qdev_id
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-null: null-co:// (null-co)
+null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
Attached to: PATH
Cache mode: writeback
(qemu) quit
-Testing: -blockdev driver=null-co,node-name=null -device floppy,drive=null
+Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device floppy,drive=null
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-null: null-co:// (null-co)
+null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
Attached to: PATH
Removable device: not locked, tray closed
Cache mode: writeback
(qemu) quit
-Testing: -blockdev driver=null-co,node-name=null -device floppy,drive=null,id=qdev_id
+Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device floppy,drive=null,id=qdev_id
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-null: null-co:// (null-co)
+null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
Attached to: qdev_id
Removable device: not locked, tray closed
Cache mode: writeback
(qemu) quit
-Testing: -blockdev driver=null-co,node-name=null -device ide-cd,drive=null
+Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device ide-cd,drive=null
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-null: null-co:// (null-co)
+null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
Attached to: PATH
Removable device: not locked, tray closed
Cache mode: writeback
(qemu) quit
-Testing: -blockdev driver=null-co,node-name=null -device ide-cd,drive=null,id=qdev_id
+Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device ide-cd,drive=null,id=qdev_id
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-null: null-co:// (null-co)
+null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
Attached to: qdev_id
Removable device: not locked, tray closed
Cache mode: writeback
(qemu) quit
-Testing: -blockdev driver=null-co,node-name=null -device scsi-cd,drive=null
+Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device scsi-cd,drive=null
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-null: null-co:// (null-co)
+null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
Attached to: PATH
Removable device: not locked, tray closed
Cache mode: writeback
(qemu) quit
-Testing: -blockdev driver=null-co,node-name=null -device scsi-cd,drive=null,id=qdev_id
+Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device scsi-cd,drive=null,id=qdev_id
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-null: null-co:// (null-co)
+null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
Attached to: qdev_id
Removable device: not locked, tray closed
Cache mode: writeback
@@ -159,76 +159,76 @@ null: null-co:// (null-co)
=== -drive if=none/-device=<node-name> ===
-Testing: -drive if=none,driver=null-co,node-name=null -device ide-hd,drive=null,id=qdev_id
+Testing: -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device ide-hd,drive=null,id=qdev_id
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-none0 (null): null-co:// (null-co)
+none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Removable device: not locked, tray closed
Cache mode: writeback
-null: null-co:// (null-co)
+null: json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: qdev_id
Cache mode: writeback
(qemu) quit
-Testing: -drive if=none,driver=null-co,node-name=null -device scsi-hd,drive=null,id=qdev_id
+Testing: -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device scsi-hd,drive=null,id=qdev_id
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-none0 (null): null-co:// (null-co)
+none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Removable device: not locked, tray closed
Cache mode: writeback
-null: null-co:// (null-co)
+null: json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: qdev_id
Cache mode: writeback
(qemu) quit
-Testing: -drive if=none,driver=null-co,node-name=null -device virtio-blk-pci,drive=null,id=qdev_id
+Testing: -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device virtio-blk-pci,drive=null,id=qdev_id
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-none0 (null): null-co:// (null-co)
+none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Removable device: not locked, tray closed
Cache mode: writeback
-null: null-co:// (null-co)
+null: json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: PATH
Cache mode: writeback
(qemu) quit
-Testing: -drive if=none,driver=null-co,node-name=null -device floppy,drive=null,id=qdev_id
+Testing: -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device floppy,drive=null,id=qdev_id
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-none0 (null): null-co:// (null-co)
+none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Removable device: not locked, tray closed
Cache mode: writeback
-null: null-co:// (null-co)
+null: json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: qdev_id
Removable device: not locked, tray closed
Cache mode: writeback
(qemu) quit
-Testing: -drive if=none,driver=null-co,node-name=null -device ide-cd,drive=null,id=qdev_id
+Testing: -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device ide-cd,drive=null,id=qdev_id
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-none0 (null): null-co:// (null-co)
+none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Removable device: not locked, tray closed
Cache mode: writeback
-null: null-co:// (null-co)
+null: json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: qdev_id
Removable device: not locked, tray closed
Cache mode: writeback
(qemu) quit
-Testing: -drive if=none,driver=null-co,node-name=null -device scsi-cd,drive=null,id=qdev_id
+Testing: -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device scsi-cd,drive=null,id=qdev_id
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-none0 (null): null-co:// (null-co)
+none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Removable device: not locked, tray closed
Cache mode: writeback
-null: null-co:// (null-co)
+null: json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: qdev_id
Removable device: not locked, tray closed
Cache mode: writeback
@@ -237,103 +237,103 @@ null: null-co:// (null-co)
=== -drive if=none/-device=<bb-name> (with medium) ===
-Testing: -drive if=none,driver=null-co,node-name=null -device ide-hd,drive=none0
+Testing: -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device ide-hd,drive=none0
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-none0 (null): null-co:// (null-co)
+none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: PATH
Cache mode: writeback
(qemu) quit
-Testing: -drive if=none,driver=null-co,node-name=null -device ide-hd,drive=none0,id=qdev_id
+Testing: -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device ide-hd,drive=none0,id=qdev_id
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-none0 (null): null-co:// (null-co)
+none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: qdev_id
Cache mode: writeback
(qemu) quit
-Testing: -drive if=none,driver=null-co,node-name=null -device scsi-hd,drive=none0
+Testing: -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device scsi-hd,drive=none0
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-none0 (null): null-co:// (null-co)
+none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: PATH
Cache mode: writeback
(qemu) quit
-Testing: -drive if=none,driver=null-co,node-name=null -device scsi-hd,drive=none0,id=qdev_id
+Testing: -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device scsi-hd,drive=none0,id=qdev_id
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-none0 (null): null-co:// (null-co)
+none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: qdev_id
Cache mode: writeback
(qemu) quit
-Testing: -drive if=none,driver=null-co,node-name=null -device virtio-blk-pci,drive=none0
+Testing: -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device virtio-blk-pci,drive=none0
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-none0 (null): null-co:// (null-co)
+none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: PATH
Cache mode: writeback
(qemu) quit
-Testing: -drive if=none,driver=null-co,node-name=null -device virtio-blk-pci,drive=none0,id=qdev_id
+Testing: -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device virtio-blk-pci,drive=none0,id=qdev_id
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-none0 (null): null-co:// (null-co)
+none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: PATH
Cache mode: writeback
(qemu) quit
-Testing: -drive if=none,driver=null-co,node-name=null -device floppy,drive=none0
+Testing: -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device floppy,drive=none0
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-none0 (null): null-co:// (null-co)
+none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: PATH
Removable device: not locked, tray closed
Cache mode: writeback
(qemu) quit
-Testing: -drive if=none,driver=null-co,node-name=null -device floppy,drive=none0,id=qdev_id
+Testing: -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device floppy,drive=none0,id=qdev_id
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-none0 (null): null-co:// (null-co)
+none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: qdev_id
Removable device: not locked, tray closed
Cache mode: writeback
(qemu) quit
-Testing: -drive if=none,driver=null-co,node-name=null -device ide-cd,drive=none0
+Testing: -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device ide-cd,drive=none0
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-none0 (null): null-co:// (null-co)
+none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: PATH
Removable device: not locked, tray closed
Cache mode: writeback
(qemu) quit
-Testing: -drive if=none,driver=null-co,node-name=null -device ide-cd,drive=none0,id=qdev_id
+Testing: -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device ide-cd,drive=none0,id=qdev_id
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-none0 (null): null-co:// (null-co)
+none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: qdev_id
Removable device: not locked, tray closed
Cache mode: writeback
(qemu) quit
-Testing: -drive if=none,driver=null-co,node-name=null -device scsi-cd,drive=none0
+Testing: -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device scsi-cd,drive=none0
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-none0 (null): null-co:// (null-co)
+none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: PATH
Removable device: not locked, tray closed
Cache mode: writeback
(qemu) quit
-Testing: -drive if=none,driver=null-co,node-name=null -device scsi-cd,drive=none0,id=qdev_id
+Testing: -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device scsi-cd,drive=none0,id=qdev_id
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-none0 (null): null-co:// (null-co)
+none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: qdev_id
Removable device: not locked, tray closed
Cache mode: writeback
@@ -408,19 +408,19 @@ floppy0: [not inserted]
Removable device: not locked, tray closed
(qemu) quit
-Testing: -drive if=floppy,driver=null-co
+Testing: -drive if=floppy,driver=null-co,read-zeroes=on
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-floppy0 (NODE_NAME): null-co:// (null-co)
+floppy0 (NODE_NAME): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: PATH
Removable device: not locked, tray closed
Cache mode: writeback
(qemu) quit
-Testing: -drive if=ide,driver=null-co
+Testing: -drive if=ide,driver=null-co,read-zeroes=on
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-ide0-hd0 (NODE_NAME): null-co:// (null-co)
+ide0-hd0 (NODE_NAME): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: PATH
Cache mode: writeback
(qemu) quit
@@ -433,27 +433,27 @@ ide0-cd0: [not inserted]
Removable device: not locked, tray closed
(qemu) quit
-Testing: -drive if=ide,driver=null-co,media=cdrom
+Testing: -drive if=ide,driver=null-co,read-zeroes=on,media=cdrom
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-ide0-cd0 (NODE_NAME): null-co:// (null-co, read-only)
+ide0-cd0 (NODE_NAME): json:{"read-zeroes": "on", "driver": "null-co"} (null-co, read-only)
Attached to: PATH
Removable device: not locked, tray closed
Cache mode: writeback
(qemu) quit
-Testing: -drive if=virtio,driver=null-co
+Testing: -drive if=virtio,driver=null-co,read-zeroes=on
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-virtio0 (NODE_NAME): null-co:// (null-co)
+virtio0 (NODE_NAME): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
Attached to: PATH
Cache mode: writeback
(qemu) quit
-Testing: -drive if=pflash,driver=null-co,size=1M
+Testing: -drive if=pflash,driver=null-co,read-zeroes=on,size=1M
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) info block
-pflash0 (NODE_NAME): json:{"driver": "null-co", "size": "1M"} (null-co)
+pflash0 (NODE_NAME): json:{"read-zeroes": "on", "driver": "null-co", "size": "1M"} (null-co)
Attached to: PATH
Cache mode: writeback
(qemu) quit
diff --git a/tests/qemu-iotests/218 b/tests/qemu-iotests/218
index 92c331b..2554d84 100755
--- a/tests/qemu-iotests/218
+++ b/tests/qemu-iotests/218
@@ -27,9 +27,9 @@
# Creator/Owner: Max Reitz <mreitz@redhat.com>
import iotests
-from iotests import log
+from iotests import log, qemu_img, qemu_io_silent
-iotests.verify_platform(['linux'])
+iotests.verify_image_format(supported_fmts=['qcow2', 'raw'])
# Launches the VM, adds two null-co nodes (source and target), and
@@ -136,3 +136,54 @@ with iotests.VM() as vm:
log(vm.event_wait('BLOCK_JOB_CANCELLED'),
filters=[iotests.filter_qmp_event])
+
+log('')
+log('=== Cancel mirror job from throttled node by quitting ===')
+log('')
+
+with iotests.VM() as vm, \
+ iotests.FilePath('src.img') as src_img_path:
+
+ assert qemu_img('create', '-f', iotests.imgfmt, src_img_path, '64M') == 0
+ assert qemu_io_silent('-f', iotests.imgfmt, src_img_path,
+ '-c', 'write -P 42 0M 64M') == 0
+
+ vm.launch()
+
+ ret = vm.qmp('object-add', qom_type='throttle-group', id='tg',
+ props={'x-bps-read': 4096})
+ assert ret['return'] == {}
+
+ ret = vm.qmp('blockdev-add',
+ node_name='source',
+ driver=iotests.imgfmt,
+ file={
+ 'driver': 'file',
+ 'filename': src_img_path
+ })
+ assert ret['return'] == {}
+
+ ret = vm.qmp('blockdev-add',
+ node_name='throttled-source',
+ driver='throttle',
+ throttle_group='tg',
+ file='source')
+ assert ret['return'] == {}
+
+ ret = vm.qmp('blockdev-add',
+ node_name='target',
+ driver='null-co',
+ size=(64 * 1048576))
+ assert ret['return'] == {}
+
+ ret = vm.qmp('blockdev-mirror',
+ job_id='mirror',
+ device='throttled-source',
+ target='target',
+ sync='full')
+ assert ret['return'] == {}
+
+ log(vm.qmp('quit'))
+
+ with iotests.Timeout(5, 'Timeout waiting for VM to quit'):
+ vm.shutdown(has_quit=True)
diff --git a/tests/qemu-iotests/218.out b/tests/qemu-iotests/218.out
index 825a657..5a86a97 100644
--- a/tests/qemu-iotests/218.out
+++ b/tests/qemu-iotests/218.out
@@ -28,3 +28,7 @@ Cancelling job
Cancelling job
{"return": {}}
{"data": {"device": "mirror", "len": 1048576, "offset": 1048576, "speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_CANCELLED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
+
+=== Cancel mirror job from throttled node by quitting ===
+
+{"return": {}}
diff --git a/tests/qemu-iotests/227 b/tests/qemu-iotests/227
index bdd727a..637d7c3 100755
--- a/tests/qemu-iotests/227
+++ b/tests/qemu-iotests/227
@@ -57,7 +57,7 @@ echo
echo '=== blockstats with -drive if=virtio ==='
echo
-run_qemu -drive driver=null-co,if=virtio <<EOF
+run_qemu -drive driver=null-co,read-zeroes=on,if=virtio <<EOF
{ "execute": "qmp_capabilities" }
{ "execute": "query-blockstats"}
{ "execute": "quit" }
@@ -87,7 +87,7 @@ echo
echo '=== blockstats with -blockdev and -device ==='
echo
-run_qemu -blockdev driver=null-co,node-name=null -device virtio-blk,drive=null,id=virtio0 <<EOF
+run_qemu -blockdev driver=null-co,read-zeroes=on,node-name=null -device virtio-blk,drive=null,id=virtio0 <<EOF
{ "execute": "qmp_capabilities" }
{ "execute": "query-blockstats"}
{ "execute": "quit" }
diff --git a/tests/qemu-iotests/227.out b/tests/qemu-iotests/227.out
index e77efaf..3dd3ca5 100644
--- a/tests/qemu-iotests/227.out
+++ b/tests/qemu-iotests/227.out
@@ -2,7 +2,7 @@ QA output created by 227
=== blockstats with -drive if=virtio ===
-Testing: -drive driver=null-co,if=virtio
+Testing: -drive driver=null-co,read-zeroes=on,if=virtio
{
QMP_VERSION
}
@@ -150,7 +150,7 @@ Testing: -blockdev driver=null-co,node-name=null
=== blockstats with -blockdev and -device ===
-Testing: -blockdev driver=null-co,node-name=null -device virtio-blk,drive=null,id=virtio0
+Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device virtio-blk,drive=null,id=virtio0
{
QMP_VERSION
}
diff --git a/tests/qemu-iotests/238 b/tests/qemu-iotests/238
index 1c0a46f..08bc7e6 100755
--- a/tests/qemu-iotests/238
+++ b/tests/qemu-iotests/238
@@ -31,7 +31,7 @@ else:
vm = iotests.VM()
vm.launch()
-log(vm.qmp('blockdev-add', node_name='hd0', driver='null-co'))
+log(vm.qmp('blockdev-add', node_name='hd0', driver='null-co', read_zeroes=True))
log(vm.qmp('object-add', qom_type='iothread', id='iothread0'))
log(vm.qmp('device_add', id='scsi0', driver=virtio_scsi_device, iothread='iothread0'))
log(vm.qmp('device_add', id='scsi-hd0', driver='scsi-hd', drive='hd0'))
diff --git a/tests/qemu-iotests/240 b/tests/qemu-iotests/240
index 5be6b9c..f73bc07 100755
--- a/tests/qemu-iotests/240
+++ b/tests/qemu-iotests/240
@@ -76,7 +76,7 @@ echo
run_qemu <<EOF
{ "execute": "qmp_capabilities" }
-{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0"}}
+{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "read-zeroes": true, "node-name": "hd0"}}
{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
{ "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0"}}
@@ -94,7 +94,7 @@ echo
run_qemu <<EOF
{ "execute": "qmp_capabilities" }
-{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true}}
+{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "read-zeroes": true, "node-name": "hd0", "read-only": true}}
{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
{ "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0"}}
@@ -112,7 +112,7 @@ echo
run_qemu <<EOF
{ "execute": "qmp_capabilities" }
-{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true}}
+{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "read-zeroes": true, "node-name": "hd0", "read-only": true}}
{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread1"}}
{ "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
@@ -134,7 +134,7 @@ echo
run_qemu <<EOF
{ "execute": "qmp_capabilities" }
-{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true}}
+{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "read-zeroes": true, "node-name": "hd0", "read-only": true}}
{ "execute": "nbd-server-start", "arguments": {"addr":{"type":"unix","data":{"path":"$TEST_DIR/nbd"}}}}
{ "execute": "nbd-server-add", "arguments": {"device":"hd0"}}
{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
diff --git a/tests/qemu-iotests/255 b/tests/qemu-iotests/255
index 49433ec..3632d50 100755
--- a/tests/qemu-iotests/255
+++ b/tests/qemu-iotests/255
@@ -132,4 +132,4 @@ with iotests.FilePath('src.qcow2') as src_path, \
vm.qmp_log('block-job-cancel', device='job0')
vm.qmp_log('quit')
- vm.shutdown()
+ vm.shutdown(has_quit=True)
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
index 12e2ecf..03fa114 100644
--- a/tests/test-bdrv-drain.c
+++ b/tests/test-bdrv-drain.c
@@ -1527,6 +1527,150 @@ static void test_set_aio_context(void)
iothread_join(b);
}
+
+typedef struct TestDropBackingBlockJob {
+ BlockJob common;
+ bool should_complete;
+ bool *did_complete;
+ BlockDriverState *detach_also;
+} TestDropBackingBlockJob;
+
+static int coroutine_fn test_drop_backing_job_run(Job *job, Error **errp)
+{
+ TestDropBackingBlockJob *s =
+ container_of(job, TestDropBackingBlockJob, common.job);
+
+ while (!s->should_complete) {
+ job_sleep_ns(job, 0);
+ }
+
+ return 0;
+}
+
+static void test_drop_backing_job_commit(Job *job)
+{
+ TestDropBackingBlockJob *s =
+ container_of(job, TestDropBackingBlockJob, common.job);
+
+ bdrv_set_backing_hd(blk_bs(s->common.blk), NULL, &error_abort);
+ bdrv_set_backing_hd(s->detach_also, NULL, &error_abort);
+
+ *s->did_complete = true;
+}
+
+static const BlockJobDriver test_drop_backing_job_driver = {
+ .job_driver = {
+ .instance_size = sizeof(TestDropBackingBlockJob),
+ .free = block_job_free,
+ .user_resume = block_job_user_resume,
+ .drain = block_job_drain,
+ .run = test_drop_backing_job_run,
+ .commit = test_drop_backing_job_commit,
+ }
+};
+
+/**
+ * Creates a child node with three parent nodes on it, and then runs a
+ * block job on the final one, parent-node-2.
+ *
+ * The job is then asked to complete before a section where the child
+ * is drained.
+ *
+ * Ending this section will undrain the child's parents, first
+ * parent-node-2, then parent-node-1, then parent-node-0 -- the parent
+ * list is in reverse order of how they were added. Ending the drain
+ * on parent-node-2 will resume the job, thus completing it and
+ * scheduling job_exit().
+ *
+ * Ending the drain on parent-node-1 will poll the AioContext, which
+ * lets job_exit() and thus test_drop_backing_job_commit() run. That
+ * function first removes the child as parent-node-2's backing file.
+ *
+ * In old (and buggy) implementations, there are two problems with
+ * that:
+ * (A) bdrv_drain_invoke() polls for every node that leaves the
+ * drained section. This means that job_exit() is scheduled
+ * before the child has left the drained section. Its
+ * quiesce_counter is therefore still 1 when it is removed from
+ * parent-node-2.
+ *
+ * (B) bdrv_replace_child_noperm() calls drained_end() on the old
+ * child's parents as many times as the child is quiesced. This
+ * means it will call drained_end() on parent-node-2 once.
+ * Because parent-node-2 is no longer quiesced at this point, this
+ * will fail.
+ *
+ * bdrv_replace_child_noperm() therefore must call drained_end() on
+ * the parent only if it really is still drained because the child is
+ * drained.
+ *
+ * If removing child from parent-node-2 was successful (as it should
+ * be), test_drop_backing_job_commit() will then also remove the child
+ * from parent-node-0.
+ *
+ * With an old version of our drain infrastructure ((A) above), that
+ * resulted in the following flow:
+ *
+ * 1. child attempts to leave its drained section. The call recurses
+ * to its parents.
+ *
+ * 2. parent-node-2 leaves the drained section. Polling in
+ * bdrv_drain_invoke() will schedule job_exit().
+ *
+ * 3. parent-node-1 leaves the drained section. Polling in
+ * bdrv_drain_invoke() will run job_exit(), thus disconnecting
+ * parent-node-0 from the child node.
+ *
+ * 4. bdrv_parent_drained_end() uses a QLIST_FOREACH_SAFE() loop to
+ * iterate over the parents. Thus, it now accesses the BdrvChild
+ * object that used to connect parent-node-0 and the child node.
+ * However, that object no longer exists, so it accesses a dangling
+ * pointer.
+ *
+ * The solution is to only poll once when running a bdrv_drained_end()
+ * operation, specifically at the end when all drained_end()
+ * operations for all involved nodes have been scheduled.
+ * Note that this also solves (A) above, thus hiding (B).
+ */
+static void test_blockjob_commit_by_drained_end(void)
+{
+ BlockDriverState *bs_child, *bs_parents[3];
+ TestDropBackingBlockJob *job;
+ bool job_has_completed = false;
+ int i;
+
+ bs_child = bdrv_new_open_driver(&bdrv_test, "child-node", BDRV_O_RDWR,
+ &error_abort);
+
+ for (i = 0; i < 3; i++) {
+ char name[32];
+ snprintf(name, sizeof(name), "parent-node-%i", i);
+ bs_parents[i] = bdrv_new_open_driver(&bdrv_test, name, BDRV_O_RDWR,
+ &error_abort);
+ bdrv_set_backing_hd(bs_parents[i], bs_child, &error_abort);
+ }
+
+ job = block_job_create("job", &test_drop_backing_job_driver, NULL,
+ bs_parents[2], 0, BLK_PERM_ALL, 0, 0, NULL, NULL,
+ &error_abort);
+
+ job->detach_also = bs_parents[0];
+ job->did_complete = &job_has_completed;
+
+ job_start(&job->common.job);
+
+ job->should_complete = true;
+ bdrv_drained_begin(bs_child);
+ g_assert(!job_has_completed);
+ bdrv_drained_end(bs_child);
+ g_assert(job_has_completed);
+
+ bdrv_unref(bs_parents[0]);
+ bdrv_unref(bs_parents[1]);
+ bdrv_unref(bs_parents[2]);
+ bdrv_unref(bs_child);
+}
+
int main(int argc, char **argv)
{
int ret;
@@ -1610,6 +1754,9 @@ int main(int argc, char **argv)
g_test_add_func("/bdrv-drain/set_aio_context", test_set_aio_context);
+ g_test_add_func("/bdrv-drain/blockjob/commit_by_drained_end",
+ test_blockjob_commit_by_drained_end);
+
ret = g_test_run();
qemu_event_destroy(&done_event);
return ret;
diff --git a/tests/test-block-iothread.c b/tests/test-block-iothread.c
index 79d9cf8..1949d5e 100644
--- a/tests/test-block-iothread.c
+++ b/tests/test-block-iothread.c
@@ -348,8 +348,8 @@ static void test_sync_op(const void *opaque)
if (t->blkfn) {
t->blkfn(blk);
}
- aio_context_release(ctx);
blk_set_aio_context(blk, qemu_get_aio_context(), &error_abort);
+ aio_context_release(ctx);
bdrv_unref(bs);
blk_unref(blk);
@@ -476,6 +476,7 @@ static void test_propagate_basic(void)
{
IOThread *iothread = iothread_new();
AioContext *ctx = iothread_get_aio_context(iothread);
+ AioContext *main_ctx;
BlockBackend *blk;
BlockDriverState *bs_a, *bs_b, *bs_verify;
QDict *options;
@@ -504,12 +505,14 @@ static void test_propagate_basic(void)
g_assert(bdrv_get_aio_context(bs_b) == ctx);
/* Switch the AioContext back */
- ctx = qemu_get_aio_context();
- blk_set_aio_context(blk, ctx, &error_abort);
- g_assert(blk_get_aio_context(blk) == ctx);
- g_assert(bdrv_get_aio_context(bs_a) == ctx);
- g_assert(bdrv_get_aio_context(bs_verify) == ctx);
- g_assert(bdrv_get_aio_context(bs_b) == ctx);
+ main_ctx = qemu_get_aio_context();
+ aio_context_acquire(ctx);
+ blk_set_aio_context(blk, main_ctx, &error_abort);
+ aio_context_release(ctx);
+ g_assert(blk_get_aio_context(blk) == main_ctx);
+ g_assert(bdrv_get_aio_context(bs_a) == main_ctx);
+ g_assert(bdrv_get_aio_context(bs_verify) == main_ctx);
+ g_assert(bdrv_get_aio_context(bs_b) == main_ctx);
bdrv_unref(bs_verify);
bdrv_unref(bs_b);
@@ -534,6 +537,7 @@ static void test_propagate_diamond(void)
{
IOThread *iothread = iothread_new();
AioContext *ctx = iothread_get_aio_context(iothread);
+ AioContext *main_ctx;
BlockBackend *blk;
BlockDriverState *bs_a, *bs_b, *bs_c, *bs_verify;
QDict *options;
@@ -573,13 +577,15 @@ static void test_propagate_diamond(void)
g_assert(bdrv_get_aio_context(bs_c) == ctx);
/* Switch the AioContext back */
- ctx = qemu_get_aio_context();
- blk_set_aio_context(blk, ctx, &error_abort);
- g_assert(blk_get_aio_context(blk) == ctx);
- g_assert(bdrv_get_aio_context(bs_verify) == ctx);
- g_assert(bdrv_get_aio_context(bs_a) == ctx);
- g_assert(bdrv_get_aio_context(bs_b) == ctx);
- g_assert(bdrv_get_aio_context(bs_c) == ctx);
+ main_ctx = qemu_get_aio_context();
+ aio_context_acquire(ctx);
+ blk_set_aio_context(blk, main_ctx, &error_abort);
+ aio_context_release(ctx);
+ g_assert(blk_get_aio_context(blk) == main_ctx);
+ g_assert(bdrv_get_aio_context(bs_verify) == main_ctx);
+ g_assert(bdrv_get_aio_context(bs_a) == main_ctx);
+ g_assert(bdrv_get_aio_context(bs_b) == main_ctx);
+ g_assert(bdrv_get_aio_context(bs_c) == main_ctx);
blk_unref(blk);
bdrv_unref(bs_verify);
@@ -685,7 +691,9 @@ static void test_attach_second_node(void)
g_assert(bdrv_get_aio_context(bs) == ctx);
g_assert(bdrv_get_aio_context(filter) == ctx);
+ aio_context_acquire(ctx);
blk_set_aio_context(blk, main_ctx, &error_abort);
+ aio_context_release(ctx);
g_assert(blk_get_aio_context(blk) == main_ctx);
g_assert(bdrv_get_aio_context(bs) == main_ctx);
g_assert(bdrv_get_aio_context(filter) == main_ctx);
@@ -712,7 +720,9 @@ static void test_attach_preserve_blk_ctx(void)
g_assert(bdrv_get_aio_context(bs) == ctx);
/* Remove the node again */
+ aio_context_acquire(ctx);
blk_remove_bs(blk);
+ aio_context_release(ctx);
g_assert(blk_get_aio_context(blk) == ctx);
g_assert(bdrv_get_aio_context(bs) == qemu_get_aio_context());
@@ -721,7 +731,9 @@ static void test_attach_preserve_blk_ctx(void)
g_assert(blk_get_aio_context(blk) == ctx);
g_assert(bdrv_get_aio_context(bs) == ctx);
+ aio_context_acquire(ctx);
blk_set_aio_context(blk, qemu_get_aio_context(), &error_abort);
+ aio_context_release(ctx);
bdrv_unref(bs);
blk_unref(blk);
}