I'm running Apache on a VM with a qcow2
disk. Apache runs a (compiled C++) program which does the following:
It calls
system
to run another (C++) program which creates a fileIt then attempts to read and process that file
Step (2) attempts to open the new file with ifstream::open
. When I run this program on the VM, this fails (ifstream::good
returns false
), with errno
saying that the file doesn't exist. However, the file does actually exist if I open a shell and look for it.
This program works fine when it's not on qcow2
(on 3 different RedHat and Ubuntu computers), which I'm guessing is implicated. I can fix this in two ways:
- If I add another step between (1) and (2), and call
system("ls /foo/bar/myfile")
thels
command fails, returning 2. I can call it 100 times and it still fails. However, step (2) will now succeed - If I run
system("sync")
instead ofsystem("ls")
, step (2) succeeds
Any idea what's going on? Does qcow2
have some unusual flush requirements?
Edit - added some sys info:
- RHEL 8.5, up-to-date
- kernel 4.18.0-348.12.2.el8_5.x86_64
- emulating pc-q35-rhel8.2.0
- VM has 4GiB RAM, 2vCPUs (Skylake-Client-IBRS)
- disk: 10GB, 35% used, virtio, default cache, Ubuntu 20.04 image
I've run this setup for years with Win 7 and Linux images and never seen an issue before.
$ virsh version
Compiled against library: libvirt 6.0.0
Using library: libvirt 6.0.0
Using API: QEMU 6.0.0
Running hypervisor: QEMU 4.2.0