When the list of domains is fetched and being printed, but in the
meantime one domain was undefined before its status was fetched, the
output then includes domain with "no state".  With this patch, such
domain is skipped over as consecutive 'virsh list --all' (or the same
one ran a second later) wouldn't list it anyway.

Signed-off-by: Martin Kletzander <mklet...@redhat.com>
---
 tools/virsh-domain-monitor.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 2af0d4f..4e434f8 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -1916,6 +1916,11 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
             ignore_value(virStrcpyStatic(id_buf, "-"));

         state = vshDomainState(ctl, dom, NULL);
+
+        /* Domain could've been removed in the meantime */
+        if (state < 0)
+            continue;
+
         if (optTable && managed && state == VIR_DOMAIN_SHUTOFF &&
             virDomainHasManagedSaveImage(dom, 0) > 0)
             state = -2;
-- 
2.1.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to