Reviewed-by: Kostiantyn Kostiuk <[email protected]>

On Tue, Mar 17, 2026 at 11:54 AM Philippe Mathieu-Daudé <[email protected]>
wrote:

> On 17/3/26 10:48, Peter Maydell wrote:
> > In the fsfreeze script we attempt to implement "log to a file if we
> > can, and fall back to syslog if we cannot".  We do this with:
> >
> >    [ ! -w "$LOGFILE" ] && USE_SYSLOG=1
> >    touch "$LOGFILE" >/dev/null 2>&1 || USE_SYSLOG=1
> >
> > This has a weird behaviour if it is run in a setup where we have
> > permissions that would allow us to write to $LOGFILE but it does not
> > currently exist.  On the first execution, the '-w' fails and so we
> > set USE_SYSLOG=1.  But since we also do the "touch $LOGFILE" step we
> > create an empty logfile.  Then on the second time the script is
> > executed, we see a writeable logfile and will use it.  The effect is
> > "log to syslog once, then to the logfile thereafter", which is not
> > likely to be what anybody wants.
> >
> > Update the condition of the first check to only pick syslog if
> > the logfile exists but is not writable. This means that:
> >   * if the logfile doesn't exist but we are able to create it,
> >     we will create it and use it
> >   * if the logfile already exists and we can write to it,
> >     we will use it
> >   * if the logfile already exists but we can't write to it,
> >     we will fall back to syslog
> >   * if the logfile doesn't exist and we can't create it,
> >     we will fall back to syslog
> >
> > Cc: [email protected]
> > Fixes: 85978dfb6b1c133 ("qemu-ga: Optimize freeze-hook script logic of
> logging error")
> > Signed-off-by: Peter Maydell <[email protected]>
> > ---
> >   scripts/qemu-guest-agent/fsfreeze-hook | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
>
> Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
>
>

Reply via email to