This version incorporates many of the changes suggested by Laszlo and
Nir in their reviews (thanks).
We now require VDDK 6.5 because it turned out that 6.0 is broken.
There is a reliable way to detect VDDK 6.0 by the absence of
VixDiskLib_Wait, so we now give an accurate error message if someone
tries to use libvixDiskLib.so.6 and it's < 6.5.
Although the 5th patch is large, I didn't split it into two parts,
because that's hard work.
About checking the return value from pthread_mutex_init and
pthread_cond_init. I checked the implementation of these (in the only
implementation we really care about, glibc), and my reading is these
cannot realistically fail, especially if the attr parameter is NULL.
https://sourceware.org/git/?p=glibc.git;a=blob;f=nptl/pthread_mutex_init....
https://sourceware.org/git/?p=glibc.git;a=blob;f=nptl/pthread_cond_init.c...
cmd->error / cmd->completed have been combined into a single
cmd->status enum.
Laszlo raised a good point about abstraction (11c here:
https://listman.redhat.com/archives/libguestfs/2021-October/msg00218.html)
which I broadly agree with. I addressed it in a slightly different
way. I think there was likely a problem with the old code in that it
set cmd->error outside the mutex. I couldn't prove that this was
definitely wrong, but it seemed either unsafe or a source of future
problems. Instead the code now only updates the new cmd->status flag
while holding the lock, which in turn solves the abstraction problem
because there are now only a couple of places which update
cmd->status.
Rich.