All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Ilya Leoshkevich <iii@linux.ibm.com>
Cc: Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>,
	 qemu-block@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH] iotests/108: probe loop device setup
Date: Tue, 13 Oct 2026 14:14:55 -0500	[thread overview]
Message-ID: <as6CpVowfVzuYTMy@redhat.com> (raw)
In-Reply-To: <83590b67-3a00-4534-a4e8-9ccf335ddf31@linux.ibm.com>

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



      reply	other threads:[~2026-10-13 19:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=as6CpVowfVzuYTMy@redhat.com \
    --to=eblake@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=iii@linux.ibm.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.