From nobody Sun May 5 04:27:59 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=fail(p=none dis=none) header.from=canonical.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1548185782205835.6333493301572; Tue, 22 Jan 2019 11:36:22 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 35CB637E88; Tue, 22 Jan 2019 19:36:20 +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 E6D01600C5; Tue, 22 Jan 2019 19:36:19 +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 5EA8E180339B; Tue, 22 Jan 2019 19:36:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0MJZu1D024873 for ; Tue, 22 Jan 2019 14:35:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id D89845C25A; Tue, 22 Jan 2019 19:35:56 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CAF885E1B0; Tue, 22 Jan 2019 19:35:53 +0000 (UTC) Received: from complete.lackof.org (complete.lackof.org [198.49.126.79]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 578F7C0495BA; Tue, 22 Jan 2019 19:35:51 +0000 (UTC) Received: from localhost (c-107-2-141-103.hsd1.co.comcast.net [107.2.141.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by complete.lackof.org (Postfix) with ESMTPSA id 812F633E019E; Tue, 22 Jan 2019 12:26:33 -0700 (MST) From: dann frazier To: libvir-list@redhat.com, Radoslaw Biernacki , Michal Privoznik Date: Tue, 22 Jan 2019 12:26:12 -0700 Message-Id: <20190122192615.9256-2-dann.frazier@canonical.com> In-Reply-To: <20190122192615.9256-1-dann.frazier@canonical.com> References: <20190122192615.9256-1-dann.frazier@canonical.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.100.2 at complete.lackof.org X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on complete.lackof.org X-Greylist: Delayed for 00:09:17 by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 22 Jan 2019 19:35:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 22 Jan 2019 19:35:51 +0000 (UTC) for IP:'198.49.126.79' DOMAIN:'complete.lackof.org' HELO:'complete.lackof.org' FROM:'dannf@dannf.org' RCPT:'' X-RedHat-Spam-Score: 0.001 (HEADER_FROM_DIFFERENT_DOMAINS) 198.49.126.79 complete.lackof.org 198.49.126.79 complete.lackof.org X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: laine@laine.org Subject: [libvirt] [PATCH v3 1/4] util: fixing wrong assumption that PF has to have netdev assigned 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-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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 22 Jan 2019 19:36:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Radoslaw Biernacki libvirt wrongly assumes that VF netdev has to have the netdev assigned to PF. There is no such requirement in SRIOV standard. This patch change the virNetDevSwitchdevFeature() function to deal with SRIOV devices which does not have netdev on PF. Also corrects one comment about PF netdev assumption. One example of such devices is ThunderX VNIC. By applying this change, VF device is used for virNetlinkCommand() as it is the only netdev assigned to VNIC. Signed-off-by: Radoslaw Biernacki [ dannf: Reinstated error path in virNetDevGetPhysicalFunction() as suggested by Michal Privoznik ] Signed-off-by: dann frazier --- src/util/virnetdev.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 2111b3ada9..82823c0dfc 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -1355,9 +1355,8 @@ virNetDevGetPhysicalFunction(const char *ifname, char= **pfname) } =20 if (!*pfname) { - /* this shouldn't be possible. A VF can't exist unless its - * PF device is bound to a network driver - */ + /* The SRIOV standard does not require VF netdevs to have the + netdev assigned to a PF */ virReportError(VIR_ERR_INTERNAL_ERROR, _("The PF device for VF %s has no network device na= me"), ifname); @@ -1449,8 +1448,12 @@ virNetDevGetVirtualFunctionInfo(const char *vfname, = char **pfname, =20 *pfname =3D NULL; =20 - if (virNetDevGetPhysicalFunction(vfname, pfname) < 0) + if (virNetDevGetPhysicalFunction(vfname, pfname) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Cannot get PF netdev name for VF %s"), + vfname); return ret; + } =20 if (virNetDevSysfsFile(&pf_sysfs_path, *pfname, "device") < 0) goto cleanup; @@ -3178,8 +3181,12 @@ virNetDevSwitchdevFeature(const char *ifname, if ((is_vf =3D virNetDevIsVirtualFunction(ifname)) < 0) return ret; =20 - if (is_vf =3D=3D 1 && virNetDevGetPhysicalFunction(ifname, &pfname) < = 0) - goto cleanup; + if (is_vf =3D=3D 1) { + /* ignore error if PF does noto have netdev assigned + * in that case pfname =3D=3D NULL */ + if (virNetDevGetPhysicalFunction(ifname, &pfname) < 0) + virResetLastError(); + } =20 pci_device_ptr =3D pfname ? virNetDevGetPCIDevice(pfname) : virNetDevGetPCIDevice(ifname); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 04:27:59 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=fail(p=none dis=none) header.from=canonical.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1548185788427843.5864104800916; Tue, 22 Jan 2019 11:36:28 -0800 (PST) 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 11DE87A19B; Tue, 22 Jan 2019 19:36:26 +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 C56871042557; Tue, 22 Jan 2019 19:36:25 +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 7664D18033CB; Tue, 22 Jan 2019 19:36:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0MJZuBr024874 for ; Tue, 22 Jan 2019 14:35:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id D7549103BAB9; Tue, 22 Jan 2019 19:35:56 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CD88F103BAAD; Tue, 22 Jan 2019 19:35:53 +0000 (UTC) Received: from complete.lackof.org (complete.lackof.org [198.49.126.79]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4297A132690; Tue, 22 Jan 2019 19:35:51 +0000 (UTC) Received: from localhost (c-107-2-141-103.hsd1.co.comcast.net [107.2.141.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by complete.lackof.org (Postfix) with ESMTPSA id D8F5333E023B; Tue, 22 Jan 2019 12:26:34 -0700 (MST) From: dann frazier To: libvir-list@redhat.com, Radoslaw Biernacki , Michal Privoznik Date: Tue, 22 Jan 2019 12:26:13 -0700 Message-Id: <20190122192615.9256-3-dann.frazier@canonical.com> In-Reply-To: <20190122192615.9256-1-dann.frazier@canonical.com> References: <20190122192615.9256-1-dann.frazier@canonical.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.100.2 at complete.lackof.org X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on complete.lackof.org X-Greylist: Delayed for 00:09:17 by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 22 Jan 2019 19:35:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 22 Jan 2019 19:35:51 +0000 (UTC) for IP:'198.49.126.79' DOMAIN:'complete.lackof.org' HELO:'complete.lackof.org' FROM:'dannf@dannf.org' RCPT:'' X-RedHat-Spam-Score: 0.001 (HEADER_FROM_DIFFERENT_DOMAINS) 198.49.126.79 complete.lackof.org 198.49.126.79 complete.lackof.org X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: laine@laine.org Subject: [libvirt] [PATCH v3 2/4] util: Code simplification 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-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.28]); Tue, 22 Jan 2019 19:36:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Radoslaw Biernacki Removing redundant sections of the code Signed-off-by: Radoslaw Biernacki [ dannf: Add missing free of *pfname in error path and use proper < 0 comparison when checking return for errors, both suggested by Michal Privoznik ] Signed-off-by: dann frazier --- src/util/virnetdev.c | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 82823c0dfc..5571a10865 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -1443,33 +1443,21 @@ int virNetDevGetVirtualFunctionInfo(const char *vfname, char **pfname, int *vf) { - char *pf_sysfs_path =3D NULL, *vf_sysfs_path =3D NULL; - int ret =3D -1; - + int ret; *pfname =3D NULL; =20 if (virNetDevGetPhysicalFunction(vfname, pfname) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Cannot get PF netdev name for VF %s"), vfname); - return ret; + return -1; } =20 - if (virNetDevSysfsFile(&pf_sysfs_path, *pfname, "device") < 0) - goto cleanup; - - if (virNetDevSysfsFile(&vf_sysfs_path, vfname, "device") < 0) - goto cleanup; + ret =3D virNetDevGetVirtualFunctionIndex(*pfname, vfname, vf); =20 - ret =3D virPCIGetVirtualFunctionIndex(pf_sysfs_path, vf_sysfs_path, vf= ); - - cleanup: if (ret < 0) VIR_FREE(*pfname); =20 - VIR_FREE(vf_sysfs_path); - VIR_FREE(pf_sysfs_path); - return ret; } =20 @@ -1865,13 +1853,9 @@ virNetDevSaveNetConfig(const char *linkdev, int vf, * it to PF + VFname */ =20 - if (virNetDevGetPhysicalFunction(linkdev, &pfDevOrig) < 0) + if (virNetDevGetVirtualFunctionInfo(linkdev, &pfDevOrig, &vf) < 0) goto cleanup; - pfDevName =3D pfDevOrig; - - if (virNetDevGetVirtualFunctionIndex(pfDevName, linkdev, &vf) < 0) - goto cleanup; } =20 if (pfDevName) { @@ -2023,13 +2007,9 @@ virNetDevReadNetConfig(const char *linkdev, int vf, * it to PF + VFname */ =20 - if (virNetDevGetPhysicalFunction(linkdev, &pfDevOrig) < 0) + if (virNetDevGetVirtualFunctionInfo(linkdev, &pfDevOrig, &vf) < 0) goto cleanup; - pfDevName =3D pfDevOrig; - - if (virNetDevGetVirtualFunctionIndex(pfDevName, linkdev, &vf) < 0) - goto cleanup; } =20 /* if there is a PF, it's now in pfDevName, and linkdev is either @@ -2228,13 +2208,9 @@ virNetDevSetNetConfig(const char *linkdev, int vf, * it to PF + VFname */ =20 - if (virNetDevGetPhysicalFunction(linkdev, &pfDevOrig) < 0) + if (virNetDevGetVirtualFunctionInfo(linkdev, &pfDevOrig, &vf)) goto cleanup; - pfDevName =3D pfDevOrig; - - if (virNetDevGetVirtualFunctionIndex(pfDevName, linkdev, &vf) < 0) - goto cleanup; } =20 =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 04:27:59 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=fail(p=none dis=none) header.from=canonical.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1548185769343377.8962766801768; Tue, 22 Jan 2019 11:36:09 -0800 (PST) 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 AAFB27F6B3; Tue, 22 Jan 2019 19:36:01 +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 0E4931019626; Tue, 22 Jan 2019 19:36:01 +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 742063F603; Tue, 22 Jan 2019 19:35:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0MJZuca024863 for ; Tue, 22 Jan 2019 14:35:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6642B103BAAD; Tue, 22 Jan 2019 19:35:56 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B9E11048111; Tue, 22 Jan 2019 19:35:53 +0000 (UTC) Received: from complete.lackof.org (complete.lackof.org [198.49.126.79]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4AC1C13A5C; Tue, 22 Jan 2019 19:35:51 +0000 (UTC) Received: from localhost (c-107-2-141-103.hsd1.co.comcast.net [107.2.141.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by complete.lackof.org (Postfix) with ESMTPSA id 8CA4733E0255; Tue, 22 Jan 2019 12:26:35 -0700 (MST) From: dann frazier To: libvir-list@redhat.com, Radoslaw Biernacki , Michal Privoznik Date: Tue, 22 Jan 2019 12:26:14 -0700 Message-Id: <20190122192615.9256-4-dann.frazier@canonical.com> In-Reply-To: <20190122192615.9256-1-dann.frazier@canonical.com> References: <20190122192615.9256-1-dann.frazier@canonical.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.100.2 at complete.lackof.org X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on complete.lackof.org X-Greylist: Delayed for 00:09:17 by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 22 Jan 2019 19:35:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 22 Jan 2019 19:35:51 +0000 (UTC) for IP:'198.49.126.79' DOMAIN:'complete.lackof.org' HELO:'complete.lackof.org' FROM:'dannf@dannf.org' RCPT:'' X-RedHat-Spam-Score: 0.001 (HEADER_FROM_DIFFERENT_DOMAINS) 198.49.126.79 complete.lackof.org 198.49.126.79 complete.lackof.org X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: laine@laine.org Subject: [libvirt] [PATCH v3 3/4] util: Fix for NULL dereference 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-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.25]); Tue, 22 Jan 2019 19:36:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Radoslaw Biernacki The device xml parser code does not set "model" while parsing
virDomainDefPtr def->nets[i]->model can be NULL while latter compares strin= gs with STREQ instead of STREQ_NULLABLE. Fixes: ac47e4a6225 (qemu: replace "def->nets[i]" with "net" and "def->sound= s[i]" with "sound") Fixes: c7fc151eec7 (qemu: assign virtio devices to PCIe slot when appropria= te) Signed-off-by: Radoslaw Biernacki Reviewed-by: Michal Privoznik Signed-off-by: dann frazier --- src/qemu/qemu_domain_address.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index bd6c4031e0..9e0b50d41e 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -230,10 +230,8 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def) for (i =3D 0; i < def->nnets; i++) { virDomainNetDefPtr net =3D def->nets[i]; =20 - if (net->model && - STREQ(net->model, "spapr-vlan")) { + if (STREQ_NULLABLE(net->model, "spapr-vlan")) net->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO; - } =20 if (qemuDomainAssignSpaprVIOAddress(def, &net->info, VIO_ADDR_NET)= < 0) goto cleanup; @@ -322,8 +320,7 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr de= f, for (i =3D 0; i < def->nnets; i++) { virDomainNetDefPtr net =3D def->nets[i]; =20 - if (net->model && - STREQ(net->model, "virtio") && + if (STREQ_NULLABLE(net->model, "virtio") && net->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { net->info.type =3D type; } @@ -691,14 +688,14 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDev= iceDefPtr dev, * addresses for other hostdev devices. */ if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_HOSTDEV || - STREQ(net->model, "usb-net")) { + STREQ_NULLABLE(net->model, "usb-net")) { return 0; } =20 - if (STREQ(net->model, "virtio")) + if (STREQ_NULLABLE(net->model, "virtio")) return virtioFlags; =20 - if (STREQ(net->model, "e1000e")) + if (STREQ_NULLABLE(net->model, "e1000e")) return pcieFlags; =20 return pciFlags; --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 04:27:59 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=fail(p=none dis=none) header.from=canonical.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1548185764444909.3561175923817; Tue, 22 Jan 2019 11:36:04 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A91C3A789F; Tue, 22 Jan 2019 19:36:01 +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 13EF26A6B3; Tue, 22 Jan 2019 19:36:01 +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 752793F604; Tue, 22 Jan 2019 19:35:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0MJZugK024858 for ; Tue, 22 Jan 2019 14:35:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1C2816A6B3; Tue, 22 Jan 2019 19:35:56 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 118615D9C7; Tue, 22 Jan 2019 19:35:53 +0000 (UTC) Received: from complete.lackof.org (complete.lackof.org [198.49.126.79]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3E71E8B104; Tue, 22 Jan 2019 19:35:51 +0000 (UTC) Received: from localhost (c-107-2-141-103.hsd1.co.comcast.net [107.2.141.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by complete.lackof.org (Postfix) with ESMTPSA id 428B333E0256; Tue, 22 Jan 2019 12:26:36 -0700 (MST) From: dann frazier To: libvir-list@redhat.com, Radoslaw Biernacki , Michal Privoznik Date: Tue, 22 Jan 2019 12:26:15 -0700 Message-Id: <20190122192615.9256-5-dann.frazier@canonical.com> In-Reply-To: <20190122192615.9256-1-dann.frazier@canonical.com> References: <20190122192615.9256-1-dann.frazier@canonical.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.100.2 at complete.lackof.org X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on complete.lackof.org X-Greylist: Delayed for 00:09:17 by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 22 Jan 2019 19:35:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 22 Jan 2019 19:35:51 +0000 (UTC) for IP:'198.49.126.79' DOMAIN:'complete.lackof.org' HELO:'complete.lackof.org' FROM:'dannf@dannf.org' RCPT:'' X-RedHat-Spam-Score: 0.001 (HEADER_FROM_DIFFERENT_DOMAINS) 198.49.126.79 complete.lackof.org 198.49.126.79 complete.lackof.org X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: laine@laine.org Subject: [libvirt] [PATCH v3 4/4] util: Fixing invalid error checking from virPCIGetNetname() 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-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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 22 Jan 2019 19:36:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Radoslaw Biernacki linkdev is In/Out function parameter as second order reference pointer so requires first order dereference for checking NULLs which can be a result from virPCIGetNetName() Fixes: d6ee56d7237 (util: change virPCIGetNetName() to not return error if = device has no net name) Signed-off-by: Radoslaw Biernacki Reviewed-by: Michal Privoznik Signed-off-by: dann frazier --- src/util/virhostdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index 41d4e8d936..880ca083d4 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -314,7 +314,7 @@ virHostdevNetDevice(virDomainHostdevDefPtr hostdev, if (virPCIGetNetName(sysfs_path, 0, NULL, linkdev) < 0) return -1; =20 - if (!linkdev) { + if (!(*linkdev)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("The device at %s has no network device name"= ), sysfs_path); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list