[libvirt] [PATCH] conf: Move more PCI functions out of device_conf

Andrea Bolognani posted 1 patch 5 years, 7 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20180913143844.4172-1-abologna@redhat.com
Test syntax-check passed
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(-)
[libvirt] [PATCH] conf: Move more PCI functions out of device_conf
Posted by Andrea Bolognani 5 years, 7 months ago
Functions that deal with virPCIDeviceAddress exclusively
belong to util/virpci.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
 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 virDomainDeviceInfo *a,
     return true;
 }
 
-bool
-virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr,
-                           bool report)
-{
-    if (addr->domain > 0xFFFF) {
-        if (report)
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("Invalid PCI address domain='0x%x', "
-                             "must be <= 0xFFFF"),
-                           addr->domain);
-        return false;
-    }
-    if (addr->bus > 0xFF) {
-        if (report)
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("Invalid PCI address bus='0x%x', "
-                             "must be <= 0xFF"),
-                           addr->bus);
-        return false;
-    }
-    if (addr->slot > 0x1F) {
-        if (report)
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("Invalid PCI address slot='0x%x', "
-                             "must be <= 0x1F"),
-                           addr->slot);
-        return false;
-    }
-    if (addr->function > 7) {
-        if (report)
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("Invalid PCI address function=0x%x, "
-                             "must be <= 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;
 }
 
-bool
-virPCIDeviceAddressEqual(virPCIDeviceAddress *addr1,
-                         virPCIDeviceAddress *addr2)
-{
-    if (addr1->domain == addr2->domain &&
-        addr1->bus == addr2->bus &&
-        addr1->slot == addr2->slot &&
-        addr1->function == 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 virDomainDeviceInfo *a,
 bool virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
                                    int type);
 
-bool virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr,
-                                bool report);
-bool virPCIDeviceAddressIsEmpty(const virPCIDeviceAddress *addr);
-
 bool virDeviceInfoPCIAddressIsWanted(const virDomainDeviceInfo *info);
 bool virDeviceInfoPCIAddressIsPresent(const virDomainDeviceInfo *info);
 
@@ -205,9 +201,6 @@ int virPCIDeviceAddressFormat(virBufferPtr buf,
                               virPCIDeviceAddress addr,
                               bool includeTypeInAddr);
 
-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;
 
 
@@ -2498,10 +2495,13 @@ virObjectUnref;
 
 # 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;
 }
 
+bool
+virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr,
+                           bool report)
+{
+    if (addr->domain > 0xFFFF) {
+        if (report)
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("Invalid PCI address domain='0x%x', "
+                             "must be <= 0xFFFF"),
+                           addr->domain);
+        return false;
+    }
+    if (addr->bus > 0xFF) {
+        if (report)
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("Invalid PCI address bus='0x%x', "
+                             "must be <= 0xFF"),
+                           addr->bus);
+        return false;
+    }
+    if (addr->slot > 0x1F) {
+        if (report)
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("Invalid PCI address slot='0x%x', "
+                             "must be <= 0x1F"),
+                           addr->slot);
+        return false;
+    }
+    if (addr->function > 7) {
+        if (report)
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("Invalid PCI address function=0x%x, "
+                             "must be <= 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 == addr2->domain &&
+        addr1->bus == addr2->bus &&
+        addr1->slot == addr2->slot &&
+        addr1->function == 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;
 
+bool virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr,
+                                bool report);
+bool virPCIDeviceAddressIsEmpty(const virPCIDeviceAddress *addr);
+
+bool virPCIDeviceAddressEqual(virPCIDeviceAddress *addr1,
+                              virPCIDeviceAddress *addr2);
+
 char *virPCIDeviceAddressAsString(virPCIDeviceAddressPtr addr)
       ATTRIBUTE_NONNULL(1);
 
-- 
2.17.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] conf: Move more PCI functions out of device_conf
Posted by Fabiano Fidêncio 5 years, 7 months ago
On Thu, Sep 13, 2018 at 4:38 PM, Andrea Bolognani <abologna@redhat.com>
wrote:

> Functions that deal with virPCIDeviceAddress exclusively
> belong to util/virpci.
>
> Signed-off-by: Andrea Bolognani <abologna@redhat.com>
>

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>


