From: Matthew Barnes <matthew.barnes@cloud.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Matthew Barnes <matthew.barnes@cloud.com>,
Anthony PERARD <anthony.perard@vates.tech>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Jan Beulich <jbeulich@suse.com>, Julien Grall <julien@xen.org>,
Stefano Stabellini <sstabellini@kernel.org>
Subject: [XEN PATCH v6] tools/lsevtchn: Use errno macro to handle hypercall error cases
Date: Mon, 29 Jul 2024 16:02:41 +0100 [thread overview]
Message-ID: <cbb751a7fab10d228513bb163c85c83d025330c9.1722265284.git.matthew.barnes@cloud.com> (raw)
Currently, lsevtchn aborts its event channel enumeration when it hits
an event channel that 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>
---
Changes in v6:
- Add blank space before label
Changes in v5:
- Code style changes to switch statement
Changes in v4:
- Catch non-critical errors and fail on everything else, instead of
catching few known critical errors and ignoring everything else
- Use 'perror' to describe miscellaneous critical errors
- Return appropriate error code from lsevtchn tool
- Tweak commit description
---
tools/xcutils/lsevtchn.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/tools/xcutils/lsevtchn.c b/tools/xcutils/lsevtchn.c
index d1710613ddc5..29504c9d2077 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,28 @@ int main(int argc, char **argv)
status.port = port;
rc = xc_evtchn_status(xch, &status);
if ( rc < 0 )
- break;
+ {
+ switch ( errno )
+ {
+ case EACCES: /* Xen-owned evtchn */
+ continue;
+
+ case EINVAL: /* Port enumeration has ended */
+ rc = 0;
+ break;
+
+ case ESRCH:
+ perror("Domain ID does not correspond to valid domain");
+ rc = ESRCH;
+ break;
+
+ default:
+ perror(NULL);
+ rc = errno;
+ break;
+ }
+ goto out;
+ }
if ( status.status == EVTCHNSTAT_closed )
continue;
@@ -58,7 +80,8 @@ int main(int argc, char **argv)
printf("\n");
}
+ out:
xc_interface_close(xch);
- return 0;
+ return rc;
}
--
2.34.1
next reply other threads:[~2024-07-29 15:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-29 15:02 Matthew Barnes [this message]
2024-07-29 16:02 ` [XEN PATCH v6] tools/lsevtchn: Use errno macro to handle hypercall error cases Anthony PERARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cbb751a7fab10d228513bb163c85c83d025330c9.1722265284.git.matthew.barnes@cloud.com \
--to=matthew.barnes@cloud.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.