* [PATCH] iotests/108: probe loop device setup
@ 2026-10-13 18:28 Ilya Leoshkevich
2026-10-13 18:53 ` Eric Blake
2026-10-30 11:09 ` Kevin Wolf
0 siblings, 2 replies; 5+ messages in thread
From: Ilya Leoshkevich @ 2026-10-13 18:28 UTC (permalink / raw)
To: Kevin Wolf, Hanna Reitz; +Cc: qemu-block, qemu-devel, Ilya Leoshkevich
Running iotests/108 in a Docker container, that has passwordless sudo
configured, fails with:
losetup: /home/user/src/qemu/build/scratch/qcow2-file-108/t.qcow2: failed to set up loop device: No such file or directory
because it incorrectly assumes losetup is allowed to do loop device
setup, when in reality it can only list devices.
Fix by probing loop device setup, using the test script as a backing
file. With this, the test is correctly skipped.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
tests/qemu-iotests/108 | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/qemu-iotests/108 b/tests/qemu-iotests/108
index 1de718188aa..adbaaf87095 100755
--- a/tests/qemu-iotests/108
+++ b/tests/qemu-iotests/108
@@ -53,7 +53,8 @@ _supported_os Linux
_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file
# This test either needs sudo -n losetup or FUSE exports to work
-if sudo -n losetup &>/dev/null; then
+if probe_dev=$(sudo -n losetup -r --show -f "$0" 2>/dev/null); then
+ sudo -n losetup -d "$probe_dev"
loopdev=true
else
loopdev=false
--
2.56.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] iotests/108: probe loop device setup
2026-10-13 18:28 [PATCH] iotests/108: probe loop device setup Ilya Leoshkevich
@ 2026-10-13 18:53 ` Eric Blake
2026-10-13 19:08 ` Ilya Leoshkevich
2026-10-30 11:09 ` Kevin Wolf
1 sibling, 1 reply; 5+ messages in thread
From: Eric Blake @ 2026-10-13 18:53 UTC (permalink / raw)
To: Ilya Leoshkevich; +Cc: Kevin Wolf, Hanna Reitz, qemu-block, qemu-devel
On Tue, Oct 13, 2026 at 08:28:00PM +0200, Ilya Leoshkevich wrote:
> Running iotests/108 in a Docker container, that has passwordless sudo
> configured, fails with:
>
> losetup: /home/user/src/qemu/build/scratch/qcow2-file-108/t.qcow2: failed to set up loop device: No such file or directory
>
> because it incorrectly assumes losetup is allowed to do loop device
> setup, when in reality it can only list devices.
>
> Fix by probing loop device setup, using the test script as a backing
> file. With this, the test is correctly skipped.
>
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
> tests/qemu-iotests/108 | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tests/qemu-iotests/108 b/tests/qemu-iotests/108
> index 1de718188aa..adbaaf87095 100755
> --- a/tests/qemu-iotests/108
> +++ b/tests/qemu-iotests/108
> @@ -53,7 +53,8 @@ _supported_os Linux
> _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file
>
> # This test either needs sudo -n losetup or FUSE exports to work
> -if sudo -n losetup &>/dev/null; then
> +if probe_dev=$(sudo -n losetup -r --show -f "$0" 2>/dev/null); then
> + sudo -n losetup -d "$probe_dev"
Is 'sudo -n losetup -f' a simpler test? It prints out the next
/dev/loopN value available only if a mount would succeed, which means
that it is a stronger test than the existing 'sudo -n losetup', but
also does not require a subsequent cleanup.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization: qemu.org | libguestfs.org
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iotests/108: probe loop device setup
2026-10-13 18:53 ` Eric Blake
@ 2026-10-13 19:08 ` Ilya Leoshkevich
2026-10-13 19:14 ` Eric Blake
0 siblings, 1 reply; 5+ messages in thread
From: Ilya Leoshkevich @ 2026-10-13 19:08 UTC (permalink / raw)
To: Eric Blake; +Cc: Kevin Wolf, Hanna Reitz, qemu-block, qemu-devel
On 10/13/26 20:53, Eric Blake wrote:
> On Tue, Oct 13, 2026 at 08:28:00PM +0200, Ilya Leoshkevich wrote:
>> Running iotests/108 in a Docker container, that has passwordless sudo
>> configured, fails with:
>>
>> losetup: /home/user/src/qemu/build/scratch/qcow2-file-108/t.qcow2: failed to set up loop device: No such file or directory
>>
>> because it incorrectly assumes losetup is allowed to do loop device
>> setup, when in reality it can only list devices.
>>
>> Fix by probing loop device setup, using the test script as a backing
>> file. With this, the test is correctly skipped.
>>
>> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
>> ---
>> tests/qemu-iotests/108 | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/tests/qemu-iotests/108 b/tests/qemu-iotests/108
>> index 1de718188aa..adbaaf87095 100755
>> --- a/tests/qemu-iotests/108
>> +++ b/tests/qemu-iotests/108
>> @@ -53,7 +53,8 @@ _supported_os Linux
>> _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file
>>
>> # This test either needs sudo -n losetup or FUSE exports to work
>> -if sudo -n losetup &>/dev/null; then
>> +if probe_dev=$(sudo -n losetup -r --show -f "$0" 2>/dev/null); then
>> + sudo -n losetup -d "$probe_dev"
>
> Is 'sudo -n losetup -f' a simpler test? It prints out the next
> /dev/loopN value available only if a mount would succeed, which means
> that it is a stronger test than the existing 'sudo -n losetup', but
> also does not require a subsequent cleanup.
I don't think 'losetup -f' attempts a mount, since it works fine without
privileges:
$ id -u
1000
$ losetup -f
/dev/loop0
$ losetup -r -f /bin/true
losetup: /bin/true: failed to set up loop device: Permission denied
A quick glance at the source code [1] seems to confirm this: the
iterator is immediately discarded after finding a free device name.
The loop-control logic above looks similar.
[1]
https://github.com/util-linux/util-linux/blob/v2.42.4/lib/loopdev.c#L1760
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iotests/108: probe loop device setup
2026-10-13 19:08 ` Ilya Leoshkevich
@ 2026-10-13 19:14 ` Eric Blake
0 siblings, 0 replies; 5+ messages in thread
From: Eric Blake @ 2026-10-13 19:14 UTC (permalink / raw)
To: Ilya Leoshkevich; +Cc: Kevin Wolf, Hanna Reitz, qemu-block, qemu-devel
On Tue, Oct 13, 2026 at 09:08:17PM +0200, Ilya Leoshkevich wrote:
>
>
> On 10/13/26 20:53, Eric Blake wrote:
> > On Tue, Oct 13, 2026 at 08:28:00PM +0200, Ilya Leoshkevich wrote:
> > > Running iotests/108 in a Docker container, that has passwordless sudo
> > > configured, fails with:
> > >
> > > losetup: /home/user/src/qemu/build/scratch/qcow2-file-108/t.qcow2: failed to set up loop device: No such file or directory
> > >
> > > because it incorrectly assumes losetup is allowed to do loop device
> > > setup, when in reality it can only list devices.
> > >
> > > Fix by probing loop device setup, using the test script as a backing
> > > file. With this, the test is correctly skipped.
> > >
> > > Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> > > ---
> > > tests/qemu-iotests/108 | 3 ++-
> > > 1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/tests/qemu-iotests/108 b/tests/qemu-iotests/108
> > > index 1de718188aa..adbaaf87095 100755
> > > --- a/tests/qemu-iotests/108
> > > +++ b/tests/qemu-iotests/108
> > > @@ -53,7 +53,8 @@ _supported_os Linux
> > > _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file
> > > # This test either needs sudo -n losetup or FUSE exports to work
> > > -if sudo -n losetup &>/dev/null; then
> > > +if probe_dev=$(sudo -n losetup -r --show -f "$0" 2>/dev/null); then
> > > + sudo -n losetup -d "$probe_dev"
> >
> > Is 'sudo -n losetup -f' a simpler test? It prints out the next
> > /dev/loopN value available only if a mount would succeed, which means
> > that it is a stronger test than the existing 'sudo -n losetup', but
> > also does not require a subsequent cleanup.
>
> I don't think 'losetup -f' attempts a mount, since it works fine without
> privileges:
>
> $ id -u
> 1000
> $ losetup -f
> /dev/loop0
> $ losetup -r -f /bin/true
> losetup: /bin/true: failed to set up loop device: Permission denied
Thanks for testing. In that case, I think your longer version is reasonable.
Reviewed-by: Eric Blake <eblake@redhat.com>
>
> A quick glance at the source code [1] seems to confirm this: the
> iterator is immediately discarded after finding a free device name.
> The loop-control logic above looks similar.
>
> [1]
> https://github.com/util-linux/util-linux/blob/v2.42.4/lib/loopdev.c#L1760
>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization: qemu.org | libguestfs.org
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iotests/108: probe loop device setup
2026-10-13 18:28 [PATCH] iotests/108: probe loop device setup Ilya Leoshkevich
2026-10-13 18:53 ` Eric Blake
@ 2026-10-30 11:09 ` Kevin Wolf
1 sibling, 0 replies; 5+ messages in thread
From: Kevin Wolf @ 2026-10-30 11:09 UTC (permalink / raw)
To: Ilya Leoshkevich; +Cc: Hanna Reitz, qemu-block, qemu-devel
Am 13.10.2026 um 20:28 hat Ilya Leoshkevich geschrieben:
> Running iotests/108 in a Docker container, that has passwordless sudo
> configured, fails with:
>
> losetup: /home/user/src/qemu/build/scratch/qcow2-file-108/t.qcow2: failed to set up loop device: No such file or directory
>
> because it incorrectly assumes losetup is allowed to do loop device
> setup, when in reality it can only list devices.
>
> Fix by probing loop device setup, using the test script as a backing
> file. With this, the test is correctly skipped.
>
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Won't loop-create-file and fuse-truncate need the same fix?
Maybe we could have a _require_losetup() helper function in common.rc
for the shell-based tests? (Only two at the moment, though I also have a
patch on the list that would add a third one.)
Kevin
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-30 11:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-13 18:28 [PATCH] iotests/108: probe loop device setup Ilya Leoshkevich
2026-10-13 18:53 ` Eric Blake
2026-10-13 19:08 ` Ilya Leoshkevich
2026-10-13 19:14 ` Eric Blake
2026-10-30 11:09 ` Kevin Wolf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.