From nobody Thu Sep 19 00:18:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1722442759; cv=none; d=zohomail.com; s=zohoarc; b=joXEEaDeIVrxSRWRgBz9P9nzYUFc84ZRwKOOEJw9Z2/dFO/HAUTY0MuB3NTEV7EivdXGR7AqM/Jy5aGNt7vPURnusTxrC9sYe3JsuhZC2XYRJB8Ymcb9aFskzRFkrQb6avuxdgBFIK+JQdKiFF7L6YGaz0B2j6TLSOvX992b2rc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722442759; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5zC3HPEws4IIYtj9rD2QA6iPL+Fvw6yU8Hh17lmetT8=; b=dgwLCr2DPc70ZNIiP0IDAs2/UL2pgtugjuGVH1LfTDFjZK1Dh0Z1FGuhW93ZLxKYWSLzyTcywUL98Ndw/liCxOap3ppcmOc7Iiwb9ZwQzAO4/KAAQS4XT+el3PR2RAY688sRjWBgPT0EshITGG2pu3+cD+Oxqyx/Dlm3/T2LoCI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1722442759184378.89976353600173; Wed, 31 Jul 2024 09:19:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.768968.1179871 (Exim 4.92) (envelope-from ) id 1sZC2X-0006X8-A3; Wed, 31 Jul 2024 16:19:01 +0000 Received: by outflank-mailman (output) from mailman id 768968.1179871; Wed, 31 Jul 2024 16:19:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sZC2X-0006X1-7U; Wed, 31 Jul 2024 16:19:01 +0000 Received: by outflank-mailman (input) for mailman id 768968; Wed, 31 Jul 2024 16:19:00 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sZC2W-0006Wv-3l for xen-devel@lists.xenproject.org; Wed, 31 Jul 2024 16:19:00 +0000 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [2a00:1450:4864:20::635]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 97227334-4f58-11ef-bc01-fd08da9f4363; Wed, 31 Jul 2024 18:18:59 +0200 (CEST) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a7a83a968ddso824180066b.0 for ; Wed, 31 Jul 2024 09:18:59 -0700 (PDT) Received: from EMEAENGAAD91498.citrite.net ([217.156.233.154]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acad9068esm782937566b.153.2024.07.31.09.18.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 09:18:57 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 97227334-4f58-11ef-bc01-fd08da9f4363 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1722442738; x=1723047538; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=5zC3HPEws4IIYtj9rD2QA6iPL+Fvw6yU8Hh17lmetT8=; b=SNyfUnAM/AV6uOb+GzjzglyT7lOjd6PVY3GbgxB0wOoy5pJB8+tzdrBfbd41qNHx8F Q2+0W5jMeowRECYYWW9DfTM48uuawSbSMjkd1yEtbaypSfN2FBCwF3wsi+RxtO49g2VD xW+1zJuXRR7CwpRAIqTaFQ6wB9PRusVzDcnrc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722442738; x=1723047538; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5zC3HPEws4IIYtj9rD2QA6iPL+Fvw6yU8Hh17lmetT8=; b=m/TdJt7gBnCPqk9Ye/2FBJ+6oATOOcgS3Y8K/RA6+6tUg2GeiVqsXtSbj3L+jilM3D HzNDBAZ9LooskPonrZvcyhn4XgHvbL4+cmM0JOYfOOfmuJDWP0Vlzv36GQ/VgvhEf08T qYBVN0OpyloQspo/WXZtCl5Dfyu8CgtLpCpoc1hSoDe9+1AUGuNTzIeSbrySGnBmrqIe E5PUsn2l7o2NwUNrJTtimbhBitVKIwmao0477coxf6Kk00SlVa7HVHX7yPvVnIeLNshh W3WmkPHTn5tN4NtdcgcfeitmJmzbMaQ7jfbr0nKwsdAerE7SbzzydH76UwT4HrJ7+5dI l3gQ== X-Gm-Message-State: AOJu0YxUiaXLBq8EZDTfQv0pUapWi0+w2aUMBnmwPq+j9iRaFGQ8ri7m YMY7K5TQZbLXwpkMey/oaG+QEF34DYDA3DmpuP/iXX4f+aWU4XbehRUUiUfTYI5gge8kASDc3Xb A X-Google-Smtp-Source: AGHT+IFjv/4LBO10IXmqnvFnYNmlumiMtnHFjHZgiuyxzbbjLnpE0xQP4sqUCHBHZ8Yd3VynDr/cbA== X-Received: by 2002:a17:906:ee85:b0:a72:9d25:8ad3 with SMTP id a640c23a62f3a-a7d3ff58047mr934361666b.9.1722442737377; Wed, 31 Jul 2024 09:18:57 -0700 (PDT) From: Matthew Barnes To: Xen-devel Cc: Matthew Barnes , Anthony PERARD , Andrew Cooper , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [XEN PATCH v7] tools/lsevtchn: Use errno macro to handle hypercall error cases Date: Wed, 31 Jul 2024 17:18:44 +0100 Message-Id: <1240a14dea2f75d2e5b8d8e8bb685fac956629c6.1722442563.git.matthew.barnes@cloud.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Bcc: Matthew Barnes Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1722442761754116600 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Anthony PERARD --- Changes in v7: - All error paths return error code 1 from lsevtchn - Simplify perror message to failing function "xc_evtchn_status" 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 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tools/xcutils/lsevtchn.c b/tools/xcutils/lsevtchn.c index d1710613ddc5..30c8d847b814 100644 --- a/tools/xcutils/lsevtchn.c +++ b/tools/xcutils/lsevtchn.c @@ -3,6 +3,7 @@ #include #include #include +#include =20 #include =20 @@ -24,7 +25,23 @@ int main(int argc, char **argv) status.port =3D port; rc =3D xc_evtchn_status(xch, &status); if ( rc < 0 ) - break; + { + switch ( errno ) + { + case EACCES: /* Xen-owned evtchn */ + continue; + + case EINVAL: /* Port enumeration has ended */ + rc =3D 0; + break; + + default: + perror("xc_evtchn_status"); + rc =3D 1; + break; + } + goto out; + } =20 if ( status.status =3D=3D EVTCHNSTAT_closed ) continue; @@ -58,7 +75,8 @@ int main(int argc, char **argv) printf("\n"); } =20 + out: xc_interface_close(xch); =20 - return 0; + return rc; } --=20 2.34.1