All of lore.kernel.org
 help / color / mirror / Atom feed
* [XEN PATCH v3] tools/lsevtchn: Use errno macro to handle hypercall error cases
@ 2024-07-15 15:36 ` Matthew Barnes
  0 siblings, 0 replies; 4+ messages in thread
From: Matthew Barnes @ 2024-05-08 11:04 UTC (permalink / raw)
  To: Xen-devel
  Cc: Matthew Barnes, Andrew Cooper, George Dunlap, Jan Beulich,
	Julien Grall, Stefano Stabellini, Anthony PERARD

Currently, lsevtchn aborts its event channel enumeration when it hits
its first hypercall error, namely:
* When an event channel doesn't exist at the specified port
* When the event channel is owned by Xen

lsevtchn does not distinguish between different hypercall errors, which
results in lsevtchn missing potential relevant event channels with
higher port numbers.

Use the errno macro to distinguish between hypercall errors, and
continue event channel enumeration if the hypercall error is not
critical to enumeration.

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

diff --git a/tools/xcutils/lsevtchn.c b/tools/xcutils/lsevtchn.c
index d1710613ddc5..e4b3f88fe4ec 100644
--- a/tools/xcutils/lsevtchn.c
+++ b/tools/xcutils/lsevtchn.c
@@ -3,6 +3,7 @@
 #include <stdint.h>
 #include <string.h>
 #include <stdio.h>
+#include <errno.h>
 
 #include <xenctrl.h>
 
@@ -24,7 +25,18 @@ int main(int argc, char **argv)
         status.port = port;
         rc = xc_evtchn_status(xch, &status);
         if ( rc < 0 )
-            break;
+        {
+            if ( errno == ESRCH )
+            {
+                fprintf(stderr, "Domain ID '%d' does not correspond to valid domain.\n", domid);
+                break;
+            }
+
+            if ( errno == EINVAL )
+                break;
+
+            continue;
+        }
 
         if ( status.status == EVTCHNSTAT_closed )
             continue;
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-07-23 16:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-08 11:04 [XEN PATCH v3] tools/lsevtchn: Use errno macro to handle hypercall error cases Matthew Barnes
2024-07-15 15:36 ` [XEN PATCH v3 RESEND] " Matthew Barnes
2024-05-14 14:15 ` [XEN PATCH v3] " Jan Beulich
2024-07-23 16:51 ` [XEN PATCH v3 RESEND] " Anthony PERARD

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.