From patchwork Wed Sep 25 02:41:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= X-Patchwork-Id: 11159935 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A88217EE for ; Wed, 25 Sep 2019 02:43:18 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3666F2146E for ; Wed, 25 Sep 2019 02:43:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="jBnWMIbV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3666F2146E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=invisiblethingslab.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCxFO-0000tC-E3; Wed, 25 Sep 2019 02:41:42 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCxFN-0000t3-5L for xen-devel@lists.xenproject.org; Wed, 25 Sep 2019 02:41:41 +0000 X-Inumbo-ID: fe8da3c2-df3d-11e9-bf31-bc764e2007e4 Received: from out2-smtp.messagingengine.com (unknown [66.111.4.26]) by localhost (Halon) with ESMTPS id fe8da3c2-df3d-11e9-bf31-bc764e2007e4; Wed, 25 Sep 2019 02:41:36 +0000 (UTC) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id BE683222E4; Tue, 24 Sep 2019 22:41:36 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Tue, 24 Sep 2019 22:41:36 -0400 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=pjHm9ceYnWR9V0AqmOopig5VJRNLK4kBvvWCoPBaS OE=; b=jBnWMIbVeD7N7kfdGlLixZ9VDGAAMPpHAPOY78UDrmJKS67GNV+xbdUhB Sfo/CRoNvvfCVzGVx/ij6XhW0kyMzbcCyWCAuAqzs1FukPHYOJWla9jw6yHERSxC Z6Lw+mShONi2fc7D/W5P0pe64vKXQMeuURkA8Y5zGjGqw1VMGLMR99PkUZjJD1t8 FLNU9RFjg9jyrbN6cwYbGGyBWetNK7JRfN8WHUCQbPNl6niFWyMhFGu4o1EeB0s+ hX66XYvKbJdRgEBxpTCiX6pz88+yNE+FEwEl0Qa5eC+Wnr9PNWcVcYoQtAFINvZE oLB0FSgfe09ubQKoFhf905B4FVh/Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrfedugdeivdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpeforghrvghk ucforghrtgiihihkohifshhkihdqifpkrhgvtghkihcuoehmrghrmhgrrhgvkhesihhnvh hishhisghlvghthhhinhhgshhlrggsrdgtohhmqeenucfkphepledurdeihedrfeegrdef feenucfrrghrrghmpehmrghilhhfrhhomhepmhgrrhhmrghrvghksehinhhvihhsihgslh gvthhhihhnghhslhgrsgdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from localhost.localdomain (ip5b412221.dynamic.kabel-deutschland.de [91.65.34.33]) by mail.messagingengine.com (Postfix) with ESMTPA id AB2AED6005A; Tue, 24 Sep 2019 22:41:35 -0400 (EDT) From: =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= To: xen-devel@lists.xenproject.org Date: Wed, 25 Sep 2019 04:41:25 +0200 Message-Id: <206c62834cf039074d95c869eebdec333471bf1f.1569379186.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 v7 3/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_Marczykowski-G=C3=B3recki?= , Wei Liu 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órecki 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 --- tools/libxl/libxl_pci.c | 50 ++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index 578535f..d26fc9a 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -120,10 +120,14 @@ static int libxl__device_pci_add_xenstore(libxl__gc *gc, uint32_t domid, libxl_d libxl_domain_config d_config; libxl_device_pci pcidev_saved; libxl__domain_userdata_lock *lock = NULL; + bool is_stubdomain = libxl_is_stubdom(CTX, domid, NULL); - libxl_domain_config_init(&d_config); - libxl_device_pci_init(&pcidev_saved); - libxl_device_pci_copy(CTX, &pcidev_saved, pcidev); + /* Stubdomain doesn't have own config. */ + if (!is_stubdomain) { + libxl_domain_config_init(&d_config); + libxl_device_pci_init(&pcidev_saved); + libxl_device_pci_copy(CTX, &pcidev_saved, pcidev); + } be_path = libxl__domain_device_backend_path(gc, 0, domid, 0, LIBXL__DEVICE_KIND_PCI); @@ -152,27 +156,35 @@ static int libxl__device_pci_add_xenstore(libxl__gc *gc, uint32_t domid, libxl_d GCNEW(device); libxl__device_from_pcidev(gc, domid, pcidev, device); - lock = libxl__lock_domain_userdata(gc, domid); - if (!lock) { - rc = ERROR_LOCK_FAIL; - goto out; - } + /* + * Stubdomin config is derived from its target domain, it doesn't have + * its own file. + */ + if (!is_stubdomain) { + lock = libxl__lock_domain_userdata(gc, domid); + if (!lock) { + rc = ERROR_LOCK_FAIL; + goto out; + } - rc = libxl__get_domain_configuration(gc, domid, &d_config); - if (rc) goto out; + rc = libxl__get_domain_configuration(gc, domid, &d_config); + if (rc) goto out; - device_add_domain_config(gc, &d_config, &libxl__pcidev_devtype, - &pcidev_saved); + device_add_domain_config(gc, &d_config, &libxl__pcidev_devtype, + &pcidev_saved); - rc = libxl__dm_check_start(gc, &d_config, domid); - if (rc) goto out; + rc = libxl__dm_check_start(gc, &d_config, domid); + if (rc) goto out; + } for (;;) { rc = libxl__xs_transaction_start(gc, &t); if (rc) goto out; - rc = libxl__set_domain_configuration(gc, domid, &d_config); - if (rc) goto out; + if (lock) { + rc = libxl__set_domain_configuration(gc, domid, &d_config); + if (rc) goto out; + } libxl__xs_writev(gc, t, be_path, libxl__xs_kvs_of_flexarray(gc, back)); @@ -184,8 +196,10 @@ static int libxl__device_pci_add_xenstore(libxl__gc *gc, uint32_t domid, libxl_d out: libxl__xs_transaction_abort(gc, &t); if (lock) libxl__unlock_domain_userdata(lock); - libxl_device_pci_dispose(&pcidev_saved); - libxl_domain_config_dispose(&d_config); + if (!is_stubdomain) { + libxl_device_pci_dispose(&pcidev_saved); + libxl_domain_config_dispose(&d_config); + } return rc; }