From: Martin Kletzander Date: Thu, 30 Oct 2014 13:39:04 +0000 (+0100) Subject: virsh: don't list unknown domains X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=1eb53f05bc82a72e30d3efc594f0a7ca4a3c60c3;p=libvirt.git 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 --- 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;