From nobody Fri May 17 23:22:23 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1569680538; cv=none; d=zoho.com; s=zohoarc; b=NhGdhTjT/H+KQLIWJGCIF44XpeCulfyGRQIcBfxVN8PZh2IBrIpu1WLfDbhMVFmunKSbTeCFZxQbypUbFqFYoeNAuqfmb2Yj5jzDuc9ykYk2e87BLsiugC0PT+tHb/X2sdjG+Zy/VBYkNeGhV5YaUZDHk2hZmPRIBXd2rSqATtI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569680538; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=3apD2+1TBXyBkxUjkTLsxsYAMfamWR03pQFjMYvMsq8=; b=QGpDjU8YWctrDJ+up4a8klOQ6a0/2eR3No/g+t8fh1B7YlOcMq+pQen7hGGul+qanTg3vPJ6ci9bCSvuEFmD3BPL+rmiR68oexlbhOU4/bTirHCmjbJkLIPq+9dQHeBtKyGALhFs61qOfts/K4avqjFOgCKo9DYzjhR6B3qlGYI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1569680538517287.3454275080352; Sat, 28 Sep 2019 07:22:18 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEDb1-0003ij-5A; Sat, 28 Sep 2019 14:21:15 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEDaz-0003iJ-MN for xen-devel@lists.xenproject.org; Sat, 28 Sep 2019 14:21:13 +0000 Received: from out5-smtp.messagingengine.com (unknown [66.111.4.29]) by localhost (Halon) with ESMTPS id 39665e8e-e1fb-11e9-969b-12813bfff9fa; Sat, 28 Sep 2019 14:21:12 +0000 (UTC) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 8EDA820A34; Sat, 28 Sep 2019 10:21:12 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sat, 28 Sep 2019 10:21:12 -0400 Received: from localhost.localdomain (ip5b412221.dynamic.kabel-deutschland.de [91.65.34.33]) by mail.messagingengine.com (Postfix) with ESMTPA id 9BFE3D6005E; Sat, 28 Sep 2019 10:21:11 -0400 (EDT) X-Inumbo-ID: 39665e8e-e1fb-11e9-969b-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=ibdft5z05fi+deOTQfoWvYpaHLXDhNtQVvDJtCVld ek=; b=EJcRl8RJQcWWC0vMTt+Tx14LvkuG14LrlIEOFuy8DJsHYdbZ8fG2q2aLg H6aDJ/1LJP2q9qjtxugq8ttode4FnxPwveU2XHTDDOE/EC7o7LJ3OtreXIp7vpYs qkB9FLpgDPorNCjR/RLdDSe+55aoyaReO+oD5cq9FYY+q5aXjg9TX5Nbh4o+CN7V EvvwrNe4d+v53F9TbjdtuAIVs6gAPNk/qKQrIecIhDNMLgkKkM+MxBuTo9pbwqQ/ y7kXI0tLpGpRUFk5tTQmswiEQWjLChPvbLaEBJe76h3BNFA6kkgPgJUmvjuePW2Y KKkhSaDWUoTl3XYgAJed7ZGFUykow== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrfeekgdejgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpeforghrvghk ucforghrtgiihihkohifshhkihdqifpkrhgvtghkihcuoehmrghrmhgrrhgvkhesihhnvh hishhisghlvghthhhinhhgshhlrggsrdgtohhmqeenucfkphepledurdeihedrfeegrdef feenucfrrghrrghmpehmrghilhhfrhhomhepmhgrrhhmrghrvghksehinhhvihhsihgslh gvthhhihhnghhslhgrsgdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= To: xen-devel@lists.xenproject.org Date: Sat, 28 Sep 2019 16:20:34 +0200 Message-Id: <9a61b361c46b5b1082ef47ac6aa25f8b5db7646b.1569680095.git-series.marmarek@invisiblethingslab.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v8 1/4] libxl: fix cold plugged PCI device with stubdomain X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Wei Liu Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" When libxl__device_pci_add() is called, stubdomain is already running, even when still constructing the target domain. Previously, do_pci_add() was called with 'starting' hardcoded to false, but now do_pci_add() shares 'starting' flag in pci_add_state for both target domain and stubdomain. Fix this by resetting (local) 'starting' to false in pci_add_dm_done() (previously part of do_pci_add()) when handling stubdomain, regardless of pas->starting value. Fixes: 11db56f9a6 (libxl_pci: Use libxl__ao_device with libxl__device_pci_a= dd) Signed-off-by: Marek Marczykowski-G=C3=B3recki Reviewed-by: Anthony PERARD --- tools/libxl/libxl_pci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index 4725817..2edff64 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -1300,6 +1300,10 @@ static void pci_add_dm_done(libxl__egc *egc, =20 if (rc) goto out; =20 + /* stubdomain is always running by now, even at create time */ + if (isstubdom) + starting =3D false; + sysfs_path =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/resource", pcidev->d= omain, pcidev->bus, pcidev->dev, pcidev->func); f =3D fopen(sysfs_path, "r"); @@ -1559,7 +1563,6 @@ void libxl__device_pci_add(libxl__egc *egc, uint32_t = domid, GCNEW(pcidev_s); libxl_device_pci_init(pcidev_s); libxl_device_pci_copy(CTX, pcidev_s, pcidev); - /* stubdomain is always running by now, even at create time */ pas->callback =3D device_pci_add_stubdom_done; do_pci_add(egc, stubdomid, pcidev_s, pas); /* must be last */ return; --=20 git-series 0.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri May 17 23:22:23 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1569680540; cv=none; d=zoho.com; s=zohoarc; b=eSgjYagJT8gzzaplpY9UwkbReirP3uENoGKiR26Huw3vKFOvq1BNJhsKttLRqDIm0iwFIh7WEG3Uqq3y3JWaBx6jBbGPCr3cmheqGuqcKWsGBZQ55hLliHvnZMFZOI8XCTPusGY3u5EP04Uoy022djMH7r9E2MblQZpK+CzSyL8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569680540; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=n+pOB7jwIJb1/Ly24tnv9gBvRHaq2mbuQ4lhxQ6vR9c=; b=fcEktd9WGXb4sbhieIrWMATGQegZ4BOjXieezeOZQki4FwsMQhBCk2J+d3lVQAOK4SPwMB6It4EcpOXLaPY+N3SC1i3PKfrRKbpOc7ZLC7jLda38kHKiLIGiWLCbgRsaNXsIAPJlVAMhGFWqBL/l/lbKP3bRQ/TFcnZBciQVGzU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1569680540836555.8056871348468; Sat, 28 Sep 2019 07:22:20 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEDb4-0003jr-GZ; Sat, 28 Sep 2019 14:21:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEDb3-0003jX-EU for xen-devel@lists.xenproject.org; Sat, 28 Sep 2019 14:21:17 +0000 Received: from out5-smtp.messagingengine.com (unknown [66.111.4.29]) by localhost (Halon) with ESMTPS id 39f16b46-e1fb-11e9-97fb-bc764e2007e4; Sat, 28 Sep 2019 14:21:13 +0000 (UTC) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 9149821C1C; Sat, 28 Sep 2019 10:21:13 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sat, 28 Sep 2019 10:21:13 -0400 Received: from localhost.localdomain (ip5b412221.dynamic.kabel-deutschland.de [91.65.34.33]) by mail.messagingengine.com (Postfix) with ESMTPA id 8966CD60057; Sat, 28 Sep 2019 10:21:12 -0400 (EDT) X-Inumbo-ID: 39f16b46-e1fb-11e9-97fb-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=v7bttf3yQOOR1SZPxB6rw3qy/co3pMgStgeM8sWnq as=; b=j0QHtM6cJwEJK8Oe4DumSwdn3mmcdrKRopVeCd1s9dziVLGYGBZcQWXXT Zsw4hrxLn5Jsr7J5SaBShaNCNK8/pwPuSp+Zhkquyv6RwQTkqMMxKB69lU6Uawb4 W5/dGoaPii1XkDyKt1wTKWUjVypokMxdktPLyFCOqeu0OFLUjqmHSyuedMUOn40q ng/J9FHp3D3+LDmpW3n4k1YIxrQKea2hQ45FUXo+n9FAIikfS+NHnmbtC8w+qMtw cR3J4yHLs/VktJI3uaYdfz8WT9TNN8urBuFkrsgmciUCf3CpoF7T+UIq0o7Uiavn Q70cRxtOOuskE+XhYpoYKAmIeq40w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrfeekgdejgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpeforghrvghk ucforghrtgiihihkohifshhkihdqifpkrhgvtghkihcuoehmrghrmhgrrhgvkhesihhnvh hishhisghlvghthhhinhhgshhlrggsrdgtohhmqeenucfkphepledurdeihedrfeegrdef feenucfrrghrrghmpehmrghilhhfrhhomhepmhgrrhhmrghrvghksehinhhvihhsihgslh gvthhhihhnghhslhgrsgdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= To: xen-devel@lists.xenproject.org Date: Sat, 28 Sep 2019 16:20:35 +0200 Message-Id: <38b059a9d0a923c7d3f7eb24b675f6ab43863340.1569680095.git-series.marmarek@invisiblethingslab.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v8 2/4] libxl: do not attach xen-pciback to HVM domain, if stubdomain is in use X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , Ian Jackson , Wei Liu , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Wei Liu Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" HVM domains use IOMMU and device model assistance for communicating with PCI devices, xen-pcifront/pciback isn't directly needed by HVM domain. But pciback serve also second function - it reset the device when it is deassigned from the guest and for this reason pciback needs to be used with HVM domain too. When HVM domain has device model in stubdomain, attaching xen-pciback to the target domain itself may prevent attaching xen-pciback to the (PV) stubdomain, effectively breaking PCI passthrough. Fix this by attaching pciback only to one domain: if PV stubdomain is in use, let it be stubdomain (the commit prevents attaching device to target HVM in this case); otherwise, attach it to the target domain. Signed-off-by: Marek Marczykowski-G=C3=B3recki Acked-by: Wei Liu --- Changes in v2: - previously called "libxl: attach xen-pciback only to PV domains" - instead of excluding all HVMs, change the condition to what actually matters here - check if stubdomain is in use; this way xen-pciback is always in use (either for the target domain, or it's stubdomain), fixing PCI reset by xen-pciback concerns Changes in v3: - adjust commit message Changes in v8: - rebase on staging --- tools/libxl/libxl_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index 2edff64..ac597a5 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -1399,7 +1399,7 @@ out_no_irq: } } =20 - if (!starting) + if (!starting && !libxl_get_stubdom_id(CTX, domid)) rc =3D libxl__device_pci_add_xenstore(gc, domid, pcidev, starting); else rc =3D 0; @@ -1697,7 +1697,7 @@ static void add_pcidevs_done(libxl__egc *egc, libxl__= multidev *multidev, libxl_domid domid =3D apds->domid; libxl__ao_device *aodev =3D apds->outer_aodev; =20 - if (d_config->num_pcidevs > 0) { + if (d_config->num_pcidevs > 0 && !libxl_get_stubdom_id(CTX, domid)) { rc =3D libxl__create_pci_backend(gc, domid, d_config->pcidevs, d_config->num_pcidevs); if (rc < 0) { --=20 git-series 0.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri May 17 23:22:23 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1569680544; cv=none; d=zoho.com; s=zohoarc; b=VhGZLaJdkloqxRZURfqKtCb0vZOGEMKJ4pxUP2WHqs/aHVIEQq/fvSYMNzVAHTmmJMZ+5qp60o7rMT4frbTU8+P767+PdaKxvYKb9213mm9yWqwNu2ZcbJMELgnvjLF6ZHWFbr5IAHQdDAxGz7MbkjQrKfs0xaRO3VH3g5zyUXg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569680544; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=lu3BdPIK/pFglwmKntfHf1WjsIW4K+YM156eEbEGJtM=; b=IOV6zZQ0FFgGjAeRoQo4Z1zXuEFM/AN0eABV6J5KQ0V/upodFXqbaWeCUiDpQkJx92a2ediVyk/yg9AI1pWo6ivvZfqXACvqofEjHqAJUcb1xkOeTM/DwJUvnhDtqwAxp3KitESmd6FUROLo6vuNw/fpZTnz8dDaP9jkYJbyqWA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1569680544320579.8789310009132; Sat, 28 Sep 2019 07:22:24 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEDbA-0003mr-A3; Sat, 28 Sep 2019 14:21:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEDb8-0003m4-DH for xen-devel@lists.xenproject.org; Sat, 28 Sep 2019 14:21:22 +0000 Received: from out5-smtp.messagingengine.com (unknown [66.111.4.29]) by localhost (Halon) with ESMTPS id 3a77441e-e1fb-11e9-b588-bc764e2007e4; Sat, 28 Sep 2019 14:21:14 +0000 (UTC) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 7362921CDD; Sat, 28 Sep 2019 10:21:14 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sat, 28 Sep 2019 10:21:14 -0400 Received: from localhost.localdomain (ip5b412221.dynamic.kabel-deutschland.de [91.65.34.33]) by mail.messagingengine.com (Postfix) with ESMTPA id 90488D6005E; Sat, 28 Sep 2019 10:21:13 -0400 (EDT) X-Inumbo-ID: 3a77441e-e1fb-11e9-b588-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=HAmib2qqZ5oj8XczRtcegzLko/r9WTZq+MH/BELfW UI=; b=syT9x8jTXgX573Yq9m3LHwPScUstkraRJ7rielm3gGFbdJ+UhEwz9oWyO UM5MEmayaJoUmxrEricMjiqQsnQz/BgxXljxgdxRYsc+wGcQj31xQVhSd+/vc3AC ieKQUpukLsfgvI1P/1X33k9R4L9c0nv5dF79EbiQ2Lm4gYZK0M3vIn74hEeoPovE iZXIs+et4pKEsBJn4PI7VzPFbbIORw3g+3ZeP7eDOZls2T6ZfzHZYh0UUBPSlQ3l Ix+chP5vCf+DdqE42ii5Pkpd7mh3EO6WMdB9zqnumfpHum4fk9XaNsL/HvzEw6Sa xWwPpqenAqXNz5HhxvBMfaBgzRtAw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrfeekgdejgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpeforghrvghk ucforghrtgiihihkohifshhkihdqifpkrhgvtghkihcuoehmrghrmhgrrhgvkhesihhnvh hishhisghlvghthhhinhhgshhlrggsrdgtohhmqeenucfkphepledurdeihedrfeegrdef feenucfrrghrrghmpehmrghilhhfrhhomhepmhgrrhhmrghrvghksehinhhvihhsihgslh gvthhhihhnghhslhgrsgdrtghomhenucevlhhushhtvghrufhiiigvpedv X-ME-Proxy: From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= To: xen-devel@lists.xenproject.org Date: Sat, 28 Sep 2019 16:20:36 +0200 Message-Id: <66a544b7e292dfe227349ffcc75a0136ca27afb1.1569680095.git-series.marmarek@invisiblethingslab.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v8 3/4] libxl: attach PCI device to qemu only after setting pciback/pcifront X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Wei Liu Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" When qemu is running in stubdomain, handling "pci-ins" command will fail if pcifront is not initialized already. Fix this by sending such command only after confirming that pciback/front is running. Signed-off-by: Marek Marczykowski-G=C3=B3recki Reviewed-by: Anthony PERARD --- Changes in v2: - Fixed code style since previous version. Changes in v8: - rebase on staging - rework for async api --- tools/libxl/libxl_pci.c | 45 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index ac597a5..ba0287d 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -1012,6 +1012,9 @@ typedef struct pci_add_state { bool starting; void (*callback)(libxl__egc *, struct pci_add_state *, int rc); =20 + /* private to device_pci_add_stubdom_wait */ + libxl__ev_devstate pciback_ds; + /* private to do_pci_add */ libxl__xswait_state xswait; libxl__ev_qmp qmp; @@ -1487,6 +1490,10 @@ static int libxl_pcidev_assignable(libxl_ctx *ctx, l= ibxl_device_pci *pcidev) return i !=3D num; } =20 +static void device_pci_add_stubdom_wait(libxl__egc *egc, + pci_add_state *pas, int rc); +static void device_pci_add_stubdom_ready(libxl__egc *egc, + libxl__ev_devstate* ds, int rc); static void device_pci_add_stubdom_done(libxl__egc *egc, pci_add_state *, int rc); static void device_pci_add_done(libxl__egc *egc, @@ -1563,7 +1570,8 @@ void libxl__device_pci_add(libxl__egc *egc, uint32_t = domid, GCNEW(pcidev_s); libxl_device_pci_init(pcidev_s); libxl_device_pci_copy(CTX, pcidev_s, pcidev); - pas->callback =3D device_pci_add_stubdom_done; + pas->callback =3D device_pci_add_stubdom_wait; + do_pci_add(egc, stubdomid, pcidev_s, pas); /* must be last */ return; } @@ -1575,6 +1583,41 @@ out: device_pci_add_done(egc, pas, rc); /* must be last */ } =20 +static void device_pci_add_stubdom_wait(libxl__egc *egc, + pci_add_state *pas, + int rc) +{ + libxl__ao_device *aodev =3D pas->aodev; + STATE_AO_GC(aodev->ao); + libxl_ctx *ctx =3D libxl__gc_owner(gc); + int stubdomid =3D libxl_get_stubdom_id(ctx, pas->domid); + char *state_path; + + if (rc) goto out; + + /* Wait for the device actually being connected, otherwise device model + * running there will fail to find the device. */ + state_path =3D libxl__sprintf(gc, "%s/backend/pci/%d/0/state", + libxl__xs_get_dompath(gc, 0), stubdomid); + rc =3D libxl__ev_devstate_wait(aodev->ao, &pas->pciback_ds, + device_pci_add_stubdom_ready, + state_path, XenbusStateConnected, + LIBXL_DEVICE_MODEL_START_TIMEOUT * 1000); + if (rc) goto out; + return; +out: + device_pci_add_done(egc, pas, rc); /* must be last */ +} + +static void device_pci_add_stubdom_ready(libxl__egc *egc, + libxl__ev_devstate* ds, + int rc) +{ + pci_add_state *pas =3D CONTAINER_OF(ds, *pas, pciback_ds); + + device_pci_add_stubdom_done(egc, pas, rc); /* must be last */ +} + static void device_pci_add_stubdom_done(libxl__egc *egc, pci_add_state *pas, int rc) --=20 git-series 0.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri May 17 23:22:23 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1569680541; cv=none; d=zoho.com; s=zohoarc; b=HBC0JTAmzf0mpfAl6Q1MLwFVQlGNM65gWE0xBMI/dY70iTdpCayWXIdFSRS1SacH7lxjgPXQZdOQkQekl2U5XOsTMe9r347CWkNjwjXmegaC/KcPru4CEcKDJQFjEbi2XtDYai5VqHqsgYjfCK81rBH9RwIEmONvznODKGXQ37c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569680541; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=4whk4LiKdAztsRMiodecsJxCO2f4BPDOObpjqA+Abes=; b=gD0Y6rulpbQE03++/NC48LJujcwNScqGs6THvnoLqYEGxE9NoRgglaOhQuOhsQpTgZf1Y8YHEsvKU068qfcFO4PyxZkArreNwJYvI79gZlJmgttVXt+CuqcWjNUzZCcPYnVN/vISGKcMAEvPrT4Cb4jNaAiMi05ifyklrlWXUw0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 15696805416581.5208192507203648; Sat, 28 Sep 2019 07:22:21 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEDb5-0003kq-VK; Sat, 28 Sep 2019 14:21:19 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEDb4-0003jx-Ma for xen-devel@lists.xenproject.org; Sat, 28 Sep 2019 14:21:18 +0000 Received: from out5-smtp.messagingengine.com (unknown [66.111.4.29]) by localhost (Halon) with ESMTPS id 3b1c8f8c-e1fb-11e9-969b-12813bfff9fa; Sat, 28 Sep 2019 14:21:15 +0000 (UTC) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 8FEB321731; Sat, 28 Sep 2019 10:21:15 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sat, 28 Sep 2019 10:21:15 -0400 Received: from localhost.localdomain (ip5b412221.dynamic.kabel-deutschland.de [91.65.34.33]) by mail.messagingengine.com (Postfix) with ESMTPA id 7FDB5D6005F; Sat, 28 Sep 2019 10:21:14 -0400 (EDT) X-Inumbo-ID: 3b1c8f8c-e1fb-11e9-969b-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=wwYkWjrYfCujVde3AkWQVL4DLVVmqV5do1n+Or3fk wA=; b=FNF1SD/k8ydlYvYA5+EJ1t4Vl3vI43PDvRa6FhGs7YVcVfmMAyxqcWudm fnWrUlpja6WgQHC8f0ofVeIXKJLLrtnntPIenbIl8D2/ONeT9jeuBKYX+4OCZ3B6 WqBQmIz6Mji4N1g6yrQpykDKlHV/xFF7qctKWRuPX6cc2H7CDeswq21G9VYdv9ST KAgo8uqNj9RXEdJFbzkO36xUci+J/PjeP+WJ5ZGkTk/uMzcpKkFCyzf4HwIEiY1Z /c9el2ZfyPLT4C4TliVrUJtLspopjCz7YXwzLgyTwdPO5glKYvG/N/3JXyEQ/f9J zn8i+2KsW11tTsAe9tz9O3UoO9m6g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrfeekgdejgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpeforghrvghk ucforghrtgiihihkohifshhkihdqifpkrhgvtghkihcuoehmrghrmhgrrhgvkhesihhnvh hishhisghlvghthhhinhhgshhlrggsrdgtohhmqeenucfkphepledurdeihedrfeegrdef feenucfrrghrrghmpehmrghilhhfrhhomhepmhgrrhhmrghrvghksehinhhvihhsihgslh gvthhhihhnghhslhgrsgdrtghomhenucevlhhushhtvghrufhiiigvpedv X-ME-Proxy: From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= To: xen-devel@lists.xenproject.org Date: Sat, 28 Sep 2019 16:20:37 +0200 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v8 4/4] libxl: don't try to manipulate json config for stubdomain X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , Ian Jackson , Wei Liu , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Wei Liu Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Stubdomain do not have it's own config file - its configuration is derived from target domains. Do not try to manipulate it when attaching PCI device. This bug prevented starting HVM with stubdomain and PCI passthrough device attached. Signed-off-by: Marek Marczykowski-G=C3=B3recki Acked-by: Wei Liu --- Changes in v3: - skip libxl__dm_check_start too, as stubdomain is guaranteed to be running at this stage already - do not init d_config at all, as it is used only for json manipulation Changes in v4: - adjust comment style Changes in v8: - rebase on staging --- tools/libxl/libxl_pci.c | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index ba0287d..dc96163 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -126,8 +126,11 @@ static int libxl__device_pci_add_xenstore(libxl__gc *g= c, int rc; libxl_domain_config d_config; libxl__domain_userdata_lock *lock =3D NULL; + bool is_stubdomain =3D libxl_is_stubdom(CTX, domid, NULL); =20 - libxl_domain_config_init(&d_config); + /* Stubdomain doesn't have own config. */ + if (!is_stubdomain) + libxl_domain_config_init(&d_config); =20 be_path =3D libxl__domain_device_backend_path(gc, 0, domid, 0, LIBXL__DEVICE_KIND_PCI); @@ -153,27 +156,35 @@ static int libxl__device_pci_add_xenstore(libxl__gc *= gc, if (!starting) flexarray_append_pair(back, "state", GCSPRINTF("%d", XenbusStateRe= configuring)); =20 - lock =3D libxl__lock_domain_userdata(gc, domid); - if (!lock) { - rc =3D ERROR_LOCK_FAIL; - goto out; - } + /* + * Stubdomin config is derived from its target domain, it doesn't have + * its own file. + */ + if (!is_stubdomain) { + lock =3D libxl__lock_domain_userdata(gc, domid); + if (!lock) { + rc =3D ERROR_LOCK_FAIL; + goto out; + } =20 - rc =3D libxl__get_domain_configuration(gc, domid, &d_config); - if (rc) goto out; + rc =3D libxl__get_domain_configuration(gc, domid, &d_config); + if (rc) goto out; =20 - device_add_domain_config(gc, &d_config, &libxl__pcidev_devtype, - pcidev); + device_add_domain_config(gc, &d_config, &libxl__pcidev_devtype, + pcidev); =20 - rc =3D libxl__dm_check_start(gc, &d_config, domid); - if (rc) goto out; + rc =3D libxl__dm_check_start(gc, &d_config, domid); + if (rc) goto out; + } =20 for (;;) { rc =3D libxl__xs_transaction_start(gc, &t); if (rc) goto out; =20 - rc =3D libxl__set_domain_configuration(gc, domid, &d_config); - if (rc) goto out; + if (lock) { + rc =3D libxl__set_domain_configuration(gc, domid, &d_config); + if (rc) goto out; + } =20 libxl__xs_writev(gc, t, be_path, libxl__xs_kvs_of_flexarray(gc, ba= ck)); =20 @@ -185,7 +196,8 @@ static int libxl__device_pci_add_xenstore(libxl__gc *gc, out: libxl__xs_transaction_abort(gc, &t); if (lock) libxl__unlock_domain_userdata(lock); - libxl_domain_config_dispose(&d_config); + if (!is_stubdomain) + libxl_domain_config_dispose(&d_config); return rc; } =20 --=20 git-series 0.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel