From nobody Fri Apr 26 16:50:00 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=virtuozzo.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1553153256351989.3780579361313; Thu, 21 Mar 2019 00:27:36 -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 81C19308792A; Thu, 21 Mar 2019 07:27: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 68B225D6A6; Thu, 21 Mar 2019 07:27:30 +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 DFA6E1803387; Thu, 21 Mar 2019 07:27:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2L7RO6R008989 for ; Thu, 21 Mar 2019 03:27:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id D1712608A5; Thu, 21 Mar 2019 07:27:24 +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 CC63360857 for ; Thu, 21 Mar 2019 07:27:22 +0000 (UTC) Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1189F85539 for ; Thu, 21 Mar 2019 07:27:20 +0000 (UTC) Received: from [10.94.3.220] (helo=dim-vz7.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1h6s6f-0003jS-Hr for libvir-list@redhat.com; Thu, 21 Mar 2019 10:27:17 +0300 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Date: Thu, 21 Mar 2019 10:27:14 +0300 Message-Id: <1553153234-427807-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Greylist: Sender passed SPF test, ACL 242 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 21 Mar 2019 07:27:21 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 21 Mar 2019 07:27:21 +0000 (UTC) for IP:'185.231.240.75' DOMAIN:'relay.sw.ru' HELO:'relay.sw.ru' FROM:'nshirokovskiy@virtuozzo.com' RCPT:'' X-RedHat-Spam-Score: -0.001 (SPF_PASS) 185.231.240.75 relay.sw.ru 185.231.240.75 relay.sw.ru X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] xml: nodedev: make pci capability class element optional 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 21 Mar 2019 07:27:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Commit 3bd4ed46 introduced this element as required which breaks backcompat for test driver. Let's make the element optional. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Erik Skultety --- docs/formatnode.html.in | 2 +- docs/schemas/nodedev.rng | 12 ++++++----- src/conf/node_device_conf.c | 23 +++++++++++-------= ---- src/conf/node_device_conf.h | 2 +- src/node_device/node_device_udev.c | 2 +- .../pci_0000_02_10_7_sriov_pf_vfs_all.xml | 1 - 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in index 5095b97..c2a8f8f 100644 --- a/docs/formatnode.html.in +++ b/docs/formatnode.html.in @@ -71,7 +71,7 @@ include:
class
-
Combined class, subclass and +
Optional element for combined class, subclass and programming interface codes as 6-digit hexadecimal number. Since 5.2.0
domain
diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng index 0f45d79..fe6ffa0 100644 --- a/docs/schemas/nodedev.rng +++ b/docs/schemas/nodedev.rng @@ -133,11 +133,13 @@ pci =20 - - - 0x[0-9a-fA-F]{6} - - + + + + 0x[0-9a-fA-F]{6} + + + diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 19c601a..b96d10c 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -208,7 +208,8 @@ virNodeDeviceCapPCIDefFormat(virBufferPtr buf, { size_t i; =20 - virBufferAsprintf(buf, "0x%.6x\n", data->pci_dev.klass); + if (data->pci_dev.klass >=3D 0) + virBufferAsprintf(buf, "0x%.6x\n", data->pci_dev.kl= ass); virBufferAsprintf(buf, "%d\n", data->pci_dev.domain); virBufferAsprintf(buf, "%d\n", data->pci_dev.bus); @@ -1645,16 +1646,16 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt, orignode =3D ctxt->node; ctxt->node =3D node; =20 - if (virNodeDevCapsDefParseHexId("string(./class[1])", ctxt, - &pci_dev->klass, def, - _("no PCI class supplied for '%s'"), - _("invalid PCI class supplied for '%s'= ")) < 0) - goto out; - - if (pci_dev->klass > 0xffffff) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid PCI class supplied for '%s'"), def->name= ); - goto out; + if ((tmp =3D virXPathString("string(./class[1])", ctxt))) { + if (virStrToLong_i(tmp, NULL, 16, &pci_dev->klass) < 0 || + pci_dev->klass > 0xffffff) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid PCI class supplied for '%s'"), def->= name); + goto out; + } + VIR_FREE(tmp); + } else { + pci_dev->klass =3D -1; } =20 if (virNodeDevCapsDefParseULong("number(./domain[1])", ctxt, diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index b13bc13..e8cb315 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -153,7 +153,7 @@ struct _virNodeDevCapPCIDev { unsigned int function; unsigned int product; unsigned int vendor; - unsigned int klass; + int klass; char *product_name; char *vendor_name; virPCIDeviceAddressPtr physical_function; diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index f0e61e4..5ed3463 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -402,7 +402,7 @@ udevProcessPCI(struct udev_device *device, privileged =3D driver->privileged; nodeDeviceUnlock(); =20 - if (udevGetUintProperty(device, "PCI_CLASS", &pci_dev->klass, 16) < 0) + if (udevGetIntProperty(device, "PCI_CLASS", &pci_dev->klass, 16) < 0) goto cleanup; =20 if ((p =3D strrchr(def->sysfs_path, '/')) =3D=3D NULL || diff --git a/tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all.xml = b/tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all.xml index 74036a6..9e8dace 100644 --- a/tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all.xml +++ b/tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all.xml @@ -2,7 +2,6 @@ pci_0000_02_10_7 pci_0000_00_04_0 - 0xffffff 0 2 16 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list