aboutsummaryrefslogtreecommitdiff
path: root/tests/qemu-iotests/149
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2017-06-26 13:35:10 +0100
committerMax Reitz <mreitz@redhat.com>2017-07-11 17:45:00 +0200
commitae50b71db01df0bb0b39694ab12354b80c9c95df (patch)
treed091b7433b2299068f7d34a60a4df2868233f827 /tests/qemu-iotests/149
parenta488e71e1e3d1568eb926f80e828e0d440af916b (diff)
iotests: chown LUKS device before qemu-io launches
On some distros, whenever you close a block device file descriptor there is a udev rule that resets the file permissions. This can race with the test script when we run qemu-io multiple times against the same block device. Occasionally the second qemu-io invocation will find udev has reset the permissions causing failure. Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-id: 20170626123510.20134-6-berrange@redhat.com Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/149')
-rwxr-xr-xtests/qemu-iotests/14912
1 files changed, 5 insertions, 7 deletions
diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149
index 5faf585461..223cd68ad5 100755
--- a/tests/qemu-iotests/149
+++ b/tests/qemu-iotests/149
@@ -186,7 +186,7 @@ def chown(config):
msg = proc.communicate()[0]
if proc.returncode != 0:
- raise Exception("Cannot change owner on %s" % path)
+ raise Exception(msg)
def cryptsetup_open(config):
@@ -271,6 +271,8 @@ def qemu_io_image_args(config, dev=False):
def qemu_io_write_pattern(config, pattern, offset_mb, size_mb, dev=False):
"""Write a pattern of data to a LUKS image or device"""
+ if dev:
+ chown(config)
args = ["-c", "write -P 0x%x %dM %dM" % (pattern, offset_mb, size_mb)]
args.extend(qemu_io_image_args(config, dev))
iotests.log("qemu-io " + " ".join(args), filters=[iotests.filter_test_dir])
@@ -281,6 +283,8 @@ def qemu_io_write_pattern(config, pattern, offset_mb, size_mb, dev=False):
def qemu_io_read_pattern(config, pattern, offset_mb, size_mb, dev=False):
"""Read a pattern of data to a LUKS image or device"""
+ if dev:
+ chown(config)
args = ["-c", "read -P 0x%x %dM %dM" % (pattern, offset_mb, size_mb)]
args.extend(qemu_io_image_args(config, dev))
iotests.log("qemu-io " + " ".join(args), filters=[iotests.filter_test_dir])
@@ -331,9 +335,6 @@ def test_once(config, qemu_img=False):
cryptsetup_open(config)
try:
- iotests.log("# Set dev owner")
- chown(config)
-
iotests.log("# Write test pattern 0xa7")
qemu_io_write_pattern(config, 0xa7, lowOffsetMB, 10, dev=True)
iotests.log("# Write test pattern 0x13")
@@ -365,9 +366,6 @@ def test_once(config, qemu_img=False):
cryptsetup_open(config)
try:
- iotests.log("# Set dev owner")
- chown(config)
-
iotests.log("# Read test pattern 0x91")
qemu_io_read_pattern(config, 0x91, lowOffsetMB, 10, dev=True)
iotests.log("# Read test pattern 0x5e")