On Wed, 19 Mar 2025 at 08:29, Gerd Hoffmann <kra...@redhat.com> wrote: > > Hi, > > > Hi; Coverity points out some problems in this code > > (CID 1593154, 1593157): > > I'll send fixes later today. > > > Do we absolutely need to be operating on a continuously open > > filedescriptor here rather than a filename? If we could make > > these functions use uv->jsonfile each time then we could use > > the glib functions g_file_get_contents() and > > g_file_set_contents(), which get all the pesky details of the > > error handling right for you. > > qemu_create() works only once in case libvirt hands us a > file handle instead of a filename.
If we have to work on a filehandle, we have the problem that if the host crashes after the ftruncate() and before the write() of the new data then we just lost the contents of the var store. Working on filenames would let us do "write new file and then rename in to position". If you need to try to operate on a filehandle in a "don't lose the data for crashes mid-write" that gets tricky. Do we care ? -- PMM