From patchwork Tue Jan 22 19:26:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dann frazier X-Patchwork-Id: 156320 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7965296jaa; Tue, 22 Jan 2019 11:36:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN4KXwKaOmgxSldU9EJyrAQDaaoa94H2VJ1NpBvyyZ7CoU73hXdf+CJlKV3++zWAjYp6k0AP X-Received: by 2002:ac8:4405:: with SMTP id j5mr31930536qtn.295.1548185781927; Tue, 22 Jan 2019 11:36:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548185781; cv=none; d=google.com; s=arc-20160816; b=sTqRabHngmetFYORYXDU6TT94Z/hYb/4R7uLOdD4n322FnPIOqZyncCAL9muEKs4V8 c5x+zYKw5C5aKk7JJat1LsvCcugvpCxsTOSRwFDv/jWdt0TyCYsa5swavs8fJViEoWYW mymVI7LXGirMiCsrIFPLSFdpvNqPpGpI8U4lAOOXmjrQCBaUiwgyZufZsG8x8i70g263 s+EursuM9z5WRt3yTlEQcb2OURe9oeh52vPYdCikYtqnNbCjWEGdnTKjlcL2psA5l+fF bNCSJblLpPo7NreGU3BllyZ2/Cto3IKsSJSaQ7MYreaw9NTzeBiBGAuzIEyKpvuKqifV igxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=QedHYV7qIHX3OfGUOhXUhtCQCToAhz45A3FSSTApw2M=; b=gLV6vQjuAqmwEqk1XoHjYATbbvPLxLOrhdEvIlmvIKxgCRh79JeRaYOj2Rfbf/osio P/MbuGz5Adt7nC3+3cf0GRYr3k9UMlAnOZOS0RK1joHXnenJ8tRzz6C+rd3JJcELrcEu ZhOy2baCBDlt3sFZxfhXYdtFDBVjQ/sTFSWySZpfnk68+S+e2lEH4dbvxp8OymUbE5/j dcjXbTwTrSyzkVYlNoX1E5YBHYmRCuI2rbjuQzUd5JwpcS+eefSn1PEa7A8/cj2pSEq1 mQRNbaRplt7Gk1MP3fM77pLByUt/838uXuIJAS2/k8EjJpK5xuuP+2kXIQCvg3tzSMWZ 2gXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id h2si207165qkc.249.2019.01.22.11.36.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 11:36:21 -0800 (PST) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) 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(-) -- 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list 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) } 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 name"), ifname); @@ -1449,8 +1448,12 @@ virNetDevGetVirtualFunctionInfo(const char *vfname, char **pfname, *pfname = NULL; - 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; + } if (virNetDevSysfsFile(&pf_sysfs_path, *pfname, "device") < 0) goto cleanup; @@ -3178,8 +3181,12 @@ virNetDevSwitchdevFeature(const char *ifname, if ((is_vf = virNetDevIsVirtualFunction(ifname)) < 0) return ret; - if (is_vf == 1 && virNetDevGetPhysicalFunction(ifname, &pfname) < 0) - goto cleanup; + if (is_vf == 1) { + /* ignore error if PF does noto have netdev assigned + * in that case pfname == NULL */ + if (virNetDevGetPhysicalFunction(ifname, &pfname) < 0) + virResetLastError(); + } pci_device_ptr = pfname ? virNetDevGetPCIDevice(pfname) : virNetDevGetPCIDevice(ifname); From patchwork Tue Jan 22 19:26:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dann frazier X-Patchwork-Id: 156321 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7965396jaa; Tue, 22 Jan 2019 11:36:28 -0800 (PST) X-Google-Smtp-Source: ALg8bN6DLyaqUpfh9Q09gJEnQVVyiKAVLFPxEbvFxnWHw3cvNVjHBSqgxKDQZqtixCkdCfgKnrPC X-Received: by 2002:ac8:35eb:: with SMTP id l40mr33804772qtb.165.1548185787989; Tue, 22 Jan 2019 11:36:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548185787; cv=none; d=google.com; s=arc-20160816; b=DIDBKgBHWRNY9z6qKYDggZywkPrPGSc4KeVQStNXUqtRMCcYxRn0yGBaWeiBm5Fdmy 5+eZ3c/8GBSI9ez2biGiF1M+LGecZT4wdSkfLaGhstBz1y5QjHJ2jpax38KWzN691EYj DrxRrsKVzdhQxLn2rBuqnMJjW/G9RoJhKCp+eXOGIxvaGKk44cUS5kB2LbXE48f2xcef iydHBee/d4AecnDht4pHrwS9BGTtFYTAkGm7Bk+Q4+NXISDJ58XUVyFT4cfmqrI2DORd 3lkGdqIBh1ioCC8ccCjyghGCTRqaznLR+8sHYN7TPQ3eVDZAfZXdPCAhw7OH8Zhvv7Lg QFXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=lUe3TdnG1y8XcM4PpnfMeK8jq0CEz4Q0UhhiCaS5J5s=; b=XN8+wkECfsGzeyC4lnu3prsjo22hC+gkH20jixTdzShgBBZNFIsZ/BepIrBFox0bQ6 JrdWCQ49olfi0as+xX6aCKLjWrVl9xNzH5ywhssxJ6jZoLNxrKgIZ90EB5pM87o9KPk9 CBxGKcm4KeXqah6VisF8Feo5nmXl3M6lMUF/7aCsxxQ+pGecqkMOS5TWZEmSGdOYg92G QY1rU//K43fOQCM4g5p3KMxcWqJjgspLEy/bBZlpdtHA+8Z4+JVKLay2k3muVD8uc3V4 VdoKoywgJoM+s2Yx8SBvTpM/stdJqaTpLsKceRWyRDfMTVMxCNulc3OJm6gRNIG5MXqf MHwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id j25si5662627qtp.145.2019.01.22.11.36.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 11:36:27 -0800 (PST) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) 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(-) -- 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list 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 = NULL, *vf_sysfs_path = NULL; - int ret = -1; - + int ret; *pfname = NULL; if (virNetDevGetPhysicalFunction(vfname, pfname) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Cannot get PF netdev name for VF %s"), vfname); - return ret; + return -1; } - if (virNetDevSysfsFile(&pf_sysfs_path, *pfname, "device") < 0) - goto cleanup; - - if (virNetDevSysfsFile(&vf_sysfs_path, vfname, "device") < 0) - goto cleanup; + ret = virNetDevGetVirtualFunctionIndex(*pfname, vfname, vf); - ret = virPCIGetVirtualFunctionIndex(pf_sysfs_path, vf_sysfs_path, vf); - - cleanup: if (ret < 0) VIR_FREE(*pfname); - VIR_FREE(vf_sysfs_path); - VIR_FREE(pf_sysfs_path); - return ret; } @@ -1865,13 +1853,9 @@ virNetDevSaveNetConfig(const char *linkdev, int vf, * it to PF + VFname */ - if (virNetDevGetPhysicalFunction(linkdev, &pfDevOrig) < 0) + if (virNetDevGetVirtualFunctionInfo(linkdev, &pfDevOrig, &vf) < 0) goto cleanup; - pfDevName = pfDevOrig; - - if (virNetDevGetVirtualFunctionIndex(pfDevName, linkdev, &vf) < 0) - goto cleanup; } if (pfDevName) { @@ -2023,13 +2007,9 @@ virNetDevReadNetConfig(const char *linkdev, int vf, * it to PF + VFname */ - if (virNetDevGetPhysicalFunction(linkdev, &pfDevOrig) < 0) + if (virNetDevGetVirtualFunctionInfo(linkdev, &pfDevOrig, &vf) < 0) goto cleanup; - pfDevName = pfDevOrig; - - if (virNetDevGetVirtualFunctionIndex(pfDevName, linkdev, &vf) < 0) - goto cleanup; } /* 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 */ - if (virNetDevGetPhysicalFunction(linkdev, &pfDevOrig) < 0) + if (virNetDevGetVirtualFunctionInfo(linkdev, &pfDevOrig, &vf)) goto cleanup; - pfDevName = pfDevOrig; - - if (virNetDevGetVirtualFunctionIndex(pfDevName, linkdev, &vf) < 0) - goto cleanup; } From patchwork Tue Jan 22 19:26:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dann frazier X-Patchwork-Id: 156319 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7965110jaa; Tue, 22 Jan 2019 11:36:08 -0800 (PST) X-Google-Smtp-Source: ALg8bN7+/Hrf4rzdfpkc5xAShOW4WSOHmEGsijv8yHT1eVuMbWhFK8PHn6F7n034VT2JPVSKItN5 X-Received: by 2002:a0c:d933:: with SMTP id p48mr31524294qvj.15.1548185768819; Tue, 22 Jan 2019 11:36:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548185768; cv=none; d=google.com; s=arc-20160816; b=HYmsRhNKS2fi3O9L+te+h/IPJ9V5p6Tbh7wiRz8iTztQTyT0hwn+h2iKC3Jg6AlbHX NfCOrKhi1RiQ8DQUbDvASbBNcL6hKS2v6z19haZR3LLnlFUK5VkgeQBEIn0shmopsCiE 57gR6s5TnKtpwKY35cyBTz9u+HYMqN5JdO0QO98GIYRQ4UGeNyaIJuxtF5MVB+rVYt4w +k44tu4jTmwcQ9Ir6LD3b0ALh35RBtvO62QkdJd0nFwQ+3xfOXM3Hk5DoyT+DS0cCC6b vlgMecMRvRFxY2uttBrO15B0J1FR0otgDHjb5vDOPbvcSmvyOiP6j6WIdCxLjh9J+Tsp PQsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=4IUi00/hD+T9ne+TvaBRA7nb3ACxRSnXsg/JdhrT7BA=; b=vH2EOfxEtpTQgnfEomswxg0wivfpfLVRydl7772x3kSVcTHnpG+msV/PUfOnZ0CHbS PblvWNa9iL3qrhPXW405STR3ku1eXzgJPVrvVHq/F2dE0KHDTi9i4SX+lCIumIFA8vd1 /fDkutOy1IB9anu3bXoyGUrnU3hZ0R99vKf6qb/s6qI04WOFtJXyzH59TTa2gJexDZGB UzI5+kS+J2LSzENrQ3vjRJLGWhwv2ZoxRIkNeD95pfYS2yMa/LXlwt3BkcYDx4FK8GKd OywLsgtB3RfQlprT/0zELe9xaVAoULPrrGovIqjzsBmiqMHPWEN/f52ohG9R/N3YwWRu ethg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id f9si3209858qtq.274.2019.01.22.11.36.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 11:36:08 -0800 (PST) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) 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 strings with STREQ instead of STREQ_NULLABLE. Fixes: ac47e4a6225 (qemu: replace "def->nets[i]" with "net" and "def->sounds[i]" with "sound") Fixes: c7fc151eec7 (qemu: assign virtio devices to PCIe slot when appropriate) 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(-) -- 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list 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 = 0; i < def->nnets; i++) { virDomainNetDefPtr net = def->nets[i]; - if (net->model && - STREQ(net->model, "spapr-vlan")) { + if (STREQ_NULLABLE(net->model, "spapr-vlan")) net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO; - } if (qemuDomainAssignSpaprVIOAddress(def, &net->info, VIO_ADDR_NET) < 0) goto cleanup; @@ -322,8 +320,7 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def, for (i = 0; i < def->nnets; i++) { virDomainNetDefPtr net = def->nets[i]; - if (net->model && - STREQ(net->model, "virtio") && + if (STREQ_NULLABLE(net->model, "virtio") && net->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { net->info.type = type; } @@ -691,14 +688,14 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, * addresses for other hostdev devices. */ if (net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV || - STREQ(net->model, "usb-net")) { + STREQ_NULLABLE(net->model, "usb-net")) { return 0; } - if (STREQ(net->model, "virtio")) + if (STREQ_NULLABLE(net->model, "virtio")) return virtioFlags; - if (STREQ(net->model, "e1000e")) + if (STREQ_NULLABLE(net->model, "e1000e")) return pcieFlags; return pciFlags; From patchwork Tue Jan 22 19:26:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dann frazier X-Patchwork-Id: 156318 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7965024jaa; Tue, 22 Jan 2019 11:36:03 -0800 (PST) X-Google-Smtp-Source: ALg8bN4mHfvJC+Wt7leXyBXsEgRBewETeDjnO4fLbQTxjewGYfZ0kJg1dVmVxe3SMbYNfOiflhs9 X-Received: by 2002:ac8:3fc9:: with SMTP id v9mr32307288qtk.108.1548185763712; Tue, 22 Jan 2019 11:36:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548185763; cv=none; d=google.com; s=arc-20160816; b=tci+VcVcZ+alwj/uEbzXim0nF0nyK9bYHgvND/wBOIfiu2QIAsw1CAV6DOgeTvqOgC Ya2/BCBbV5XA0kaC+bMeY05y9dyArMc1l3p7AAdF7Hex+RUpBIthC2jJy0c/UBBSNdLi WgNy3LAMO0Uj3uZYLRyC+SUvRaNMRdF1pc1atb14P3Nh7RAG/1xTbwcP19yZ7lhjnPo8 nf9v5qBAZxvXklKzAtFKtscmormATthwac/Kl84Kmk42aGKXJMwRYRothyeZPAn1/UZf GrZ9M7D3x3FNCVXgmPI02K6T5xFWciKBqBzgV1dF0Uulz5J+DHVDnzv0Pq2QvbdkNGIM 0cEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=3Wn8UbZdu+9AMx2D35JdAikH8kj9J60B57wvSXA3Miw=; b=kgb98G1jTf7Rr1jnfaZBvCAyFWA1d4Ph2WZZ8C8t3S4ZKCCYYk0ZJGuwPCLxJB/6+G BF2p++sy35eMEpjxAbgWXoLBiLc0ZEDbweSRYIM+oNzkAvqMItp1dpyxk3dGlC4aJr/D sJfc5LO0C6yyBZpxQ1HNrXtSQGesWHMNVG5g/UsBM9ogHFFbRvqTPHKs/WB4vVTvOCmg YYOU2VM9m1fMsGi06rhBToEIyqNWVH/idyi6Me3F9uAdcnllGjz3tBupK92hXqKGl5hO g+3h+g+q9eczHgezIygaSAVhhjMdzk4z8eYWQKKJ8B2TPA8W6ciRrIkKL9Hye29iPSa0 1GLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id f24si1785294qvd.54.2019.01.22.11.36.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 11:36:03 -0800 (PST) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) 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(-) -- 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list 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; - if (!linkdev) { + if (!(*linkdev)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("The device at %s has no network device name"), sysfs_path);