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 <mkletzan@redhat.com>
This commit is contained in:
Martin Kletzander 2014-10-30 14:39:04 +01:00
parent b3880bbe97
commit 1eb53f05bc

View File

@ -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;