]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Move more PCI functions out of device_conf
authorAndrea Bolognani <abologna@redhat.com>
Thu, 13 Sep 2018 14:36:25 +0000 (16:36 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 17 Sep 2018 07:23:04 +0000 (09:23 +0200)
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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/device_conf.c
src/conf/device_conf.h
src/libvirt_private.syms
src/util/virpci.c
src/util/virpci.h

index cbdfbf6ef4632a07e38e3718c2faa70908352035..98a419f40f7d86901a9de4368d2c2b11c4443aba 100644 (file)
@@ -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)
 {
index 9f51118e29cd63d73b1aaa3778d268921bf0c98f..407956bd02d173af318da37ff1ad116eed77d50c 100644 (file)
@@ -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);
index e7a4d61f25fd0b8aac489e61f8fdd3d131913a08..b9dabfef1bce7f079f898dbe325e31d3412e1af0 100644 (file)
@@ -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;
index 1730d888f716b413c3955591fe44a5df191fa016..fb3f04fac35833b801116a612cf3695dfb17c4ff 100644 (file)
@@ -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)
 {
index b4f72f8f063ef43eb0d464f2c2a40122836029ea..16c2eded5ed42b82a9bc475469e0ca752ed3a83b 100644 (file)
@@ -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);