From nobody Wed May 8 01:34:36 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; dkim=fail; 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=linaro.org Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1542488964827141.62134666005068; Sat, 17 Nov 2018 13:09:24 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 78796C049597; Sat, 17 Nov 2018 21:09:22 +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 4266917249; Sat, 17 Nov 2018 21:09:22 +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 D70F93F953; Sat, 17 Nov 2018 21:09:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAHJpO33029177 for ; Sat, 17 Nov 2018 14:51:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6CC3765F57; Sat, 17 Nov 2018 19:51:24 +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 6434365F48 for ; Sat, 17 Nov 2018 19:51:22 +0000 (UTC) Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E4B2E4E916 for ; Sat, 17 Nov 2018 19:51:20 +0000 (UTC) Received: by mail-ed1-f66.google.com with SMTP id f23so13068181edb.3 for ; Sat, 17 Nov 2018 11:51:20 -0800 (PST) Received: from rad-H81M-S1.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id s12sm7887633edb.43.2018.11.17.11.51.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Nov 2018 11:51:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=V4omFcjws/Z/+/+Zs4WSRpsJOEsX4CGTL83qjq0bh2o=; b=AWPxVvusEyIM+yqwDQv4LwnBl6Mw+GLYdFFjKgzW0kd4pMMLPjneGmI79nr8fEEPLP hQXPJlRluIEtZGl/pFjECMF/szTd7O/eo1h2III//seOCxr7tByQffSMT298poAegafP teH374CalvM0Smv3Ib3X8KL+c5Z59+nXrRbXQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=V4omFcjws/Z/+/+Zs4WSRpsJOEsX4CGTL83qjq0bh2o=; b=tscQ6Q3vsHIiCtSIX9Jlp0y6VghT7OaTVPXzXo0pC/KbzQRjOvemqCj8DhKBkWzrxQ JzXegWWYKzVp6QodpE3ThKvpIPQg62hZfn+3VA6J4oN4WeQiInnCSR8HOwUT5OOvqUYR JtKFtFaeNn9S8gkHIshLsmVRPpzK6keUBBMYB6q2ALjM2wRDgW2Koh9IfCRMk1RvCXED XOTSzilB/3qZUiaWwL/ysFtG/uIpdVeWbGW5VML7BUg1JtWqqO8ltAlsTNroUZ18ayGZ QAoMZTewgb/xP/2WsJRd1+e+g+9ttg0wW5vtP0KYEQmv6eNrGvU/fyFdP1eCFgsfxCkq prKw== X-Gm-Message-State: AGRZ1gKqxd8Pi1tzrVtbmT7IuqGIGORQY8b3zLtBG0ruzI2+wk171nfP Md4y9k3sD5Lu/+XBrPNAcPeP9ydHYqA= X-Google-Smtp-Source: AJdET5cF8mosv6vXoQ+mNRK8pUEkvUnA2G/fFyzm7+V9459t2TAZdFyV8fX8kwP6G1bLrRnqgoHjhQ== X-Received: by 2002:a17:906:1859:: with SMTP id w25-v6mr12253044eje.3.1542484279255; Sat, 17 Nov 2018 11:51:19 -0800 (PST) From: Radoslaw Biernacki To: libvir-list@redhat.com, mprivozn@redhat.com Date: Sat, 17 Nov 2018 20:51:10 +0100 Message-Id: <20181117195113.12544-2-radoslaw.biernacki@linaro.org> In-Reply-To: <20181117195113.12544-1-radoslaw.biernacki@linaro.org> References: <20181110125624.1168-1-radoslaw.biernacki@linaro.org> <20181117195113.12544-1-radoslaw.biernacki@linaro.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sat, 17 Nov 2018 19:51:21 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sat, 17 Nov 2018 19:51:21 +0000 (UTC) for IP:'209.85.208.66' DOMAIN:'mail-ed1-f66.google.com' HELO:'mail-ed1-f66.google.com' FROM:'radoslaw.biernacki@linaro.org' RCPT:'' X-RedHat-Spam-Score: -0.112 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.208.66 mail-ed1-f66.google.com 209.85.208.66 mail-ed1-f66.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: laine@laine.org Subject: [libvirt] [PATCH v2 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: , MIME-Version: 1.0 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sat, 17 Nov 2018 21:09:23 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 removes one comment about PF netdev assumption. The error report was moved outside from virNetDevGetPhysicalFunction() and the error message changed slightly to reflect other potential root causes of error. 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 --- src/util/virnetdev.c | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 5867977df4..f1c2ba8c17 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -1358,15 +1358,8 @@ virNetDevGetPhysicalFunction(const char *ifname, cha= r **pfname) goto cleanup; } =20 - if (!*pfname) { - /* this shouldn't be possible. A VF can't exist unless its - * PF device is bound to a network driver - */ - virReportError(VIR_ERR_INTERNAL_ERROR, - _("The PF device for VF %s has no network device na= me"), - ifname); + if (!*pfname) goto cleanup; - } =20 ret =3D 0; cleanup: @@ -1453,8 +1446,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; @@ -3182,8 +3179,11 @@ 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 */ + ignore_value(virNetDevGetPhysicalFunction(ifname, &pfname)); + } =20 pci_device_ptr =3D pfname ? virNetDevGetPCIDevice(pfname) : virNetDevGetPCIDevice(ifname); --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 01:34:36 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; dkim=fail; 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=linaro.org Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1542488975457695.8895642789727; Sat, 17 Nov 2018 13:09:35 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 826263083392; Sat, 17 Nov 2018 21:09:33 +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 51B2217249; Sat, 17 Nov 2018 21:09:33 +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 0810C18005B1; Sat, 17 Nov 2018 21:09:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAHJpOou029178 for ; Sat, 17 Nov 2018 14:51:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7022C60BF1; Sat, 17 Nov 2018 19:51:24 +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 6497065F4C for ; Sat, 17 Nov 2018 19:51:23 +0000 (UTC) Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DA2EC3DDB6 for ; Sat, 17 Nov 2018 19:51:21 +0000 (UTC) Received: by mail-ed1-f66.google.com with SMTP id f4so9586466edq.10 for ; Sat, 17 Nov 2018 11:51:21 -0800 (PST) Received: from rad-H81M-S1.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id s12sm7887633edb.43.2018.11.17.11.51.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Nov 2018 11:51:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kVZfDwJ2r7m+ojDZr9hYdZNb8P6V0m1xH6zGF0YyfXc=; b=QX11F3GTiuYnJpAl9JFbH+hlx/qZt0IJaKsoLRggYesMAhRtnA87op/Vq+f9/Rasvj bCPUU2lTwy20xLbqXThOrBEFwQEvDN7XRJTHw7fEoE5kesPVGAml8DwEfr1o0NVOP6xd M1cdQZUv84JmjEJdbOvpyVbrntB7wiA8O8Do4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kVZfDwJ2r7m+ojDZr9hYdZNb8P6V0m1xH6zGF0YyfXc=; b=g5F2ndszmk85Bak2/IFU33fqdd0SXszlF1Toh/1gEeuYqffaUEGvgtuilS8OjxDbYm 8mxcgJ+DlRXLFN8szSmP5QVPGCYFw9aYwmLGpCABNR773cK6rgfzWxj+HF9pzZpCgpXU sLmedy77G6p9yJJw2r9eT7adF/zmzt6ubEmGVu8P+ng/3zierpc61o5Ybwl4EWJn4WLV Jm+BSq4gGbOFYt+ioi+OXA1h4l9V6uBqz8sDTZb987/mZdPeb0PcwolC/QhHgim1ONnR YZimJw34MTHazMmlj0B6yawiRe9fZCOuU8AqmnrnkmQiCinCtXgwF97xu/90/Fwlc22x DbZA== X-Gm-Message-State: AA+aEWaq0IOzC3WxyFCInF7m5KDpwz08RUMA7s3TP6IpOV9bxqZOP9WC H/ZNn/L0tf/L/XdkoAr5r6/ku1SSEoM= X-Google-Smtp-Source: AFSGD/UxtePbkKrYvAzacqgZ0Ov7d4WeMx9YCJ97bnEwTAObpwygBHzUA/Mth1RLEPQcwW3pDvvdLA== X-Received: by 2002:a50:b902:: with SMTP id m2mr4646682ede.108.1542484280308; Sat, 17 Nov 2018 11:51:20 -0800 (PST) From: Radoslaw Biernacki To: libvir-list@redhat.com, mprivozn@redhat.com Date: Sat, 17 Nov 2018 20:51:11 +0100 Message-Id: <20181117195113.12544-3-radoslaw.biernacki@linaro.org> In-Reply-To: <20181117195113.12544-1-radoslaw.biernacki@linaro.org> References: <20181110125624.1168-1-radoslaw.biernacki@linaro.org> <20181117195113.12544-1-radoslaw.biernacki@linaro.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sat, 17 Nov 2018 19:51:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sat, 17 Nov 2018 19:51:22 +0000 (UTC) for IP:'209.85.208.66' DOMAIN:'mail-ed1-f66.google.com' HELO:'mail-ed1-f66.google.com' FROM:'radoslaw.biernacki@linaro.org' RCPT:'' X-RedHat-Spam-Score: -0.112 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.208.66 mail-ed1-f66.google.com 209.85.208.66 mail-ed1-f66.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: laine@laine.org Subject: [libvirt] [PATCH v2 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: , MIME-Version: 1.0 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Sat, 17 Nov 2018 21:09:34 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Removing redundant sections of the code Signed-off-by: Radoslaw Biernacki Reviewed-by: Michal Privoznik --- src/util/virnetdev.c | 40 +++----------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index f1c2ba8c17..9318de406c 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -1441,34 +1441,16 @@ int virNetDevGetVirtualFunctionInfo(const char *vfname, char **pfname, int *vf) { - char *pf_sysfs_path =3D NULL, *vf_sysfs_path =3D NULL; - int ret =3D -1; - *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 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; + return virNetDevGetVirtualFunctionIndex(*pfname, vfname, vf); } =20 #else /* !__linux__ */ @@ -1863,13 +1845,9 @@ virNetDevSaveNetConfig(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 if (pfDevName) { @@ -2021,13 +1999,9 @@ virNetDevReadNetConfig(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 /* if there is a PF, it's now in pfDevName, and linkdev is either @@ -2226,13 +2200,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.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 01:34:36 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; dkim=fail; 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=linaro.org Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1542484889508378.9771530300901; Sat, 17 Nov 2018 12:01:29 -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 E661385362; Sat, 17 Nov 2018 20:01: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 5A15E7D2C8; Sat, 17 Nov 2018 20:01:26 +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 14EE2181B9E1; Sat, 17 Nov 2018 20:01: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 wAHJpQYo029222 for ; Sat, 17 Nov 2018 14:51:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id 39514101962A; Sat, 17 Nov 2018 19:51:26 +0000 (UTC) Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 318A41001F3D for ; Sat, 17 Nov 2018 19:51:24 +0000 (UTC) Received: from mail-ed1-f68.google.com (mail-ed1-f68.google.com [209.85.208.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D52E13084217 for ; Sat, 17 Nov 2018 19:51:22 +0000 (UTC) Received: by mail-ed1-f68.google.com with SMTP id f4so9586484edq.10 for ; Sat, 17 Nov 2018 11:51:22 -0800 (PST) Received: from rad-H81M-S1.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id s12sm7887633edb.43.2018.11.17.11.51.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Nov 2018 11:51:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PxzE0LVPiDRRkOraSl4MU1fXKtt0B1+bjHE0+zgQilM=; b=LvaQBUSvO28rJ3PwODc40Q6vkOzG+IcLK2qGiFDUKHhp/kBDEDFsXwBtsl+jZLaM4E s0Ss2/niwKxxNbAJzvckfzA6ium455RtNTIhmd7MGwYpsOLFwFn5dTVf0gbFAj8dlnx6 JUtTChyA1vXpOdFgioZBQf5dMHGwDjpZFgTFg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PxzE0LVPiDRRkOraSl4MU1fXKtt0B1+bjHE0+zgQilM=; b=SekShAPO6bPHCiiaLo5AD03t/aiFdyN2NJd9Ui8z8aIMtrkyJztsv7Bz84WXiFjyPa c+Jhn1Zxy9hYjkFK5/DiVktH7+T3t4fH0tMfrDKXM1lftVQ/iCJgD/jeq24oVNLWA004 ntj2UbPbYV7tpDNcgoAk/5xEsSgo0HNR+fNLzsQTDGEi/8yLQtEYZxgtj7J9V6ZkJnCF ZF/ORo5WDHKCqmqUe5xPJijvKTJny+EP5mD0kiUuUc5LdDYtMKPrwN2hO8HtNFCzgQgm zgZnPRkVw2xX80RRlm7Dqynoj1y89n+dVG8a6giJWu+N5Ubq8O/FM9X8Y9AyfVwmoTBb qtNQ== X-Gm-Message-State: AGRZ1gLeiY2VtR80QdaN+M6a6sPeR/6Su/6eJc02mncrevGy2CYFqdp9 f+wrEL4xUFmzOKUODPiCZOWHzG48mVM= X-Google-Smtp-Source: AJdET5enHGGjJxAORQI5krt4iHPS2ZBth6CoexnZ8WixsQ+E8dKf20og55NgVJc4oj77lyKrha51Mg== X-Received: by 2002:a17:906:3389:: with SMTP id v9-v6mr11975026eja.201.1542484281110; Sat, 17 Nov 2018 11:51:21 -0800 (PST) From: Radoslaw Biernacki To: libvir-list@redhat.com, mprivozn@redhat.com Date: Sat, 17 Nov 2018 20:51:12 +0100 Message-Id: <20181117195113.12544-4-radoslaw.biernacki@linaro.org> In-Reply-To: <20181117195113.12544-1-radoslaw.biernacki@linaro.org> References: <20181110125624.1168-1-radoslaw.biernacki@linaro.org> <20181117195113.12544-1-radoslaw.biernacki@linaro.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Sat, 17 Nov 2018 19:51:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Sat, 17 Nov 2018 19:51:23 +0000 (UTC) for IP:'209.85.208.68' DOMAIN:'mail-ed1-f68.google.com' HELO:'mail-ed1-f68.google.com' FROM:'radoslaw.biernacki@linaro.org' RCPT:'' X-RedHat-Spam-Score: -0.112 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.208.68 mail-ed1-f68.google.com 209.85.208.68 mail-ed1-f68.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: laine@laine.org Subject: [libvirt] [PATCH v2 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: , MIME-Version: 1.0 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.25]); Sat, 17 Nov 2018 20:01:27 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 --- 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 73ed9cc68c..f9275ed810 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -232,10 +232,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; @@ -324,8 +322,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; } @@ -692,14 +689,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.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 01:34:36 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; dkim=fail; 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=linaro.org Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 154248583441833.59621503571975; Sat, 17 Nov 2018 12:17:14 -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 3A62BC057F34; Sat, 17 Nov 2018 20:17:12 +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 E925C600C7; Sat, 17 Nov 2018 20:17:11 +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 8199F3F7D0; Sat, 17 Nov 2018 20:17:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAHJpR5e029355 for ; Sat, 17 Nov 2018 14:51:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6FDA2600C7; Sat, 17 Nov 2018 19:51:27 +0000 (UTC) Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 65EDF600C4 for ; Sat, 17 Nov 2018 19:51:25 +0000 (UTC) Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D119E308338E for ; Sat, 17 Nov 2018 19:51:23 +0000 (UTC) Received: by mail-ed1-f66.google.com with SMTP id f23so13068222edb.3 for ; Sat, 17 Nov 2018 11:51:23 -0800 (PST) Received: from rad-H81M-S1.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id s12sm7887633edb.43.2018.11.17.11.51.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Nov 2018 11:51:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=N8DwdroMPmJovv46TwQEeDs2zfJZzOXJ9PxmkNmnvGY=; b=Qy7/M8OYy+cWICMTmCCTBjSMAOWdNVe6087ehHHjeMPYh0IMClzM6nk6hThx+bYw02 9sAt4Okl8TLsYkQZ9YbowIffZrpLGLRQKF7Ug9AW7OaoagAauZhTHDjfslhX5A1UkHmW M71ikS0qufA3hPcBaGLnWM37tN/Xz+UmXCj1c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=N8DwdroMPmJovv46TwQEeDs2zfJZzOXJ9PxmkNmnvGY=; b=baF2WzvqiwL4KOQb1Eb1K+2yA6dwg55dri2zcSoE/sxPxKwvm4h7kj4Aj0fMWjs+zn a11PnLwsC/ftnMuehDCLMK58h5khPOScjWtWARYDB9mMddvmRb3nATw3gmvG7FC1+uIx iKC0J/O4o+VtV59xNx16EJL/2fooCTV6THLbiMxWftr1o+ynXnPf8sjaCA0ruhezcpT5 QCDiitKM5eorMVpJaSSb7kz55W0dNuw967RSoZSsCbxdyCmOOuKEbqx5KB4HymExQ23B 2S+R8LHxsI7hz6C1vcmm1YKjCVY5mTQ/yJbDwwo2BCGYjEytE28OxemPASEzctHdyahr xr6w== X-Gm-Message-State: AGRZ1gJHCXToMIJURLWppqbZYxLQnh0r2xh0b4dzc2Pe+qzBWLv2YeyS 7uxlb0Xx/cC25m280ll99+umgc5wYTo= X-Google-Smtp-Source: AJdET5fMjvGR95vJfuCYB7Faxw+UKxfihx79PJ0OJ/fbCLR2BzqztGXadDSYaOx01+o+Gds1O5RLkg== X-Received: by 2002:a17:906:e0cb:: with SMTP id gl11-v6mr5473514ejb.92.1542484282237; Sat, 17 Nov 2018 11:51:22 -0800 (PST) From: Radoslaw Biernacki To: libvir-list@redhat.com, mprivozn@redhat.com Date: Sat, 17 Nov 2018 20:51:13 +0100 Message-Id: <20181117195113.12544-5-radoslaw.biernacki@linaro.org> In-Reply-To: <20181117195113.12544-1-radoslaw.biernacki@linaro.org> References: <20181110125624.1168-1-radoslaw.biernacki@linaro.org> <20181117195113.12544-1-radoslaw.biernacki@linaro.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Sat, 17 Nov 2018 19:51:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Sat, 17 Nov 2018 19:51:24 +0000 (UTC) for IP:'209.85.208.66' DOMAIN:'mail-ed1-f66.google.com' HELO:'mail-ed1-f66.google.com' FROM:'radoslaw.biernacki@linaro.org' RCPT:'' X-RedHat-Spam-Score: -0.112 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.208.66 mail-ed1-f66.google.com 209.85.208.66 mail-ed1-f66.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.44 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: laine@laine.org Subject: [libvirt] [PATCH v2 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: , MIME-Version: 1.0 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.32]); Sat, 17 Nov 2018 20:17:12 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 --- 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 1898f9eeb9..1d9345beda 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -317,7 +317,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.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list