> ---
>  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
> virDomainDeviceInfo *a,
>      return true;
>  }
>
> -bool
> -virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr,
> -                           bool report)
> -{
> -    if (addr->domain > 0xFFFF) {
> -        if (report)
> -            virReportError(VIR_ERR_XML_ERROR,
> -                           _("Invalid PCI address domain='0x%x', "
> -                             "must be <= 0xFFFF"),
> -                           addr->domain);
> -        return false;
> -    }
> -    if (addr->bus > 0xFF) {
> -        if (report)
> -            virReportError(VIR_ERR_XML_ERROR,
> -                           _("Invalid PCI address bus='0x%x', "
> -                             "must be <= 0xFF"),
> -                           addr->bus);
> -        return false;
> -    }
> -    if (addr->slot > 0x1F) {
> -        if (report)
> -            virReportError(VIR_ERR_XML_ERROR,
> -                           _("Invalid PCI address slot='0x%x', "
> -                             "must be <= 0x1F"),
> -                           addr->slot);
> -        return false;
> -    }
> -    if (addr->function > 7) {
> -        if (report)
> -            virReportError(VIR_ERR_XML_ERROR,
> -                           _("Invalid PCI address function=0x%x, "
> -                             "must be <= 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;
>  }
>
> -bool
> -virPCIDeviceAddressEqual(virPCIDeviceAddress *addr1,
> -                         virPCIDeviceAddress *addr2)
> -{
> -    if (addr1->domain == addr2->domain &&
> -        addr1->bus == addr2->bus &&
> -        addr1->slot == addr2->slot &&
> -        addr1->function == 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
> virDomainDeviceInfo *a,
>  bool virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
>                                     int type);
>
> -bool virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr,
> -                                bool report);
> -bool virPCIDeviceAddressIsEmpty(const virPCIDeviceAddress *addr);
> -
>  bool virDeviceInfoPCIAddressIsWanted(const virDomainDeviceInfo *info);
>  bool virDeviceInfoPCIAddressIsPresent(const virDomainDeviceInfo *info);
>
> @@ -205,9 +201,6 @@ int virPCIDeviceAddressFormat(virBufferPtr buf,
>                                virPCIDeviceAddress addr,
>                                bool includeTypeInAddr);
>
> -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;
>
>
> @@ -2498,10 +2495,13 @@ virObjectUnref;
>
>  # 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;
>  }
>
> +bool
> +virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr,
> +                           bool report)
> +{
> +    if (addr->domain > 0xFFFF) {
> +        if (report)
> +            virReportError(VIR_ERR_XML_ERROR,
> +                           _("Invalid PCI address domain='0x%x', "
> +                             "must be <= 0xFFFF"),
> +                           addr->domain);
> +        return false;
> +    }
> +    if (addr->bus > 0xFF) {
> +        if (report)
> +            virReportError(VIR_ERR_XML_ERROR,
> +                           _("Invalid PCI address bus='0x%x', "
> +                             "must be <= 0xFF"),
> +                           addr->bus);
> +        return false;
> +    }
> +    if (addr->slot > 0x1F) {
> +        if (report)
> +            virReportError(VIR_ERR_XML_ERROR,
> +                           _("Invalid PCI address slot='0x%x', "
> +                             "must be <= 0x1F"),
> +                           addr->slot);
> +        return false;
> +    }
> +    if (addr->function > 7) {
> +        if (report)
> +            virReportError(VIR_ERR_XML_ERROR,
> +                           _("Invalid PCI address function=0x%x, "
> +                             "must be <= 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 == addr2->domain &&
> +        addr1->bus == addr2->bus &&
> +        addr1->slot == addr2->slot &&
> +        addr1->function == 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;
>
> +bool virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr,
> +                                bool report);
> +bool virPCIDeviceAddressIsEmpty(const virPCIDeviceAddress *addr);
> +
> +bool virPCIDeviceAddressEqual(virPCIDeviceAddress *addr1,
> +                              virPCIDeviceAddress *addr2);
> +
>  char *virPCIDeviceAddressAsString(virPCIDeviceAddressPtr addr)
>        ATTRIBUTE_NONNULL(1);
>
> --
> 2.17.1
>
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] conf: Move more PCI functions out of device_conf
Posted by Ján Tomko 5 years, 7 months ago
On Thu, Sep 13, 2018 at 04:38:44PM +0200, Andrea Bolognani wrote:
>Functions that deal with virPCIDeviceAddress exclusively
>belong to util/virpci.
>

They're already named appropriately for the new location.

>Signed-off-by: Andrea Bolognani <abologna@redhat.com>
>---
> 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(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list