From dbdaf22b6327860443712a8b0acfb25f752c9e29 Mon Sep 17 00:00:00 2001 From: Lucas Amaral Date: Mon, 16 Feb 2026 12:50:06 -0300 Subject: [PATCH] virsh: report "unknown" for autostart when API query fails When virStoragePoolGetAutostart(), virNetworkGetAutostart(), or virNodeDeviceGetAutostart() fails, the respective info commands report "no autostart". This is incorrect: the API failure means we cannot determine the autostart state, not that autostart is disabled. The persistent field in the same functions already correctly reports "unknown" on API failure. Apply the same pattern to the autostart field for consistency and correctness. Signed-off-by: Lucas Amaral Reviewed-by: Michal Privoznik --- tools/virsh-network.c | 4 ++-- tools/virsh-nodedev.c | 2 +- tools/virsh-pool.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/virsh-network.c b/tools/virsh-network.c index a725be289f..0e6503a4f1 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -715,7 +715,7 @@ cmdNetworkInfo(vshControl *ctl, const vshCmd *cmd) vshPrint(ctl, "%-15s %s\n", _("Persistent:"), persistent ? _("yes") : _("no")); if (virNetworkGetAutostart(network, &autostart) < 0) - vshPrint(ctl, "%-15s %s\n", _("Autostart:"), _("no autostart")); + vshPrint(ctl, "%-15s %s\n", _("Autostart:"), _("unknown")); else vshPrint(ctl, "%-15s %s\n", _("Autostart:"), autostart ? _("yes") : _("no")); @@ -1055,7 +1055,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) if (optTable) { if (virNetworkGetAutostart(network, &is_autostart) < 0) - autostartStr = _("no autostart"); + autostartStr = _("unknown"); else autostartStr = is_autostart ? _("yes") : _("no"); diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index 2ce0c1411f..e78fc24897 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -1245,7 +1245,7 @@ cmdNodeDeviceInfo(vshControl *ctl, const vshCmd *cmd) vshPrint(ctl, "%-15s %s\n", _("Persistent:"), virNodeDeviceIsPersistent(device) ? _("yes") : _("no")); if (virNodeDeviceGetAutostart(device, &autostart) < 0) - vshPrint(ctl, "%-15s %s\n", _("Autostart:"), _("no autostart")); + vshPrint(ctl, "%-15s %s\n", _("Autostart:"), _("unknown")); else vshPrint(ctl, "%-15s %s\n", _("Autostart:"), autostart ? _("yes") : _("no")); diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index e06a6cf7c8..c4821cf41d 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -1204,7 +1204,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) /* Retrieve the autostart status of the pool */ if (virStoragePoolGetAutostart(list->pools[i], &autostart) < 0) - poolInfoTexts[i].autostart = g_strdup(_("no autostart")); + poolInfoTexts[i].autostart = g_strdup(_("unknown")); else poolInfoTexts[i].autostart = g_strdup(autostart ? _("yes") : _("no")); @@ -1554,7 +1554,7 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd) /* Check and display whether the pool is autostarted or not */ if (virStoragePoolGetAutostart(pool, &autostart) < 0) - vshPrint(ctl, "%-15s %s\n", _("Autostart:"), _("no autostart")); + vshPrint(ctl, "%-15s %s\n", _("Autostart:"), _("unknown")); else vshPrint(ctl, "%-15s %s\n", _("Autostart:"), autostart ? _("yes") : _("no"));