Skip to contentSkip to conversation

qemu-iotests: Fix 128 if sudo required

PATCH Applied Fam Zheng 3 participants 3 messages May 19, 2015 – May 26, 2015

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH 1/1 qemu-iotests: Fix 128 if sudo required

If passwordless "sudo" works, use it in the qemu-io cmd.

---
 tests/qemu-iotests/128 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/qemu-iotests/128 +3 -1
index 249a865..e2a0f2f 100755
@@ -29,6 +29,7 @@ tmp=/tmp/$$
 status=1	# failure is the default!
 
 devname="eiodev$$"
+sudo=""
 
 _setup_eiodev()
 {
@@ -37,6 +38,7 @@ _setup_eiodev()
 		echo "0 $((1024 * 1024 * 1024 / 512)) error" | \
 			$cmd dmsetup create "$devname" 2>/dev/null
 		if [ "$?" -eq 0 ]; then
+			sudo="$cmd"
 			return
 		fi
 	done
@@ -74,7 +76,7 @@ TEST_IMG="/dev/mapper/$devname"
 echo
 echo "== reading from error device =="
 # Opening image should succeed but the read operation should fail
-$QEMU_IO --format "$IMGFMT" --nocache -c "read 0 65536" "$TEST_IMG" | _filter_qemu_io
+$sudo $QEMU_IO --format "$IMGFMT" --nocache -c "read 0 65536" "$TEST_IMG" | _filter_qemu_io
 
 # success, all done
 echo "*** done"
Signature · 1 line
2.4.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Fam Zheng

If passwordless "sudo" works, use it in the qemu-io cmd.

---
 tests/qemu-iotests/128 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Oops, I'm in the group 'disk' on my workstation so I never noticed that the user running the test may not have permission to access the block device.