提交 ae50b71d 编写于 作者: D Daniel P. Berrange 提交者: Max Reitz

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: NMax Reitz <mreitz@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
Message-id: 20170626123510.20134-6-berrange@redhat.com
Signed-off-by: NMax Reitz <mreitz@redhat.com>
上级 a488e71e
......@@ -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")
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册