lsevtchn terminates the loop when the hypercall returns an error, even
if there are still event channels with higher port numbers to be
enumerated over.

Continue the loop even on hypercall errors, and use the new status
identifiers for the evtchn_status hypercall, namely "port invalid" and
"domain invalid", to determine when to break the loop.

Signed-off-by: Matthew Barnes <matthew.bar...@cloud.com>
---
 tools/xcutils/lsevtchn.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/xcutils/lsevtchn.c b/tools/xcutils/lsevtchn.c
index d1710613ddc5..4a48620cd72a 100644
--- a/tools/xcutils/lsevtchn.c
+++ b/tools/xcutils/lsevtchn.c
@@ -24,11 +24,20 @@ int main(int argc, char **argv)
         status.port = port;
         rc = xc_evtchn_status(xch, &status);
         if ( rc < 0 )
-            break;
+            continue;
 
         if ( status.status == EVTCHNSTAT_closed )
             continue;
 
+        if ( status.status == EVTCHNSTAT_dom_invalid )
+        {
+            printf("Domain ID '%d' does not correspond to valid domain.\n", 
domid);
+            break;
+        }
+
+        if ( status.status == EVTCHNSTAT_port_invalid )
+            break;
+
         printf("%4d: VCPU %u: ", port, status.vcpu);
 
         switch ( status.status )
-- 
2.34.1


Reply via email to