# Reopen an image several times changing some of its options
def test_reopen(self):
+ # Check whether the filesystem supports O_DIRECT
+ if 'O_DIRECT' in qemu_io('-f', 'raw', '-t', 'none', '-c', 'quit', hd_path[0]):
+ supports_direct = False
+ else:
+ supports_direct = True
+
# Open the hd1 image passing all backing options
opts = hd_opts(1)
opts['backing'] = hd_opts(0)
self.assert_qmp(self.get_node('hd1'), 'cache/writeback', True)
self.assert_qmp(self.get_node('hd1'), 'cache/direct', False)
self.assert_qmp(self.get_node('hd1'), 'cache/no-flush', False)
- self.reopen(opts, {'cache': { 'direct': True, 'no-flush': True }})
+ self.reopen(opts, {'cache': { 'direct': supports_direct, 'no-flush': True }})
self.assert_qmp(self.get_node('hd1'), 'cache/writeback', True)
- self.assert_qmp(self.get_node('hd1'), 'cache/direct', True)
+ self.assert_qmp(self.get_node('hd1'), 'cache/direct', supports_direct)
self.assert_qmp(self.get_node('hd1'), 'cache/no-flush', True)
# Reopen again with the original options
# hd2 <- hd0
result = self.vm.qmp('block-stream', conv_keys = True, job_id = 'stream0',
- device = 'hd0', base_node = 'hd2', speed = 512 * 1024)
+ device = 'hd0', base_node = 'hd2',
+ auto_finalize = False)
self.assert_qmp(result, 'return', {})
- # We can't remove hd2 while the stream job is ongoing
+ # We can remove hd2 while the stream job is ongoing
opts['backing']['backing'] = None
- self.reopen(opts, {}, "Cannot change 'backing' link from 'hd1' to 'hd2'")
+ self.reopen(opts, {})
# We can't remove hd1 while the stream job is ongoing
opts['backing'] = None
self.reopen(opts, {}, "Cannot change 'backing' link from 'hd0' to 'hd1'")
- self.wait_until_completed(drive = 'stream0')
+ self.vm.run_job('stream0', auto_finalize = False, auto_dismiss = True)
# Reopen the chain during a block-stream job (from hd2 to hd1)
def test_block_stream_4(self):
# hd1 <- hd0
result = self.vm.qmp('block-stream', conv_keys = True, job_id = 'stream0',
- device = 'hd1', speed = 512 * 1024)
+ device = 'hd1', auto_finalize = False)
self.assert_qmp(result, 'return', {})
# We can't reopen with the original options because that would
# make hd1 read-only and block-stream requires it to be read-write
- self.reopen(opts, {}, "Can't set node 'hd1' to r/o with copy-on-read enabled")
+ # (Which error message appears depends on whether the stream job is
+ # already done with copying at this point.)
+ self.reopen(opts, {},
+ ["Can't set node 'hd1' to r/o with copy-on-read enabled",
+ "Cannot make block node read-only, there is a writer on it"])
# We can't remove hd2 while the stream job is ongoing
opts['backing']['backing'] = None
opts['backing'] = None
self.reopen(opts)
- self.wait_until_completed(drive = 'stream0')
+ self.vm.run_job('stream0', auto_finalize = False, auto_dismiss = True)
# Reopen the chain during a block-commit job (from hd0 to hd2)
def test_block_commit_1(self):
self.assert_qmp(result, 'return', {})
result = self.vm.qmp('block-commit', conv_keys = True, job_id = 'commit0',
- device = 'hd0', speed = 1024 * 1024)
+ device = 'hd0')
self.assert_qmp(result, 'return', {})
# We can't remove hd2 while the commit job is ongoing
self.assert_qmp(result, 'return', {})
result = self.vm.qmp('block-commit', conv_keys = True, job_id = 'commit0',
- device = 'hd0', top_node = 'hd1', speed = 1024 * 1024)
+ device = 'hd0', top_node = 'hd1',
+ auto_finalize = False)
self.assert_qmp(result, 'return', {})
# We can't remove hd2 while the commit job is ongoing
self.reopen(opts, {}, "Cannot change backing link if 'hd0' has an implicit backing file")
# hd2 <- hd0
- self.wait_until_completed(drive = 'commit0')
+ self.vm.run_job('commit0', auto_finalize = False, auto_dismiss = True)
self.assert_qmp(self.get_node('hd0'), 'ro', False)
self.assertEqual(self.get_node('hd1'), None)