qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Masayoshi Mizuma <msys.mizuma@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: locking option doesn't work as expected
Date: Wed, 4 Nov 2020 16:48:53 +0000	[thread overview]
Message-ID: <20201104164853.GM565323@redhat.com> (raw)
In-Reply-To: <20201104163556.ifevmhkj4bw6iuc2@gabell>

On Wed, Nov 04, 2020 at 11:35:56AM -0500, Masayoshi Mizuma wrote:
> Hello,
> 
> It seems that locking option doesn't work as expected.
> When I run qemu as following options, then I got an error and failed to
> boot the guest:
> 
>   qemu-system-x86_64 \
>     -machine pc \
>     -enable-kvm \
>     -cpu host \
>     -smp 1 -m 4G \
>     -nographic \
>     -serial telnet::1235,server,nowait \
>     -blockdev driver=qcow2,node-name=disk,file.driver=file,file.filename=/mnt/guest.qcow2,file.locking=auto \
>     -device virtio-blk-pci,scsi=off,drive=disk,id=virtio-disk0,bootindex=1
> 
>   qemu-system-x86_64: -blockdev driver=qcow2,node-name=disk,file.driver=file,file.filename=/mnt/guest.qcow2,file.locking=auto: Failed to lock byte 100
> 
> The error happens when the filesystem doesn't support OFD lock.
> qemu_probe_lock_ops() judges whether qemu can use OFD lock or not with doing
> fcntl(F_OFD_GETLK) to /dev/null, so the error happens if /dev/null supports OFD lock,
> but the filesystem doesn't support the lock.
> 
> I'm thinking how to fix the error. My idea is to add locking=posix option to use posix
> lock to the file, but I'm not sure the idea is good way to fix the error...
> 
> I would appreciate it if you could give me some advises to fix the error.

Ideally we would not attempt to probe it on /dev/null at all. Instead just
attempt to lock the actual file using F_OFD_SETLK and if that fails, then
falback to F_SETLK.  We can do similar when checking whether the lock
currently exists. AFAIK, the locking code isn't so performance critical
that the extra syscall would hurt us in the case where OFD doesn't exist
or isn't supported by the FS.

> 
> BTW, locking=off may be useful for the workaround so far, however, locking=off
> doesn't work on the splitting blockdev configs as followings...
> I split the blockdev option as libvirt doing.
> 
>    -blockdev driver=file,filename=/mnt/guest.qcow2,node-name=storage,auto-read-only=on,locking=off \
>    -blockdev node-name=format,read-only=off,driver=qcow2,file=storage \
> 
> Thanks,
> Masa
> 

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  reply	other threads:[~2020-11-04 16:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-04 16:35 locking option doesn't work as expected Masayoshi Mizuma
2020-11-04 16:48 ` Daniel P. Berrangé [this message]
2020-11-04 23:19   ` Masayoshi Mizuma

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=20201104164853.GM565323@redhat.com \
    --to=berrange@redhat.com \
    --cc=msys.mizuma@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).