From nobody Mon Apr 29 12:44:30 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1628729905; cv=none; d=zohomail.com; s=zohoarc; b=a/uMzs/rCtG5LEsHfZNXYtvFk/JWkCxUb6E+jrp6kKjCgZvOdpvnQg3RownCVnJT3lcLtB+y0BdJ8yGKoG2D9vjNir3I/XTUngvOQAz9f5Mw6OFU3IwwiSuzi+8dA65HXdivfpaT1GW1aMlCQeisiVnEQHI3+g1RElbpW9zL0dQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628729905; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=YZFpHqZ18RAHlwIBW8zPlfdiJZMmIECW9lTEa+PkGTg=; b=cFfKe4u529FTlXcJToU4CD2dyu7jIawzvmhDO9ih5nngbo8RYvUbuV1l4gLpXA8zI+r297eYgID96ZRlaBQYUw/lXk9XqQDN/En6SJACJDncp6cpe+s15hh78L5jhjgByDWW9iBkszaL0N+kTjusYClPuJCoENpikycDXatVBwE= 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=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1628729905800704.765057178437; Wed, 11 Aug 2021 17:58:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.166183.303478 (Exim 4.92) (envelope-from ) id 1mDz2d-0004zU-4C; Thu, 12 Aug 2021 00:57:51 +0000 Received: by outflank-mailman (output) from mailman id 166183.303478; Thu, 12 Aug 2021 00:57:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mDz2d-0004zN-1G; Thu, 12 Aug 2021 00:57:51 +0000 Received: by outflank-mailman (input) for mailman id 166183; Thu, 12 Aug 2021 00:57:49 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mDz2b-0004zH-10 for xen-devel@lists.xenproject.org; Thu, 12 Aug 2021 00:57:49 +0000 Received: from mail-qt1-x82d.google.com (unknown [2607:f8b0:4864:20::82d]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f1c70254-ef12-4253-9944-5b3a59bbb42d; Thu, 12 Aug 2021 00:57:47 +0000 (UTC) Received: by mail-qt1-x82d.google.com with SMTP id l24so3738645qtj.4 for ; Wed, 11 Aug 2021 17:57:47 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:9a6d:dce3:ac2:6190]) by smtp.gmail.com with ESMTPSA id i18sm485260qkk.115.2021.08.11.17.57.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Aug 2021 17:57:46 -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: f1c70254-ef12-4253-9944-5b3a59bbb42d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YZFpHqZ18RAHlwIBW8zPlfdiJZMmIECW9lTEa+PkGTg=; b=JaPiE5rMz/BT/SKoDeuKeIsM5ZL56sbHBv+sDzJMRWNJZrzDI+lnNCXLgoXeC1IPhH a4BXKZWyZlmJH57Fq//t/Ha1TVa+uf2COlut5ERX3R5Xu/SdPUPw3mJbCGro0uBQeHBr VVW7Pzo8qMB769qEkH1MNOt2ZfiEZwiJ91Z2bVQbinO7RroiQQLuEQQ7N2EJ6xZFhBMW iFKYInc6TpjqGAk+e/8iCMnvHQnRDjpasijWB56czwq5oMyU/gGDvMWFf8shdzBSPatY yP3+SmfGfS8tsfXiQWzpEx1qik9DMQRj8SUotZ15QbsSGBYQnFaD99schRjOgo5aHZVX 8C6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YZFpHqZ18RAHlwIBW8zPlfdiJZMmIECW9lTEa+PkGTg=; b=omX+U0gy68GCNp0+tnvfhfW1rdUlxcJpykG9m6us5OaGYQqv7DViTCHQxOJmRewtTi FdOv3oGU4OViyqeFst1gNvxCHq7tdkN68D5eMmzu2q/CneEiQ85fmOrYpxYIUK3BxNpA 2NlGDtQpo1oQmYpgsCaZggTRuShOmspn7uweyV5rEq9GeK5Unh8IIDk/XZJTd+f5o4pR 0N+fZHBKPI7N1tZajNsau2nMxbHievAGFoUtm9VazF0XWxh3+OcgLO7VAKJxa0iOTd3e UnGGkWl23IRRJrfT3fLX/+jfHh+rQuzqGgfLfhTsRvfMvS9cD+OkkZN5PVzGGWKQMs8K Z2Uw== X-Gm-Message-State: AOAM531fksa3zZ223EjqraVtokdzfatTCP1hHB3oQTniE1McYiTIKyQo dhFVF17tczfdFRvHbRoMEBCrkZ21RdI= X-Google-Smtp-Source: ABdhPJxdDfySv+Iakuj0bi7vNSAhCiKDRa/EzM+GZXORGegIwLqWJtIM8BOVe8B7gPTvEvbWULRJWA== X-Received: by 2002:a05:622a:1183:: with SMTP id m3mr1415553qtk.323.1628729867151; Wed, 11 Aug 2021 17:57:47 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: pdurrant@amazon.com, Jason Andryuk , Ian Jackson , Wei Liu , Anthony PERARD , Juergen Gross Subject: [PATCH v2] libxl: Fix stubdom PCI passthrough Date: Wed, 11 Aug 2021 20:57:00 -0400 Message-Id: <20210812005700.3159-1-jandryuk@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1628729907815100001 Content-Type: text/plain; charset="utf-8" commit 0fdb48ffe7a1 "libxl: Make sure devices added by pci-attach are reflected in the config" broken stubdom PCI passthrough when it moved libxl__create_pci_backend later in the function. xl pci-attach for a running PV domain may also have been broken, but that was not verified. The stubdomain is running (!starting) and PV, so it calls libxl__wait_for_backend. With the new placement of libxl__create_pci_backend, the path does not exist and the call immediately fails. libxl: error: libxl_device.c:1388:libxl__wait_for_backend: Backend /local/d= omain/0/backend/pci/43/0 does not exist libxl: error: libxl_pci.c:1764:device_pci_add_done: Domain 42:libxl__device= _pci_add failed for PCI device 0:2:0.0 (rc -3) libxl: error: libxl_create.c:1857:domcreate_attach_devices: Domain 42:unabl= e to add pci devices The wait is only relevant when the backend is already present. num_devs is already used to determine if the backend needs to be created. Re-use num_devs to determine if the backend wait is necessary. The wait is necessary to avoid racing with another PCI attachment reconfiguring the front/back. If we are creating the backend, then we don't have to worry about a racing reconfigure. Fixes: 0fdb48ffe7a1 ("libxl: Make sure devices added by pci-attach are reflected in the config") Signed-off-by: Jason Andryuk --- v2: Add Fixes Expand num_devs use in commit message --- tools/libs/light/libxl_pci.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c index 1a1c263080..19daf1d4ee 100644 --- a/tools/libs/light/libxl_pci.c +++ b/tools/libs/light/libxl_pci.c @@ -157,8 +157,10 @@ static int libxl__device_pci_add_xenstore(libxl__gc *g= c, if (domtype =3D=3D LIBXL_DOMAIN_TYPE_INVALID) return ERROR_FAIL; =20 - if (!starting && domtype =3D=3D LIBXL_DOMAIN_TYPE_PV) { - if (libxl__wait_for_backend(gc, be_path, GCSPRINTF("%d", XenbusSta= teConnected)) < 0) + /* wait is only needed if the backend already exists (num_devs !=3D NU= LL) */ + if (num_devs && !starting && domtype =3D=3D LIBXL_DOMAIN_TYPE_PV) { + if (libxl__wait_for_backend(gc, be_path, + GCSPRINTF("%d", XenbusStateConnected))= < 0) return ERROR_FAIL; } =20 --=20 2.30.2