0
openstack:~/qemu-6.0.0-rc1/build$ qemu-img --version
qemu-img version 2.5.0 (Debian 1:2.5+dfsg-5ubuntu10.51), Copyright (c) 2004-2008 Fabrice Bellard
openstack:~/qemu-6.0.0-rc1/build$ sudo qemu-img check /mnt/esxi/name.vmdk
No errors were found on the image.

openstack:~/qemu-6.0.0-rc1/build$ ./qemu-img -V
qemu-img version 5.2.91
Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers
openstack:~/qemu-6.0.0-rc1/build$ sudo ./qemu-img check /mnt/esxi/name.vmdk
qemu-img: Could not open '/mnt/esxi/name.vmdk': Failed to lock byte 100: Input/output error

As the command output, the qemu-img 5.2.91 can't check the vmdk file, but qemu-img 2.5 works fine.

qemu-img 5.2.91 --help get this:

Supported formats: blkdebug blklogwrites blkverify bochs cloop compress copy-on-read dmg file host_cdrom host_device luks nbd null-aio null-co nvme preallocate qcow qcow2 qed quorum raw rbd replication throttle vdi vhdx vmdk vpc vvfat

How can I fix it? THX

enter image description here

Victor Lee
  • 2,467
  • 3
  • 19
  • 37
  • I don't have a solid answer for you, but it might help to know if the vmdk file is currently in use by a VM, since the error indicates a failure to lock it. And if it IS in use, kill the VM first and try again? – Aiken Drum Apr 22 '21 at 22:12
  • The VM is shutoff, and why the old version(2.5) qemu-img check it was OK but the 5.2.91 version check it can not open? – Victor Lee Apr 23 '21 at 01:30
  • 1
    I'm just guessing that the locking protocol was either different, or absent, in the old version – Aiken Drum Apr 23 '21 at 01:39
  • Are there any files in the same folder, or elsewhere, that have similar filenames to the vmdk, but with "lock" appended? Something like that? Perhaps a previous VM session left a stale lock file. – Aiken Drum Apr 23 '21 at 01:39
  • Maybe it not about the stale lock file.Check the picture I update the question. – Victor Lee Apr 23 '21 at 01:53
  • The qemu-img 5.2.91 version compile from source code with the configure `./configure --enable-rbd --python=/usr/local/bin/python3.6`, is there I miss some `configure` parameter? – Victor Lee Apr 23 '21 at 02:06
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/231487/discussion-between-victorlee-and-aiken-drum). – Victor Lee Apr 23 '21 at 02:09

1 Answers1

0

Because the vmdk file in NFS directory, add this option -o nolock fixed it.

nolock — Disables file locking. This setting is occasionally required when connecting to older NFS servers. noexec — Prevents execution of binaries on mounted file systems. This is useful if the system is mounting a non-Linux file system via NFS containing incompatible binaries.

Victor Lee
  • 2,467
  • 3
  • 19
  • 37