From nobody Thu Mar 28 20:42:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565703900; cv=none; d=zoho.com; s=zohoarc; b=Op83pdLjrhaE1jIr3Hl+xFhOGEVezkwKu516eco9tNdUASkQDPHTPzCw2H2rx4ixlLRhUaRDWVB8nsV8AqS2juIFhclmnID9CHOcxPi+dw1ls6/JNXc0+M6URUG739HfP69PK/hkkXY39a+9ZU2o6hoD/TzMPaeYUSHN0vSa7k8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565703900; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Y7vAhB5Tb4tEYvMnVwmExYe12gfLRu69A6Vqy+gi1vw=; b=mJsqAIzUWfcqNrugFb0GkoGXq8ZBr+BfjUPIWMzarlb3gnT0QywLauEre14RzljzOdbiEQh43WHm9HAORj+d+2xlkXj6h/k20FVAI27vrH9d3KhJ0pxnViYVGPwJCl2Y8su8cSvNkjfhWihWA5L/O2oNlduMIsRxWjuUUjBs92w= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565703900437378.1537939244853; Tue, 13 Aug 2019 06:45:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 51ED3307D848; Tue, 13 Aug 2019 13:44:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 27B39289BD; Tue, 13 Aug 2019 13:44:59 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E2372180BA9B; Tue, 13 Aug 2019 13:44:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7DDid1L004598 for ; Tue, 13 Aug 2019 09:44:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 69A66271AA; Tue, 13 Aug 2019 13:44:39 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-22.brq.redhat.com [10.40.200.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC3DC271A6 for ; Tue, 13 Aug 2019 13:44:38 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 13 Aug 2019 15:45:15 +0200 Message-Id: <223b56009be49179e977c0bfbd57cfab5f8ada12.1565703264.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/5] util: introduce virPCIDeviceConfigOpenInternal X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 13 Aug 2019 13:44:59 +0000 (UTC) A thin wrapper to allow creating new functions. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/virpci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/util/virpci.c b/src/util/virpci.c index 61a6b359e5..f4be907a10 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -291,7 +291,7 @@ virPCIDeviceGetDriverPathAndName(virPCIDevicePtr dev, c= har **path, char **name) =20 =20 static int -virPCIDeviceConfigOpen(virPCIDevicePtr dev, bool fatal) +virPCIDeviceConfigOpenInternal(virPCIDevicePtr dev, bool fatal) { int fd; =20 @@ -314,6 +314,12 @@ virPCIDeviceConfigOpen(virPCIDevicePtr dev, bool fatal) return fd; } =20 +static int +virPCIDeviceConfigOpen(virPCIDevicePtr dev, bool fatal) +{ + return virPCIDeviceConfigOpenInternal(dev, fatal); +} + static void virPCIDeviceConfigClose(virPCIDevicePtr dev, int cfgfd) { --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 20:42:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565703885; cv=none; d=zoho.com; s=zohoarc; b=aoocLtHeY1xXxvw/sLzoIddapWm9ZHIVqRad90+B3d59igBTnveUzKj4aIcfC65MwEgk2uuj08WOgobNXlYeG4UbMvCD2W0I14W5Qi9OSFc/Ye8WipaBS0wK6sk87/BrVN+uzHXTdRLZrl0pcKSURMOie+9qYjnhEGSFc4KOfWo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565703885; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=qG9X36EGPSdYm6ryUx34pR6b2nxVcnpjGETtyvJDTio=; b=dTo4dbRVHypS8ksMX/T/DlirXSi62OImGSFTj21qfGUHEMQRtiB8KMZihinn3E2ZEcoxGo6iBrcFxDEf3QTMvSfdJmWlEgqTE8O/GTRlhkW9N4b6GPKF0kwS1iSIb3Usz9TWrHMyOj4CWNS8Wx9UrP70Q18krB8m+Hh6BIZDhng= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565703885794346.98511103914404; Tue, 13 Aug 2019 06:44:45 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8E13F3082145; Tue, 13 Aug 2019 13:44:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5969337DE; Tue, 13 Aug 2019 13:44:44 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 79DF718005B9; Tue, 13 Aug 2019 13:44:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7DDie0L004604 for ; Tue, 13 Aug 2019 09:44:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 72129271A6; Tue, 13 Aug 2019 13:44:40 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-22.brq.redhat.com [10.40.200.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDCD7271AA for ; Tue, 13 Aug 2019 13:44:39 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 13 Aug 2019 15:45:16 +0200 Message-Id: <92df539b70bef2966ce346efa4ed381ea06ea1fe.1565703264.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/5] util: Introduce virPCIDeviceConfigOpenWrite X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 13 Aug 2019 13:44:45 +0000 (UTC) Only a handful of function need write access to the PCI config space. Create a wrapper function for those so that we can open it read only by default. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/virpci.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/util/virpci.c b/src/util/virpci.c index f4be907a10..c1dad1e69f 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -320,6 +320,12 @@ virPCIDeviceConfigOpen(virPCIDevicePtr dev, bool fatal) return virPCIDeviceConfigOpenInternal(dev, fatal); } =20 +static int +virPCIDeviceConfigOpenWrite(virPCIDevicePtr dev) +{ + return virPCIDeviceConfigOpenInternal(dev, true); +} + static void virPCIDeviceConfigClose(virPCIDevicePtr dev, int cfgfd) { @@ -808,7 +814,7 @@ virPCIDeviceTrySecondaryBusReset(virPCIDevicePtr dev, dev->name); return -1; } - if ((parentfd =3D virPCIDeviceConfigOpen(parent, true)) < 0) + if ((parentfd =3D virPCIDeviceConfigOpenWrite(parent)) < 0) goto out; =20 VIR_DEBUG("%s %s: doing a secondary bus reset", dev->id, dev->name); @@ -957,7 +963,7 @@ virPCIDeviceReset(virPCIDevicePtr dev, } VIR_DEBUG("Resetting device %s", dev->name); =20 - if ((fd =3D virPCIDeviceConfigOpen(dev, true)) < 0) + if ((fd =3D virPCIDeviceConfigOpenWrite(dev)) < 0) goto cleanup; =20 if (virPCIDeviceInit(dev, fd) < 0) --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 20:42:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565703900; cv=none; d=zoho.com; s=zohoarc; b=SZHa/b1Rx3YxurrYAosFOIAbPdp374KNQfuvnXf7vb6cJ44MJfIlk/Ajl8KaMhF6AY8wHfHPHoKVQ6aPg/QCDihHjxNVBRU9zKTLnTKutRq8JrtE9p8Dtj8hsYvGnQO3Plv9sIcO5gOvgTVy8Ij2+me733nfTi606Zou+S6ROOQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565703900; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=WhVIqnbakUpgP7oQUMplq+DB0xAPqkAjVIKdY7VP5fo=; b=KNoxorY5twDBuNkA1z/bXiMtWcfjuAWTXI0Two01TnrbNV5Qj47XFCcq8qGDaet/58v/tSJ7eiC7SzjaQwPAqqMPcw2gl9jAodwFhm5vEeu3cXZWgDn8y7U6oTPjTCZycCqMI5OZWYP/W6/KKi5IY0nm5h9QfZw10bj8CtjoM8E= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565703900587842.5580774968898; Tue, 13 Aug 2019 06:45:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 44ABCC010883; Tue, 13 Aug 2019 13:44:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1D5DF272D4; Tue, 13 Aug 2019 13:44:59 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DCD4E6B4B3; Tue, 13 Aug 2019 13:44:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7DDifd9004613 for ; Tue, 13 Aug 2019 09:44:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7D3A2271A6; Tue, 13 Aug 2019 13:44:41 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-22.brq.redhat.com [10.40.200.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id DADAA28D02 for ; Tue, 13 Aug 2019 13:44:40 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 13 Aug 2019 15:45:17 +0200 Message-Id: <57f34d73cd1d275a11174a5a40d679d3faf2f26c.1565703264.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/5] util: introduce readonly attribute to virPCIDeviceConfigOpenInternal X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 13 Aug 2019 13:44:59 +0000 (UTC) Allow wrappers to open PCI config as read-only. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/virpci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/virpci.c b/src/util/virpci.c index c1dad1e69f..e45dfbc631 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -291,11 +291,11 @@ virPCIDeviceGetDriverPathAndName(virPCIDevicePtr dev,= char **path, char **name) =20 =20 static int -virPCIDeviceConfigOpenInternal(virPCIDevicePtr dev, bool fatal) +virPCIDeviceConfigOpenInternal(virPCIDevicePtr dev, bool readonly, bool fa= tal) { int fd; =20 - fd =3D open(dev->path, O_RDWR); + fd =3D open(dev->path, readonly ? O_RDONLY : O_RDWR); =20 if (fd < 0) { if (fatal) { @@ -317,13 +317,13 @@ virPCIDeviceConfigOpenInternal(virPCIDevicePtr dev, b= ool fatal) static int virPCIDeviceConfigOpen(virPCIDevicePtr dev, bool fatal) { - return virPCIDeviceConfigOpenInternal(dev, fatal); + return virPCIDeviceConfigOpenInternal(dev, false, fatal); } =20 static int virPCIDeviceConfigOpenWrite(virPCIDevicePtr dev) { - return virPCIDeviceConfigOpenInternal(dev, true); + return virPCIDeviceConfigOpenInternal(dev, false, true); } =20 static void --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 20:42:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565703887; cv=none; d=zoho.com; s=zohoarc; b=kMa6+HUH953IzRJ4vMNEJZDktKra/Xlwys+GBcguwfrRlDw8ylpah0uE/CY8QaJUPir0nw0Nu4pHI+4fkgaJPZ/pIp0/i8tl00Kt5Ryh12F1+BO36pGAPnWCTUKYJuxpgV/pOvsM0nFkLDrfve6/PP84oa/0TrLSh1KapbP54ks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565703887; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=gthMgcAVTVwxSZM42zC+ajM4eT2DDQKepuxnpfslCt0=; b=F0CnzFe3IfBcUcXzsHAe6mjtbyxF4xfNtRv+nqJoV64kj8FuzjmrCD4m/O01EEHKvPhZqO3TQ9quhFG9DilOewHkvbhKUPFcmm/+It98TgbBkGJlsCf52wr4guAqg5CWipk/Pgv88UJZN5AlFjyY/z4fVyqfSKVuf2kPasGNyNk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565703887182580.4481925073678; Tue, 13 Aug 2019 06:44:47 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D986B307D84B; Tue, 13 Aug 2019 13:44:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B587510013A1; Tue, 13 Aug 2019 13:44:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7C6996B4A9; Tue, 13 Aug 2019 13:44:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7DDigIn004626 for ; Tue, 13 Aug 2019 09:44:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 88292271A6; Tue, 13 Aug 2019 13:44:42 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-22.brq.redhat.com [10.40.200.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id E3FA1272D4 for ; Tue, 13 Aug 2019 13:44:41 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 13 Aug 2019 15:45:18 +0200 Message-Id: <59a128ec0e19a6c54e5009fb71a12cd0bd2f75fb.1565703264.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/5] util: introduce virPCIDeviceConfigOpenTry X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 13 Aug 2019 13:44:46 +0000 (UTC) For callers that only need read-only access and don't want an error reported. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/virpci.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/util/virpci.c b/src/util/virpci.c index e45dfbc631..2758ee6f49 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -320,6 +320,12 @@ virPCIDeviceConfigOpen(virPCIDevicePtr dev, bool fatal) return virPCIDeviceConfigOpenInternal(dev, false, fatal); } =20 +static int +virPCIDeviceConfigOpenTry(virPCIDevicePtr dev) +{ + return virPCIDeviceConfigOpenInternal(dev, true, false); +} + static int virPCIDeviceConfigOpenWrite(virPCIDevicePtr dev) { @@ -692,7 +698,7 @@ virPCIDeviceIsParent(virPCIDevicePtr dev, virPCIDeviceP= tr check, void *data) if (dev->address.domain !=3D check->address.domain) return 0; =20 - if ((fd =3D virPCIDeviceConfigOpen(check, false)) < 0) + if ((fd =3D virPCIDeviceConfigOpenTry(check)) < 0) return 0; =20 /* Is it a bridge? */ @@ -740,7 +746,7 @@ virPCIDeviceIsParent(virPCIDevicePtr dev, virPCIDeviceP= tr check, void *data) int bestfd; uint8_t best_secondary; =20 - if ((bestfd =3D virPCIDeviceConfigOpen(*best, false)) < 0) + if ((bestfd =3D virPCIDeviceConfigOpenTry(*best)) < 0) goto cleanup; best_secondary =3D virPCIDeviceRead8(*best, bestfd, PCI_SECOND= ARY_BUS); virPCIDeviceConfigClose(*best, bestfd); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 20:42:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565703900; cv=none; d=zoho.com; s=zohoarc; b=BoscIMz1w8ACre5KawSVKaQ7W5rSjXJ5w1CR+ixgn/3mbS5Z+hXpAH7SvxXVoZSC4UzjxCCJuE4ELFFoA0drhmOCG82fmv4DtswjcGR44bXqZX64pQfER2KzwP8vKj7b+bw7wozgqmjdFHK25P+10O/0bDiMQqdAkeS6BMvJkDk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565703900; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=nrpRpFpkjTGdmVxDoQrZEcrlOFj5XPLXIR8U4GK0ufY=; b=DsMKccYaaB2T4gULwYWQmf2TLQFHYUuFofl3Z4THPAHy8MDJ8DBjDhL0u8xbQ5oeRKDZOpcOhmj/149/jZfSCLpdyadLx18yXYjqCyc0juZNg70S6aFVmnn9t6Yntma5JfB464LKvYSkZa54TXFXv3/T+Odq+kAqLYYCjYsbGS0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565703900703234.2277998523274; Tue, 13 Aug 2019 06:45:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 431E9693F3; Tue, 13 Aug 2019 13:44:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2003B6092F; Tue, 13 Aug 2019 13:44:59 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DE50E180BA9A; Tue, 13 Aug 2019 13:44:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7DDihNO004634 for ; Tue, 13 Aug 2019 09:44:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 94213271A6; Tue, 13 Aug 2019 13:44:43 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-22.brq.redhat.com [10.40.200.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04F9428D02 for ; Tue, 13 Aug 2019 13:44:42 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 13 Aug 2019 15:45:19 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/5] util: default to read-only in virPCIDeviceConfigOpen X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 13 Aug 2019 13:44:59 +0000 (UTC) All the callers left require virPCIDeviceConfigOpen to be fatal and only use read-only access to the config file. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/virpci.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/util/virpci.c b/src/util/virpci.c index 2758ee6f49..7ca755c1a8 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -315,9 +315,9 @@ virPCIDeviceConfigOpenInternal(virPCIDevicePtr dev, boo= l readonly, bool fatal) } =20 static int -virPCIDeviceConfigOpen(virPCIDevicePtr dev, bool fatal) +virPCIDeviceConfigOpen(virPCIDevicePtr dev) { - return virPCIDeviceConfigOpenInternal(dev, false, fatal); + return virPCIDeviceConfigOpenInternal(dev, true, true); } =20 static int @@ -2426,7 +2426,7 @@ virPCIDeviceDownstreamLacksACS(virPCIDevicePtr dev) int ret =3D 0; uint16_t device_class; =20 - if ((fd =3D virPCIDeviceConfigOpen(dev, true)) < 0) + if ((fd =3D virPCIDeviceConfigOpen(dev)) < 0) return -1; =20 if (virPCIDeviceInit(dev, fd) < 0) { @@ -3168,7 +3168,7 @@ virPCIDeviceIsPCIExpress(virPCIDevicePtr dev) int fd; int ret =3D -1; =20 - if ((fd =3D virPCIDeviceConfigOpen(dev, true)) < 0) + if ((fd =3D virPCIDeviceConfigOpen(dev)) < 0) return ret; =20 if (virPCIDeviceInit(dev, fd) < 0) @@ -3188,7 +3188,7 @@ virPCIDeviceHasPCIExpressLink(virPCIDevicePtr dev) int ret =3D -1; uint16_t cap, type; =20 - if ((fd =3D virPCIDeviceConfigOpen(dev, true)) < 0) + if ((fd =3D virPCIDeviceConfigOpen(dev)) < 0) return ret; =20 if (virPCIDeviceInit(dev, fd) < 0) @@ -3216,7 +3216,7 @@ virPCIDeviceGetLinkCapSta(virPCIDevicePtr dev, int fd; int ret =3D -1; =20 - if ((fd =3D virPCIDeviceConfigOpen(dev, true)) < 0) + if ((fd =3D virPCIDeviceConfigOpen(dev)) < 0) return ret; =20 if (virPCIDeviceInit(dev, fd) < 0) @@ -3254,7 +3254,7 @@ int virPCIGetHeaderType(virPCIDevicePtr dev, int *hdr= Type) =20 *hdrType =3D -1; =20 - if ((fd =3D virPCIDeviceConfigOpen(dev, true)) < 0) + if ((fd =3D virPCIDeviceConfigOpen(dev)) < 0) return -1; =20 type =3D virPCIDeviceRead8(dev, fd, PCI_HEADER_TYPE); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list