]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: don't list unknown domains
authorMartin Kletzander <mkletzan@redhat.com>
Thu, 30 Oct 2014 13:39:04 +0000 (14:39 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Mon, 3 Nov 2014 15:43:23 +0000 (16:43 +0100)
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>
tools/virsh-domain-monitor.c

index 2af0d4fc33475f25e07e88083ab9f7741f1cec09..4e434f89d06bb4d93324bd638eca89874989fb8f 100644 (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;