diff mbox series

[XEN,v2,2/2] tools/lsevtchn: Use new status identifiers in loop

Message ID 83f66a419e0df15d23f0dd8e1e5680658d0c136d.1714148012.git.matthew.barnes@cloud.com (mailing list archive)
State New, archived
Headers show
Series Enumerate all allocated evtchns in lsevtchn | expand

Commit Message

Matthew Barnes April 29, 2024, 1:42 p.m. UTC
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.barnes@cloud.com>
---
 tools/xcutils/lsevtchn.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff mbox series

Patch

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 )