From nobody Fri Nov 22 10:52:56 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=1722265396; cv=none; d=zohomail.com; s=zohoarc; b=J499HEIXWgTsdkFrrHqsnM+o8Hn3HOiF030xyaiPG1cAFZfjQk23jZtb48pG0Y1EAdK43zaj8OyX0efZA2aaY9k7WNHCmoYT8NepESj4O3MxMBp2F4qxUgpwQGgbIYXsXp9nPdBy9+y7xrNns0i9iZayx0SJuLtpuvtP8BbFMXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722265396; 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=kBtjsfdsTy7i8mRY2ZgMcr3TDqeVEGFIRB258IV37CA=; b=hz6NnopDBHHjCgpGPVtjmrIqOhBDGspa+bP4RoSkWBue3la4hAvUOhRV2zrqMc/YfsCL/BuBIwDcwJd+DbMqJ5pXEnJQZjW+DiyqYewenFo3weNTzhk4Tsv3nPHz5Pyru08pn24K5fB3RFGud0CUtUwbeohQu1/+unsdWoDDtvo= 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 172226539679434.664551832792085; Mon, 29 Jul 2024 08:03:16 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.766873.1177411 (Exim 4.92) (envelope-from ) id 1sYRto-0006In-H6; Mon, 29 Jul 2024 15:02:56 +0000 Received: by outflank-mailman (output) from mailman id 766873.1177411; Mon, 29 Jul 2024 15:02:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sYRto-0006Ig-Bu; Mon, 29 Jul 2024 15:02:56 +0000 Received: by outflank-mailman (input) for mailman id 766873; Mon, 29 Jul 2024 15:02:55 +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 1sYRtn-0006Ia-Dx for xen-devel@lists.xenproject.org; Mon, 29 Jul 2024 15:02:55 +0000 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [2a00:1450:4864:20::533]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a17c0cb2-4dbb-11ef-8776-851b0ebba9a2; Mon, 29 Jul 2024 17:02:53 +0200 (CEST) Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-5afa207b8bfso3103068a12.0 for ; Mon, 29 Jul 2024 08:02:53 -0700 (PDT) Received: from EMEAENGAAD91498.citrite.net ([217.156.233.154]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac6339b06esm5848322a12.10.2024.07.29.08.02.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 08:02:52 -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: a17c0cb2-4dbb-11ef-8776-851b0ebba9a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1722265373; x=1722870173; 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=kBtjsfdsTy7i8mRY2ZgMcr3TDqeVEGFIRB258IV37CA=; b=bXl/YNPq/y8M6JBi8jWAAjX9XMi2Fpw7u9H+9a2Lg2scRiErjo3nD3GyUHtrNAvBOb KSvxlvxNT7D1U6QjzjLtliXO978D1oBtiMzEQmdzKVoGqKQAdS7VzyfxKZFAQE3c8kiN XUnsEp8hfwrHTqaDtvqcvzf/vO/74z4EzFAWY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722265373; x=1722870173; 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=kBtjsfdsTy7i8mRY2ZgMcr3TDqeVEGFIRB258IV37CA=; b=NiZEn4i086rBqFNpaKD+ELC9yoQcjyAdJZz85XbBL2jOg1nbpMssCWFLU2c+Y6nuFf IVnNvTKKLHLbwsmGbjT6P72kmn4kIpfjOBTKxQFZh/XxzmUKVl1Dpk2PRGpTl63FLLq8 5BIvEHuKlnljehKigeI9JvvoUb+l5Cs2Gao9kAzQOzmblTIY3GFFlf6/1fS6LzAYKMcf bQHJnwBK2/UwfJWtTrhkjFUdCMUnGOh/K7mnSB5ri06+Ir4+Die+TbzswLbbbSEzbEQR llZUDrAf0/sBe5xsO0EHGce8w5MwbLZsl86c+/gPQ6+bvi+/W56eajwxMICnV/l8aBnj ai7A== X-Gm-Message-State: AOJu0Yw2h+DB6CNal7I7FHRJxnkJ+I+Koi0uimidmfBEsUY+7O0UTxkY /7D4Pk0S9pdbl6aE3bC3A2yB+OuYxwRax5Z+IzwIu0Oyd4WAs74PxW5v0/VMypIRhlfMFl87Czl z X-Google-Smtp-Source: AGHT+IEklQ96vRviqOT8LlJpDTS1BsN+ypuK42NQSF78PAKQ9a8sQ24qH0SFjgEQUGQ2p/1LYCSRKw== X-Received: by 2002:a50:d489:0:b0:5a2:1693:1a2f with SMTP id 4fb4d7f45d1cf-5b0208c2d59mr4992714a12.12.1722265372287; Mon, 29 Jul 2024 08:02:52 -0700 (PDT) From: Matthew Barnes To: Xen-devel Cc: Matthew Barnes , Anthony PERARD , Andrew Cooper , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [XEN PATCH v6] tools/lsevtchn: Use errno macro to handle hypercall error cases Date: Mon, 29 Jul 2024 16:02:41 +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: 1722265398307116600 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 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 #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