qemu/scripts
Peter Maydell 08497afcb2 scripts/qemu-guest-agent/fsfreeze-hook: Fix syslog-fallback logic
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: qemu-stable@nongnu.org
Fixes: 85978dfb6b ("qemu-ga: Optimize freeze-hook script logic of logging error")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Link: https://lore.kernel.org/qemu-devel/20260317094806.1944053-4-peter.maydell@linaro.org
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
2026-03-27 19:55:01 +02:00
..
ci tests: Replace ncat with socat in migration test and drop ncat from containers 2026-03-23 13:13:07 +00:00
coccinelle memory: Remove memory_region_init_ram_nomigrate() 2026-03-09 14:05:55 -04:00
codeconverter audio: remove obsolete/obscure functions 2026-02-23 14:28:56 +01:00
coverage scripts/coverage: initial coverage comparison script 2023-04-04 15:16:29 +01:00
coverity-scan hw/net: Remove the xgmac device 2026-03-06 09:01:11 +00:00
kvm target/i386: enumerate VMX nested-exception support 2024-06-08 10:33:38 +02:00
lib/kdoc kernel-doc.py: sync with upstream Kernel v6.19-rc4 2026-01-22 11:23:31 +00:00
modules
oss-fuzz scripts: Move lsan_suppressions.txt out of oss-fuzz subdir 2026-03-06 09:43:18 +00:00
performance scripts/: spelling fixes 2023-09-08 13:08:52 +03:00
qapi python/qapi: delint import statements 2025-11-19 10:46:26 +01:00
qemu-guest-agent scripts/qemu-guest-agent/fsfreeze-hook: Fix syslog-fallback logic 2026-03-27 19:55:01 +02:00
qemugdb scripts/qemugdb: coroutine: Add option for obtaining detailed trace in coredump 2026-02-09 09:24:49 -05:00
qmp scripts: nudge users to use 'run' script for scripts that import qemu.qmp 2026-02-24 13:11:29 -05:00
rust meson: let Meson handle mixed-language linking of Rust and C objects 2025-12-27 10:11:11 +01:00
simplebench scripts: nudge users to use 'run' script for scripts that import qemu.qmp 2026-02-24 13:11:29 -05:00
tracetool tracetool: add Rust DTrace/SystemTap SDT support 2025-12-27 10:11:10 +01:00
analyse-9p-simpletrace.py
analyse-locks-simpletrace.py treewide: remove unnessary "coding" header 2025-10-01 11:22:07 -04:00
analyze-inclusions block: rename block/aio.h to qemu/aio.h 2025-12-27 10:11:12 +01:00
analyze-migration.py scripts/analyze-migration: Support mapped-ram snapshot format 2025-12-23 09:24:34 -05:00
archive-source.sh subprojects: add probe crate 2025-12-27 10:11:10 +01:00
arm_processor_error.py scripts/ghes_inject: add a script to generate GHES error inject 2025-10-05 08:17:08 -04:00
block-coroutine-wrapper.py block-coroutine-wrapper: use qemu_get_current_aio_context() 2023-12-21 22:49:28 +01:00
check_sparse.py
checkpatch.pl scripts/checkpatch: Fix MAINTAINERS update warning with --terse 2026-03-05 17:40:24 +00:00
clean-header-guards.pl disas: Remove libvixl disassembler 2022-07-05 10:15:49 +02:00
clean-includes scripts/clean-includes: Update exclude list 2026-01-22 11:23:31 +00:00
clean_functional_cache.py tests: Evict stale files in the functional download cache after a while 2025-10-16 17:44:32 +02:00
cleanup-trace-events.pl
cocci-macro-file.h win32: remove usage of attribute gcc_struct 2025-01-17 10:45:13 +00:00
compare-machine-types.py scripts: nudge users to use 'run' script for scripts that import qemu.qmp 2026-02-24 13:11:29 -05:00
cpu-x86-uarch-abi.py scripts: drop comment about autogenerated CPU API file 2024-02-09 12:48:07 +00:00
decodetree.py decodetree: Infer argument set before inferring format 2025-07-25 10:31:45 +01:00
device-crash-test configure: unconditionally install "tooling" group 2026-02-24 13:11:29 -05:00
disas-objdump.pl
dump-guest-memory.py
entitlement.sh scripts/entitlement.sh: Use backward-compatible cp flags 2021-11-30 22:25:58 +01:00
extract-vsssdk-headers
feature_to_c.py gdbstub: Emit base_register index in GDBFeature entries 2026-03-10 17:12:18 -07:00
fix-multiline-comments.sh
get-wraps-from-cargo-registry.py scripts: add script to help distros use global Rust packages 2025-07-25 14:51:05 +02:00
get_maintainer.pl scripts/get_maintainer.pl: don't print parentheses 2023-10-17 15:20:53 +02:00
ghes_inject.py scripts/ghes_inject: add a script to generate GHES error inject 2025-10-05 08:17:08 -04:00
git-submodule.sh scripts/git-submodule.sh: Don't rely on non-POSIX 'read' behaviour 2023-07-25 10:56:51 +01:00
git.orderfile scripts/git.orderfile: Display MAINTAINERS changes first 2023-01-13 16:22:57 +01:00
hxtool
kernel-doc.py scripts: Import Python kerneldoc from Linux kernel 2025-08-30 16:37:23 +01:00
lsan_suppressions.txt scripts/lsan_suppressions.txt: Add more leaks 2026-03-06 09:43:18 +00:00
make-config-poison.sh system: Allow restricting the legacy ld/st_phys() 'native-endian' API 2026-01-22 10:48:45 +01:00
make-release subprojects: add probe crate 2025-12-27 10:11:10 +01:00
meson-buildoptions.py meson-buildoptions: Remove duplicated entry of --gdb in the help text 2026-02-06 12:02:56 +00:00
meson-buildoptions.sh accel: Add Nitro Enclaves accelerator 2026-02-27 08:18:31 +01:00
meson.build scripts: add a XML preprocessor script 2023-06-27 17:08:56 +02:00
minikconf.py scripts/minikconf.py: s/Error/KconfigParserError 2025-08-20 22:47:54 +02:00
mkemmc.sh scripts: Add helper script to generate eMMC block device images 2025-11-05 09:26:27 +01:00
modinfo-collect.py scripts: fix broken error path in modinfo-collect.py 2025-12-09 20:48:36 +01:00
modinfo-generate.py scripts/modinfo: add --skip-missing-deps 2026-02-23 14:28:57 +01:00
mtest2make.py mtest2make: do not repeat the same speed over and over 2025-11-19 09:24:01 +01:00
nsis.py scripts/nsis.py: Tell makensis that WoA is 64 bit 2025-12-09 20:56:14 +01:00
probe-gdb-support.py treewide: remove unnessary "coding" header 2025-10-01 11:22:07 -04:00
python_qmp_updater.py scripts: add python_qmp_updater.py 2023-10-12 14:21:44 -04:00
qapi-gen.py
qcow2-to-stdout.py scripts/qcow2-to-stdout.py: Add script to write qcow2 images to stdout 2025-03-13 17:57:23 +01:00
qemu-binfmt-conf.sh binfmt: Add --ignore-family option 2025-03-04 15:42:54 +10:00
qemu-gdb.py scripts/qemu-gdb: Always do full stack dump for python errors 2025-02-06 13:59:00 +01:00
qemu-plugin-symbols.py plugins: add PC diversion API function 2026-03-05 10:54:09 -08:00
qemu-stamp.py meson, configure: move --with-pkgversion, CONFIG_STAMP to meson 2022-05-07 07:46:58 +02:00
qemu-trace-stap scripts: improve error from qemu-trace-stap on missing 'stap' 2025-02-12 10:03:18 -05:00
qemu-version.sh
qmp_helper.py scripts: nudge users to use 'run' script for scripts that import qemu.qmp 2026-02-24 13:11:29 -05:00
qom-cast-macro-clean-cocci-gen.py licenses: Remove SPDX tags not being license identifier for Linaro 2025-01-30 13:01:22 +03:00
rdma-migration-helper.sh qtest/migration/rdma: Add test for rdma migration with ipv6 2025-05-20 11:26:32 -04:00
refresh-pxe-roms.sh
render_block_graph.py scripts: nudge users to use 'run' script for scripts that import qemu.qmp 2026-02-24 13:11:29 -05:00
replay-dump.py replay: remove dependency on audio/ 2026-02-23 14:28:57 +01:00
rust-to-clang-target-test.sh configure: set the bindgen cross target 2025-09-30 19:33:25 +04:00
rust-to-clang-target.sh configure: set the bindgen cross target 2025-09-30 19:33:25 +04:00
shaderinclude.py build-sys: fix crlf-ending C code 2023-02-02 10:44:23 +00:00
signrom.py
simpletrace.py simpletrace: added simplified Analyzer2 class 2023-09-26 12:28:51 -04:00
symlink-install-tree.py scripts/symlink-install-tree.py: Fix MESONINTROSPECT parsing 2024-10-29 15:04:46 +00:00
tracetool.py treewide: remove unnessary "coding" header 2025-10-01 11:22:07 -04:00
u2f-setup-gen.py
undefsym.py
update-linux-headers.sh scripts/update-linux-headers: Add Nitro Enclaves header 2026-02-27 08:18:31 +01:00
update-mips-syscall-args.sh linux-user, mips: update syscall-args-o32.c.inc to Linux v5.13 2021-07-13 13:59:59 +02:00
update-syscalltbl.sh linux-user,loongarch: move to syscalltbl file 2024-09-22 09:30:18 +02:00
userfaultfd-wrlat.py tests, scripts: Don't import print_function from __future__ 2025-09-16 17:31:53 +01:00
vmstate-static-checker.py scripts/vmstate-static-checker: Fix deprecation warnings with latest argparse 2025-11-03 16:04:10 -05:00
xen-detect.c xen: Drop support for Xen versions below 4.7.1 2023-06-07 15:07:10 +01:00
xml-preprocess-test.py scripts: add a XML preprocessor script 2023-06-27 17:08:56 +02:00
xml-preprocess.py scripts/xml-preprocess: Make sure this script is invoked via the right Python 2023-10-12 00:37:39 +03:00