From nobody Fri Nov 22 11:40:43 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=1722263675; cv=none; d=zohomail.com; s=zohoarc; b=KTQV9wu2nZSdK7XWE6joNYlP/GzlXrNT6VYvUYsFyXF5tzDlTgFIbi/cK9VEYwYIg05t62MScJVBPKdo4Mb3uDOzLn8VuV2AazGYx6j5yAsiPtRl6ESJgfruUZDcDrbpSvOHQjDXDcfYKSTxe3ugnwnCzzr4G6yp77OHi8fyAFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722263675; 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=WYQASg0qEMRl0vt7k1Mn52hk12I5MM01uJ4iEBy3MoA=; b=TIo3j7nTIbF8t1WokH/k2eKDUzlqUJVqyHoQWkONU1T76yB2yk2fUOXi12JMTOstwSR5VwcK8Xf07nzx9F7y/WI2rDbg/bulI+lfFQeBbFNNSsb3BBziJQ/Xr1CzZ14FBTGrq+btJgo/uDm7FytGNcJMUdwaNd/l90khbY74SCM= 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 1722263675195752.6016708129208; Mon, 29 Jul 2024 07:34:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.766841.1177369 (Exim 4.92) (envelope-from ) id 1sYRSA-0007Pt-M0; Mon, 29 Jul 2024 14:34:22 +0000 Received: by outflank-mailman (output) from mailman id 766841.1177369; Mon, 29 Jul 2024 14:34:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sYRSA-0007Pm-JX; Mon, 29 Jul 2024 14:34:22 +0000 Received: by outflank-mailman (input) for mailman id 766841; Mon, 29 Jul 2024 14:34:21 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sYRS9-0007Pg-1h for xen-devel@lists.xenproject.org; Mon, 29 Jul 2024 14:34:21 +0000 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [2a00:1450:4864:20::130]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a3b55e8e-4db7-11ef-8776-851b0ebba9a2; Mon, 29 Jul 2024 16:34:19 +0200 (CEST) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-52f0277daa5so5534027e87.0 for ; Mon, 29 Jul 2024 07:34:19 -0700 (PDT) Received: from EMEAENGAAD91498.citrite.net ([217.156.233.154]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acab22ffcsm523005266b.12.2024.07.29.07.34.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:34:17 -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: a3b55e8e-4db7-11ef-8776-851b0ebba9a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1722263658; x=1722868458; 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=WYQASg0qEMRl0vt7k1Mn52hk12I5MM01uJ4iEBy3MoA=; b=kPzHL33kej+L6WDh9hdgWd8zb9kBS7+olUqHXCe0aS9CnAdxs7fSKWi/8T2ZPDRnR9 T+HAlgOBNG6hMKIFf4UMXtSsVbatF8UuPmfnD0x7Ro2izvGbJgEkiuI+dTnN9ztY/87r vdUIQ/xspAZxGaOSttrDxOhnamQbGufIxRYcA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263658; x=1722868458; 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=WYQASg0qEMRl0vt7k1Mn52hk12I5MM01uJ4iEBy3MoA=; b=PHLqbikbyTlHn1hEmHpj4CLwhR9at4kJs/UuIqjMfbEVIwCleuAi9HeGNBxnhJMLLa P2QWBuNiH4FRC/SocN2Fgsj+nwZt4oZLi09RK7xR5WXuIOOyXprvn32tOxgdfGy5nf72 rIJ2ProMb5Q7YEyDPuglJ8Be3YH1lAQiWR/kyJvn+0QRRH0S5RxkuG53VifB80v72Mxv HO4e7qJ/WYsauyrI6fnIsVE2F8d4N2Abjv1zq5MBmV8y5dzHkCMykCr7htQ8aYKEKZ+S 4C9cZ8egj+M4tvxcBc5m9HkoYSrqroOeGNNCxPOp38Z6gt/ATDqb+ojYWc4mNjxFsuuP 3ViA== X-Gm-Message-State: AOJu0YwirCVzo/8D+fCk3exuNOqpYjRK3+gbs9huREvHzbnQi2qxqKmW 19EjQPQHjZoU83HcNylVUIFyP10O+NK8Sw/mzc0pmPmHxlVYuawTF6ouHNQ8nWeObJr9uIPxrFY m X-Google-Smtp-Source: AGHT+IE4mgT1kEGBeVHUDuG7vDqdEvTWYP9MxoqFErLHoggYa/wos73pFBjG56spMhLYXa+UyI8lXQ== X-Received: by 2002:a05:6512:ea0:b0:52c:d819:517e with SMTP id 2adb3069b0e04-5309b27bd2fmr7006371e87.30.1722263657812; Mon, 29 Jul 2024 07:34:17 -0700 (PDT) From: Matthew Barnes To: Xen-devel Cc: Matthew Barnes , Anthony PERARD , Andrew Cooper , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [XEN PATCH v5] tools/lsevtchn: Use errno macro to handle hypercall error cases Date: Mon, 29 Jul 2024 15:34:11 +0100 Message-Id: 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: 1722263676096116600 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 --- 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..b7d1b3d424ae 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,28 @@ 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; + + case ESRCH: + perror("Domain ID does not correspond to valid domain"); + rc =3D ESRCH; + break; + + default: + perror(NULL); + rc =3D errno; + break; + } + goto out; + } =20 if ( status.status =3D=3D EVTCHNSTAT_closed ) continue; @@ -58,7 +80,8 @@ int main(int argc, char **argv) printf("\n"); } =20 +out: xc_interface_close(xch); =20 - return 0; + return rc; } --=20 2.34.1