From 91db41227fa385b19942e6f677d9b871031e0878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20B=C4=99za?= Date: Tue, 3 Jun 2025 13:18:26 +0200 Subject: [PATCH] runtime: Fix logging on virtiofs shutdown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes a confusing log message shown when Virtio-FS is disabled. Previously we logged “The virtiofsd had stopped” regardless of whether Virtio-FS was actually enabled or not. Signed-off-by: Paweł Bęza --- src/runtime/virtcontainers/clh.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/runtime/virtcontainers/clh.go b/src/runtime/virtcontainers/clh.go index 29c8001256..7965fc797c 100644 --- a/src/runtime/virtcontainers/clh.go +++ b/src/runtime/virtcontainers/clh.go @@ -726,7 +726,11 @@ func (clh *cloudHypervisor) StartVM(ctx context.Context, timeout int) error { return err } defer func() { - if err != nil { + if err == nil { + return + } + + if clh.config.SharedFS == config.VirtioFS || clh.config.SharedFS == config.VirtioFSNydus { if shutdownErr := clh.stopVirtiofsDaemon(ctx); shutdownErr != nil { clh.Logger().WithError(shutdownErr).Warn("error shutting down VirtiofsDaemon") } @@ -1303,10 +1307,12 @@ func (clh *cloudHypervisor) terminate(ctx context.Context, waitOnly bool) (err e return err } - clh.Logger().Debug("stop virtiofsDaemon") + if clh.config.SharedFS == config.VirtioFS || clh.config.SharedFS == config.VirtioFSNydus { + clh.Logger().Debug("stop virtiofsDaemon") - if err = clh.stopVirtiofsDaemon(ctx); err != nil { - clh.Logger().WithError(err).Error("failed to stop virtiofsDaemon") + if err = clh.stopVirtiofsDaemon(ctx); err != nil { + clh.Logger().WithError(err).Error("failed to stop virtiofsDaemon") + } } return