From nobody Sun May 5 11:53:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1536849628945371.34419378891675; Thu, 13 Sep 2018 07:40:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B49C231524C9; Thu, 13 Sep 2018 14:40:25 +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 6B9CB19940; Thu, 13 Sep 2018 14:40: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 1726B181A12E; Thu, 13 Sep 2018 14:40:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8DEcpU8013869 for ; Thu, 13 Sep 2018 10:38:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6628A3091323; Thu, 13 Sep 2018 14:38:51 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B7AF830912F4 for ; Thu, 13 Sep 2018 14:38:48 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 13 Sep 2018 16:38:44 +0200 Message-Id: <20180913143844.4172-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] conf: Move more PCI functions out of device_conf 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 13 Sep 2018 14:40:27 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Functions that deal with virPCIDeviceAddress exclusively belong to util/virpci. Signed-off-by: Andrea Bolognani Reviewed-by: Fabiano Fid=C3=AAncio Reviewed-by: J=EF=BF=BDn Tomko --- src/conf/device_conf.c | 66 ---------------------------------------- src/conf/device_conf.h | 7 ----- src/libvirt_private.syms | 6 ++-- src/util/virpci.c | 65 +++++++++++++++++++++++++++++++++++++++ src/util/virpci.h | 7 +++++ 5 files changed, 75 insertions(+), 76 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index cbdfbf6ef4..98a419f40f 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -160,59 +160,6 @@ virDomainDeviceInfoAddressIsEqual(const virDomainDevic= eInfo *a, return true; } =20 -bool -virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr, - bool report) -{ - if (addr->domain > 0xFFFF) { - if (report) - virReportError(VIR_ERR_XML_ERROR, - _("Invalid PCI address domain=3D'0x%x', " - "must be <=3D 0xFFFF"), - addr->domain); - return false; - } - if (addr->bus > 0xFF) { - if (report) - virReportError(VIR_ERR_XML_ERROR, - _("Invalid PCI address bus=3D'0x%x', " - "must be <=3D 0xFF"), - addr->bus); - return false; - } - if (addr->slot > 0x1F) { - if (report) - virReportError(VIR_ERR_XML_ERROR, - _("Invalid PCI address slot=3D'0x%x', " - "must be <=3D 0x1F"), - addr->slot); - return false; - } - if (addr->function > 7) { - if (report) - virReportError(VIR_ERR_XML_ERROR, - _("Invalid PCI address function=3D0x%x, " - "must be <=3D 7"), - addr->function); - return false; - } - if (virPCIDeviceAddressIsEmpty(addr)) { - if (report) - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Invalid PCI address 0000:00:00, at least " - "one of domain, bus, or slot must be > 0")); - return false; - } - return true; -} - - -bool -virPCIDeviceAddressIsEmpty(const virPCIDeviceAddress *addr) -{ - return !(addr->domain || addr->bus || addr->slot); -} - bool virDeviceInfoPCIAddressIsWanted(const virDomainDeviceInfo *info) { @@ -309,19 +256,6 @@ virPCIDeviceAddressFormat(virBufferPtr buf, return 0; } =20 -bool -virPCIDeviceAddressEqual(virPCIDeviceAddress *addr1, - virPCIDeviceAddress *addr2) -{ - if (addr1->domain =3D=3D addr2->domain && - addr1->bus =3D=3D addr2->bus && - addr1->slot =3D=3D addr2->slot && - addr1->function =3D=3D addr2->function) { - return true; - } - return false; -} - bool virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddressPtr addr) { diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index 9f51118e29..407956bd02 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -191,10 +191,6 @@ bool virDomainDeviceInfoAddressIsEqual(const virDomain= DeviceInfo *a, bool virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info, int type); =20 -bool virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr, - bool report); -bool virPCIDeviceAddressIsEmpty(const virPCIDeviceAddress *addr); - bool virDeviceInfoPCIAddressIsWanted(const virDomainDeviceInfo *info); bool virDeviceInfoPCIAddressIsPresent(const virDomainDeviceInfo *info); =20 @@ -205,9 +201,6 @@ int virPCIDeviceAddressFormat(virBufferPtr buf, virPCIDeviceAddress addr, bool includeTypeInAddr); =20 -bool virPCIDeviceAddressEqual(virPCIDeviceAddress *addr1, - virPCIDeviceAddress *addr2); - bool virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddressPtr addr); int virDomainDeviceCCWAddressParseXML(xmlNodePtr node, virDomainDeviceCCWAddressPtr addr); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a0d229a79f..d6662d691d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -108,10 +108,7 @@ virDomainDeviceUSBAddressParseXML; virDomainDeviceVirtioSerialAddressParseXML; virInterfaceLinkFormat; virInterfaceLinkParseXML; -virPCIDeviceAddressEqual; virPCIDeviceAddressFormat; -virPCIDeviceAddressIsEmpty; -virPCIDeviceAddressIsValid; virPCIDeviceAddressParseXML; =20 =20 @@ -2498,10 +2495,13 @@ virObjectUnref; =20 # util/virpci.h virPCIDeviceAddressAsString; +virPCIDeviceAddressEqual; virPCIDeviceAddressGetIOMMUGroupAddresses; virPCIDeviceAddressGetIOMMUGroupNum; virPCIDeviceAddressGetSysfsFile; virPCIDeviceAddressIOMMUGroupIterate; +virPCIDeviceAddressIsEmpty; +virPCIDeviceAddressIsValid; virPCIDeviceAddressParse; virPCIDeviceCopy; virPCIDeviceDetach; diff --git a/src/util/virpci.c b/src/util/virpci.c index 1730d888f7..fb3f04fac3 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -1668,6 +1668,71 @@ virPCIDeviceReadID(virPCIDevicePtr dev, const char *= id_name) return id_str; } =20 +bool +virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr, + bool report) +{ + if (addr->domain > 0xFFFF) { + if (report) + virReportError(VIR_ERR_XML_ERROR, + _("Invalid PCI address domain=3D'0x%x', " + "must be <=3D 0xFFFF"), + addr->domain); + return false; + } + if (addr->bus > 0xFF) { + if (report) + virReportError(VIR_ERR_XML_ERROR, + _("Invalid PCI address bus=3D'0x%x', " + "must be <=3D 0xFF"), + addr->bus); + return false; + } + if (addr->slot > 0x1F) { + if (report) + virReportError(VIR_ERR_XML_ERROR, + _("Invalid PCI address slot=3D'0x%x', " + "must be <=3D 0x1F"), + addr->slot); + return false; + } + if (addr->function > 7) { + if (report) + virReportError(VIR_ERR_XML_ERROR, + _("Invalid PCI address function=3D0x%x, " + "must be <=3D 7"), + addr->function); + return false; + } + if (virPCIDeviceAddressIsEmpty(addr)) { + if (report) + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Invalid PCI address 0000:00:00, at least " + "one of domain, bus, or slot must be > 0")); + return false; + } + return true; +} + +bool +virPCIDeviceAddressIsEmpty(const virPCIDeviceAddress *addr) +{ + return !(addr->domain || addr->bus || addr->slot); +} + +bool +virPCIDeviceAddressEqual(virPCIDeviceAddress *addr1, + virPCIDeviceAddress *addr2) +{ + if (addr1->domain =3D=3D addr2->domain && + addr1->bus =3D=3D addr2->bus && + addr1->slot =3D=3D addr2->slot && + addr1->function =3D=3D addr2->function) { + return true; + } + return false; +} + char * virPCIDeviceAddressAsString(virPCIDeviceAddressPtr addr) { diff --git a/src/util/virpci.h b/src/util/virpci.h index b4f72f8f06..16c2eded5e 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -218,6 +218,13 @@ int virPCIGetSysfsFile(char *virPCIDeviceName, char **pci_sysfs_device_link) ATTRIBUTE_RETURN_CHECK; =20 +bool virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr, + bool report); +bool virPCIDeviceAddressIsEmpty(const virPCIDeviceAddress *addr); + +bool virPCIDeviceAddressEqual(virPCIDeviceAddress *addr1, + virPCIDeviceAddress *addr2); + char *virPCIDeviceAddressAsString(virPCIDeviceAddressPtr addr) ATTRIBUTE_NONNULL(1); =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list