From nobody Mon Apr 6 23:41:53 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1773740930; cv=none; d=zohomail.com; s=zohoarc; b=mT48HnOLPqHk2pI+Kl/aX1TCu2YdW+aah62SfSCgA0GUKB1zREul7YUqZEGuL9F6CFgLsS1+/b9UKwa/MK7O2cUCwg+YY9xLoxF1LZz441DcTFHEx4HR7g3XR1kqPrw+ajGXhRei/fBmY478ipCXCoBUn3xN6I7yD55bPlAz26g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773740930; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IVwcDllVF+PIsQQDJxzoY8CPdJKMLwF1VpkJA51D9D0=; b=SLa9u2ccg6ZB5ERJeAd3Ph3deJcojH4eIPn1NRA5Xj7yLi7QE2L4lEebYpgiJgLUzIkhzfhykzxBQfVKl799GQddaNgtsbkqLFFvdgVyviLjLhTLQybuQzK5ieRmpW1yxnAkHkUpi6cvivliuyWqr35piW7bZvZNLsxDvKxPa0Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1773740930835430.97269801065363; Tue, 17 Mar 2026 02:48:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w2R27-0001o7-7P; Tue, 17 Mar 2026 05:48:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w2R23-0001nO-Mb for qemu-devel@nongnu.org; Tue, 17 Mar 2026 05:48:12 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1w2R22-00043i-6c for qemu-devel@nongnu.org; Tue, 17 Mar 2026 05:48:11 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-48532925a4bso28776845e9.1 for ; Tue, 17 Mar 2026 02:48:09 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4856ea98070sm54329075e9.6.2026.03.17.02.48.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2026 02:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1773740889; x=1774345689; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IVwcDllVF+PIsQQDJxzoY8CPdJKMLwF1VpkJA51D9D0=; b=I4kC1jFW6yHN0b6FQOgu8Ab0yfYTc/ybfbg9DznE2nEZRnkAVkVANE20tVNAeKjW2J lZQLOMSREpVgJNE3mxKddkr2mDXQtVljGQvGm65ISCWT1AvyBpn4qYQlODzxTB0gBdTN Jt6xf1BpcqgOBxynQDqoQGR5NZ7rk0NBV35XQ3CGup715p8b3wtz/XW2oQatLreh8wau pk6Z0e903x2Qu9eEVzGFlrlIG6CB0GJ1jh/pr6isUEuapAuRMyQlibUw+VI+QX+xglri 4IFrlCWLY7Y6kM196LHI8L3rWzuZO4OFaBlaA7XV+F1hX6/1Ay7OQJDs+n2fClEQ4Ecd dAtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773740889; x=1774345689; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=IVwcDllVF+PIsQQDJxzoY8CPdJKMLwF1VpkJA51D9D0=; b=T59gCujUMJcsgfkJAvAZlxaMWftUj2gjuFNJRsi1y35ur8XdHyFQCklBjdJtt2Yhmv USFlEypsiKoZvzFOeMBYqoHNumHQtT8MJ2GsP94v9lbeL/1KRXAp5rCD6aQZvwfb0zx7 YML0Z6Q6kpTD7exw58bwVSN6a0zun+FWoiASjUCeuIu27dP+sqbALaSH4No6RXWKY6Q2 pWNp/ixrtTSQQpNxlpW1fpXAe++x+tjC72FYDt+/JdVAtJYOZjlNcoNWpN/S4FGB2ppR qp+ggUtgjyVro/pvINxcTHHVFNQx7X9iY62YwuJ7Jb50hZ5Ti1CM55x8QFs+phmehbRC lq9w== X-Gm-Message-State: AOJu0YxmSHBgUOCvfdoWAX+2zHhpsgDEy/2CadkX1upf7pG8kuecQpYS OfXHLxlf5qeWu9yb3UimuosmCE24LLQ0QWrdGJZtaxDrof3ZzHbS1f0ePo+N6H8ZjNbb5dgIQo2 Jf7ek X-Gm-Gg: ATEYQzydEsZxDl+CH7CFvTTs5WrvpR5DeCV41WJ10W0qP2Bb8JIoCYVK+Dkm2gFIpVs rajHygrWlvfbigcFEwCJSjdl2GnbeHTg8B/n9Ht+m2p4HoMuglaetnR+r+cQmPuzlTUyx2I1x4Z XVGrJUdmMJQ3urbuZkrou/FzEmc6pebCv40up7tPg4vGU/u5v+1yPbpb724NXV2x/dLR+LqbtKp 5xBxS286UTiw8jom8kXYqahSQnQTrhncgSk2P2Zh7XyNEvjv7oX5eo6787q8q4i+dLsZgo3rsZ6 wXgh53zdYu5ddn4Mfk6amJ0riojHfGxfrasU7Fhu2mEjZUIm52d22h2oV0i5KWbKQJydArOdlqG ZcWvGCfyqmv8jE1W5+sEM2jwBSrBu74Sm3tZQR7ih/pvziVEDASELQqIIUrYMEXBWi06b/CL5lZ T72fpOnVufFLhYMFxNaBpupRjORMxJ2qauB3ZG0zQsUdwCqHu6NduIGJSbFH6ErjLNSqBM5Tc8m KK4FKRKs3JFT0JJmSH8fks7byr4lAw= X-Received: by 2002:a05:600c:1395:b0:485:3026:2b8b with SMTP id 5b1f17b1804b1-4855670607emr263158695e9.29.1773740888501; Tue, 17 Mar 2026 02:48:08 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Michael Roth , Kostiantyn Kostiuk Subject: [PATCH 1/3] scripts/qemu-guest-agent/fsfreeze-hook: Avoid bash-isms Date: Tue, 17 Mar 2026 09:48:04 +0000 Message-ID: <20260317094806.1944053-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260317094806.1944053-1-peter.maydell@linaro.org> References: <20260317094806.1944053-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1773740933687154100 Content-Type: text/plain; charset="utf-8" The fsfreeze-hook script starts with #!/bin/sh, but it uses several bash-specific constructs, resulting in misbehaviour on guest systems where /bin/sh is some other POSIX shell. Fix the simple ones reported by shellcheck: In scripts/qemu-guest-agent/fsfreeze-hook line 27: touch "$LOGFILE" &>/dev/null || USE_SYSLOG=3D1 ^---------^ SC3020 (warning): In POSIX sh, &> is undefined. In scripts/qemu-guest-agent/fsfreeze-hook line 31: local message=3D"$1" ^-----------^ SC3043 (warning): In POSIX sh, 'local' is undefined. In scripts/qemu-guest-agent/fsfreeze-hook line 46: log_message "Executing $file $@" ^-- SC2145 (error): Argument mixes string = and array. Use * or separate argument. In scripts/qemu-guest-agent/fsfreeze-hook line 55: if [ $STATUS -ne 0 ]; then ^-----^ SC2086 (info): Double quote to prevent globbing and word s= plitting. There is also a use of PIPESTATUS that is more complex to fix; that will be dealt with in a separate commit. Cc: qemu-stable@nongnu.org Fixes: 85978dfb6b1c133 ("qemu-ga: Optimize freeze-hook script logic of logg= ing error") Signed-off-by: Peter Maydell Reviewed-by: Kostiantyn Kostiuk --- scripts/qemu-guest-agent/fsfreeze-hook | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/qemu-guest-agent/fsfreeze-hook b/scripts/qemu-guest-ag= ent/fsfreeze-hook index 5b915af017..6e2d7588af 100755 --- a/scripts/qemu-guest-agent/fsfreeze-hook +++ b/scripts/qemu-guest-agent/fsfreeze-hook @@ -24,15 +24,14 @@ USE_SYSLOG=3D0 # if log file is not writable, fallback to syslog [ ! -w "$LOGFILE" ] && USE_SYSLOG=3D1 # try to update log file and fallback to syslog if it fails -touch "$LOGFILE" &>/dev/null || USE_SYSLOG=3D1 +touch "$LOGFILE" >/dev/null 2>&1 || USE_SYSLOG=3D1 =20 # Ensure the log file is writable, fallback to syslog if not log_message() { - local message=3D"$1" if [ "$USE_SYSLOG" -eq 0 ]; then - printf "%s: %s\n" "$(date)" "$message" >>"$LOGFILE" + printf "%s: %s\n" "$(date)" "$1" >>"$LOGFILE" else - logger -t qemu-ga-freeze-hook "$message" + logger -t qemu-ga-freeze-hook "$1" fi } =20 @@ -43,7 +42,7 @@ for file in "$FSFREEZE_D"/* ; do is_ignored_file "$file" && continue [ -x "$file" ] || continue =20 - log_message "Executing $file $@" + log_message "Executing $file $*" if [ "$USE_SYSLOG" -eq 0 ]; then "$file" "$@" >>"$LOGFILE" 2>&1 STATUS=3D$? @@ -52,7 +51,7 @@ for file in "$FSFREEZE_D"/* ; do STATUS=3D${PIPESTATUS[0]} fi =20 - if [ $STATUS -ne 0 ]; then + if [ "$STATUS" -ne 0 ]; then log_message "Error: $file finished with status=3D$STATUS" else log_message "$file finished successfully" --=20 2.43.0 From nobody Mon Apr 6 23:41:53 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1773740956; cv=none; d=zohomail.com; s=zohoarc; b=E7BIrP4zodZ3N+bRwS6jXuaLFxr9/odvmMKtoRwA6so5YzNyITYTNXuA+JXPpP4ueEanV3j0fyAIUPAhD18QaWRA43/1e8WPBjAy1lGD6NsAaSeCHBUTUmEbo5e/HYfykYemc4x5ls2nmekyYbb0De15MARE7s4gaMwn58Smnso= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773740956; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0srI6lC7NklTkYTvsgaVvhomkxbDk+VOa5Qai6ZEJZU=; b=lhiBX4z3+tLoLSUq5THasoUOEz+7caYfM/T41uQQsH8jPTqfnUYVQaZpKtGa2eT+XEZTz7Q/h0zXfVctyR3H3q44+bHOrAvqynh782JOjW+/0adLK+9PBH5dc5Z4iKnoygkrEOSGw23ftfDTS8DjaleWimnN4cwB5hpQjAOj8Ek= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1773740956592593.7093750856629; Tue, 17 Mar 2026 02:49:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w2R28-0001oe-JF; Tue, 17 Mar 2026 05:48:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w2R24-0001nR-E0 for qemu-devel@nongnu.org; Tue, 17 Mar 2026 05:48:12 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1w2R22-00043n-PP for qemu-devel@nongnu.org; Tue, 17 Mar 2026 05:48:12 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-48628ce9ab5so5427405e9.2 for ; Tue, 17 Mar 2026 02:48:10 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4856ea98070sm54329075e9.6.2026.03.17.02.48.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2026 02:48:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1773740889; x=1774345689; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0srI6lC7NklTkYTvsgaVvhomkxbDk+VOa5Qai6ZEJZU=; b=Swdt8K7DRzpccdX5KLNIdfs4uUFAztdTahfw6FRgGorUpkBk6T13He8a9b+WfrXDKJ G2Ti54SVueo518qFEEsWKi57txZSZ9YEbi/0CLpp8im1BexKJ1RoD8CJsYjoSZZwJib+ yQtzKxa97nqSzq9LuJHo0wxAGmTOmEPX1clAF4rAg4D9oJOdACRjC+90qGkRVHC5G4nz rO8lAkhs+k/zbdEg4ucTqadi2XJ+zKkZ8aUphemdBdFPdACCxU1rKpskDnnSyfEdAxj7 Qw09Qe91QgPh2aRU6CD+TmfhH5e69TZOwOT6F1MAgVh09KSomhuGAAif1Y8h013YUikM 9//w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773740889; x=1774345689; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=0srI6lC7NklTkYTvsgaVvhomkxbDk+VOa5Qai6ZEJZU=; b=mRWxgAA2Iu45O/w8psFXq1vnsgTxVDjN/0ws/yZ1JWEXCG/h3miyk9O6OcJ2kZEIcb fhMmPJ07Th0etPH6N8R9DV3JHKKdLpb2tEdB1as8sbm5GVNbDtB34dlkE1aBnEqqBDDw AaMX2wOYpBsEb+qDccDCCsUhbTZzyD0fRFr+s+XNJZ/HTmEPj8izj3AGQYYEQyXIwvRF K9KpgVK42+qaB0rI+bTjEXH7uqycwWKcerNIbUEhcsgyTlzfZbqVRpkTAW6OfV16ZO5C 6UDqu0zqoLgrP5MBiaKYJlFrSst2QUVyI//5/kI2lUkeW4//WRL6vHvYz/wLHf+20UOb /jOw== X-Gm-Message-State: AOJu0Yx7s/pK7JqRAYOl7PJTFgODOELfUomvxlETQLGzB7E6cc8b1EtY xcjMA04iZ0XH9ReJkN1HOhkVWx8rU0oobL/BJD+w/gyCXYQwe6SpaPYvB5AABkXtgWeiKPB/0cm LXRhv X-Gm-Gg: ATEYQzwYNCWY3MPPKAbLZQFd4MriSpE74ycD8FQnde0UPHCSAwZOz7tPS2SuS+N4ZYv eZInUGea4TbmHIQlSlGOrmtb9zytLuM3FLGgKEQqwml1GdjT/OCfVbSwEURQOw1DgDi+iAhY9nq /igm2bLnlt/Nxm6HGSbvlP+7M4sV/ZHSRc+pkgQVvCavf8zhqzOcek+TyREf9fEgTkTrKxAFVsa kVIgsgqvisG+PVbUOjdUNaMomzw7w9+vry1tcQAq1cED3fm+yrEk69eDS06jkFSP5vbS/EDLnK+ BlFyKv8yBopMp6hftOYtiLvyePiOOE3ydGti4AQfXCBhRdw+ZxrADSsK51WkPcQZicX0GdTEQWd 3BzAVMX9+I0383nT67Z4G9WPYAkrOZ3YPwRch0EfJjxZDH5SDgDoejDJfmzM5SUVvuEC1FRBTdF GNPMD8A0G0x/M+TrPADGSBeOzTniG6MEGpHKHEH5/MaZpOgOKXSO5DhcoQxqYun8WYfpDJXMIRm sfxeTGQhYqfTE00A9UYdhqHK5UQ6zs= X-Received: by 2002:a05:600c:34d3:b0:486:d76c:fa51 with SMTP id 5b1f17b1804b1-486d76cff4amr9178085e9.27.1773740889346; Tue, 17 Mar 2026 02:48:09 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Michael Roth , Kostiantyn Kostiuk Subject: [PATCH 2/3] scripts/qemu-guest-agent/fsfreeze-hook: Avoid use of PIPESTATUS Date: Tue, 17 Mar 2026 09:48:05 +0000 Message-ID: <20260317094806.1944053-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260317094806.1944053-1-peter.maydell@linaro.org> References: <20260317094806.1944053-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1773740958258158500 Content-Type: text/plain; charset="utf-8" PIPESTATUS is a bash-specific construct, and this script is supposed to be POSIX shell. We only use it in one place, to capture the exit status of a command whose output we are piping to 'logger'. Replace the PIPESTATUS usage with the trick described in https://unix.stackexchange.com/questions/14270/get-exit-status-of-process-t= hats-piped-to-another/70675#70675 which uses a command-group to capture the status of the first process in the pipeline. Cc: qemu-stable@nongnu.org Fixes: 85978dfb6b1c133 ("qemu-ga: Optimize freeze-hook script logic of logg= ing error") Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3339 Signed-off-by: Peter Maydell Reviewed-by: Kostiantyn Kostiuk --- scripts/qemu-guest-agent/fsfreeze-hook | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/qemu-guest-agent/fsfreeze-hook b/scripts/qemu-guest-ag= ent/fsfreeze-hook index 6e2d7588af..21eb5c5145 100755 --- a/scripts/qemu-guest-agent/fsfreeze-hook +++ b/scripts/qemu-guest-agent/fsfreeze-hook @@ -47,8 +47,23 @@ for file in "$FSFREEZE_D"/* ; do "$file" "$@" >>"$LOGFILE" 2>&1 STATUS=3D$? else - "$file" "$@" 2>&1 | logger -t qemu-ga-freeze-hook - STATUS=3D${PIPESTATUS[0]} + # We want to pipe the output of $file through 'logger' and also + # capture its exit status. Since we are a POSIX script we can't + # use PIPESTATUS, so instead this is a trick borrowed from + # https://unix.stackexchange.com/questions/14270/get-exit-status-o= f-process-thats-piped-to-another/70675#70675 + # which uses command-groups and redirection to get the exit status. + # This is equivalent to + # "$file" "$@" 2>&1 | logger -t qemu-ga-freeze-hook + # plus setting the exit status of the pipe to the exit + # status of the first command rather than the last one. + { { { { + "$file" "$@" 2>&1 3>&- 4>&- + echo $? >&3 + } | logger -t qemu-ga-freeze-hook >&4 + } 3>&1 + } | { read -r xs ; exit "$xs"; } + } 4>&1 + STATUS=3D$? fi =20 if [ "$STATUS" -ne 0 ]; then --=20 2.43.0 From nobody Mon Apr 6 23:41:53 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1773740949; cv=none; d=zohomail.com; s=zohoarc; b=GGt4ZQOHENS2zIwbAnFcr8shahOB7zGpJ72E88wPvo0iePUvoCvXUdnZKvIPyP9A+womk2TikdV0B0sF1larsoq2nukqzjUXLBhxTAa1sKctPfSazOvDvtAQuas1ubMhHvgkVk+XTOSwGHPty/FEvzgmfoRLN8wFYCSIHu3sGjY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773740949; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/iFyReZLv6A8DCGV09DfF1JGeNsnz7YwppXHJdu2GgE=; b=n6aFeVZXvU8WjyhZ8qSbMQgUHjdUY7qCQNu2OTmvt9WpVdVKTxOFWtKx7AfFMFyhvP7O1Y2hL+N3jj7MSN5VnHimea4/jlFGhQYAmVp/zeakkxgDUUHhDve+l26MMIfQmBE27+vFq9CJ9J3mlzDajb8zk5C3MnEBJFJEoTwwWZo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1773740949067667.3933262825984; Tue, 17 Mar 2026 02:49:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w2R2A-0001op-G5; Tue, 17 Mar 2026 05:48:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w2R25-0001nw-Ft for qemu-devel@nongnu.org; Tue, 17 Mar 2026 05:48:13 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1w2R23-00043w-QR for qemu-devel@nongnu.org; Tue, 17 Mar 2026 05:48:13 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-48334ee0aeaso48480025e9.1 for ; Tue, 17 Mar 2026 02:48:11 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4856ea98070sm54329075e9.6.2026.03.17.02.48.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2026 02:48:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1773740890; x=1774345690; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/iFyReZLv6A8DCGV09DfF1JGeNsnz7YwppXHJdu2GgE=; b=U+jOo+zmw3MDymddRlApTSXaMmBK/Ee2sg75YDwUyPJRskuDHzh9qUOb4knJUY8aBM 7sA8uyFOhbfX/WgyLQlhUeTcmGzwJui4NtvbaEGYPz6gnxjuneSWH16LLFE/WkfdwZ1/ chxh0wFG9l6UN+WAVPpdhQ8pxBpo2w5XmWxuxeylbhkK5K8IPkJsTdnsl5XSs31OSuuY 5l2ji/MGq8ttayuAkYtH5lkxtmDIMgHvvnZTIvMGjqoODKPO2ZN/zgW4Nwoxx955KtEh 10Z0asASWR/9Y0CrwnY9LYH+xr/C+Va7E1davuciALVhQ9KpCMeaFXpj5jU5iWyh5Z4I eKOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773740890; x=1774345690; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=/iFyReZLv6A8DCGV09DfF1JGeNsnz7YwppXHJdu2GgE=; b=XZ1YL3OR9UMIkJbxSPaFBeyunpAo69Vo8EeSC97yvpE1JUp+Hr6t3WF2KeKudBGebv s7Afic7kHxHk11+UDRum/dMWRit+P19KqJNorEGzfYrNkbiHOyNeDU+smsr1A44k2D2q Ynz+RTwjVVNk9gq9cwsXMPufenBb1K8l/6LhLBX8uiP72zmN45OgESay6ddb4oOUMir7 DAdJqkOW69e1YpO1Afk+GsbKlpDXoCCGxPEaJvhx92dVhFet3Zr0TTNF8leVEwHaeWX6 I6Vn2hjHgiBWmflgpIfnt5EAJZ1K51F822LrSXB8v4EVeaZg/rMq7D03flv3bYAX8Jx4 WrHw== X-Gm-Message-State: AOJu0YxHPg+thi90YKvMce70i6IoEiMQMqiOelbo0x9sAcXPH1zIjvcl EMSJWDsHVKLOXJ8w5VWEJk26+5mxvh86SQ4cxYZYbMs+jl6Av2sTgAsP8BqsNUKt8o61E4OiBX1 E2LSW X-Gm-Gg: ATEYQzzODG1ClNnJuiCr3Mv7A92vm2feRcUnn+HYPEvteeBys8V3/t2HeaS8dzVvBA/ hGC+hrxoBySZaeGEyIUEcuv5WVm/LfnGwJ1XLjzmXUf77eRVTu0hQ6Gc7lJBnDviCemViZ4orXO /rUUafaeyzhuKC3ZWO3pDlD9UUElTwjBnppTlXCBjfeFioKLsC8VeMsKNj9XCqfHxuEHAYfQQFR dhstDgJ7Wd6LQ5V7e+dg/OA6PZiJQYR73uDYnWWCAXMLUyQb6AEGRKrdrtxiDn6CJZc0jTa506f ZmbqMpxGI2XV/GROkeChmMmq5hIrwWfsbBcoFJ5ZUqX9xqbhhp47TFUzdr1uno2TQ8cY/CoVpu4 jjxtiaCg1RiYq2mdPwZLK+2AwM68MT71KMniYnegAAqaVQ8QIQnZ/brgjF4+eF/oOw1rN1iOPAg 2pxpxly+jhTcRB3a8qm9Nb9+v9onyHUCZoqhhJ8U/aSXlg32oTHrf0obuqfHOU4je+762/YYzn1 C9/x0LNMSJT6IxrUx56yFaiGTsmTlg= X-Received: by 2002:a05:600c:8011:b0:485:3b00:f939 with SMTP id 5b1f17b1804b1-485570ce1acmr252779375e9.8.1773740890115; Tue, 17 Mar 2026 02:48:10 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Michael Roth , Kostiantyn Kostiuk Subject: [PATCH 3/3] scripts/qemu-guest-agent/fsfreeze-hook: Fix syslog-fallback logic Date: Tue, 17 Mar 2026 09:48:06 +0000 Message-ID: <20260317094806.1944053-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260317094806.1944053-1-peter.maydell@linaro.org> References: <20260317094806.1944053-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1773740950037154100 Content-Type: text/plain; charset="utf-8" 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=3D1 touch "$LOGFILE" >/dev/null 2>&1 || USE_SYSLOG=3D1 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=3D1. 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: 85978dfb6b1c133 ("qemu-ga: Optimize freeze-hook script logic of logg= ing error") Signed-off-by: Peter Maydell Reviewed-by: Kostiantyn Kostiuk Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- scripts/qemu-guest-agent/fsfreeze-hook | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/qemu-guest-agent/fsfreeze-hook b/scripts/qemu-guest-ag= ent/fsfreeze-hook index 21eb5c5145..76669f5caf 100755 --- a/scripts/qemu-guest-agent/fsfreeze-hook +++ b/scripts/qemu-guest-agent/fsfreeze-hook @@ -21,8 +21,8 @@ is_ignored_file() { } =20 USE_SYSLOG=3D0 -# if log file is not writable, fallback to syslog -[ ! -w "$LOGFILE" ] && USE_SYSLOG=3D1 +# if log file exists but is not writable, fallback to syslog +[ -e "$LOGFILE" ] && [ ! -w "$LOGFILE" ] && USE_SYSLOG=3D1 # try to update log file and fallback to syslog if it fails touch "$LOGFILE" >/dev/null 2>&1 || USE_SYSLOG=3D1 =20 --=20 2.43.0