A disk image or database file that reads slowly on a spinning disk might be in thousands of pieces. You can check a single file in a second.
filefrag /var/lib/libvirt/images/vm1.qcow2
The answer is a count of extents, where an extent is one continuous run of blocks. One or a few is perfect. For the details, add -v:
sudo filefrag -v /var/lib/libvirt/images/vm1.qcow2
That lists each extent with its position and length. To find the worst files in a folder:
sudo find /srv/images -type f -size +100M -exec filefrag {} + | sort -t: -k2 -rn | head
I would look at this before spending time on defragmenting anything, since on ext4 the answer is often that there is nothing to fix.
A high number is not automatically bad. On an SSD it hardly matters, and a very large file needs many extents because each one has a maximum length. Copy on write filesystems like btrfs fragment files that are rewritten in place, such as VM images, and compressed files there report many small extents that look worse than they are. The tool needs support from the filesystem, so on some network or FUSE mounts it just returns an error.
Further reading: filefrag man page