From 1eb53f05bc82a72e30d3efc594f0a7ca4a3c60c3 Mon Sep 17 00:00:00 2001 From: Martin Kletzander Date: Thu, 30 Oct 2014 14:39:04 +0100 Subject: [PATCH] virsh: don't list unknown domains 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 --- 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 2af0d4fc33..4e434f89d0 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;