[PATCH libvirt v1 4/6] qemu: move ZPCI uid validation into device validation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The ZPCI device validation is specific to qemu. So, let us move the
ZPCI uid validation out of domain xml parsing into qemu domain device
validation.

Signed-off-by: Shalini Chellathurai Saroja <shalini@xxxxxxxxxxxxx>
Reviewed-by: Bjoern Walk <bwalk@xxxxxxxxxxxxx>
Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx>
---
 src/conf/device_conf.c   |  3 ---
 src/libvirt_private.syms |  1 -
 src/qemu/qemu_validate.c | 24 ++++++++++++++++++++++++
 src/util/virpci.c        | 20 --------------------
 src/util/virpci.h        |  1 -
 5 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
index c03356e7..048d2b16 100644
--- a/src/conf/device_conf.c
+++ b/src/conf/device_conf.c
@@ -77,9 +77,6 @@ virZPCIDeviceAddressParseXML(xmlNodePtr node,
         def.fid_set = true;
     }
 
-    if (!virZPCIDeviceAddressIsValid(&def))
-        return -1;
-
     addr->zpci = def;
 
     return 0;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 18687563..a4c888bb 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2823,7 +2823,6 @@ virPCIStubDriverTypeFromString;
 virPCIStubDriverTypeToString;
 virZPCIDeviceAddressIsIncomplete;
 virZPCIDeviceAddressIsPresent;
-virZPCIDeviceAddressIsValid;
 
 
 # util/virperf.h
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 22fdfd11..d85d8321 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -948,6 +948,24 @@ qemuValidateDomainDef(const virDomainDef *def,
 }
 
 
+static bool
+qemuDomainDeviceDefValidateZPCIUid(virZPCIDeviceAddressPtr zpci)
+{
+    if (zpci->uid_set &&
+        (zpci->uid > VIR_DOMAIN_DEVICE_ZPCI_MAX_UID ||
+         zpci->uid == 0)) {
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("Invalid PCI address uid='0x%.4x', "
+                         "must be > 0x0000 and <= 0x%.4x"),
+                       zpci->uid,
+                       VIR_DOMAIN_DEVICE_ZPCI_MAX_UID);
+        return false;
+    }
+
+    return true;
+}
+
+
 static int
 qemuValidateDomainDeviceDefZPCIAddress(virDomainDeviceInfoPtr info,
                                        virQEMUCapsPtr qemuCaps)
@@ -960,6 +978,12 @@ qemuValidateDomainDeviceDefZPCIAddress(virDomainDeviceInfoPtr info,
         return -1;
     }
 
+    /* We don't need to check fid because fid covers
+     * all range of uint32 type.
+     */
+    if (!qemuDomainDeviceDefValidateZPCIUid(&info->addr.pci.zpci))
+        return -1;
+
     return 0;
 }
 
diff --git a/src/util/virpci.c b/src/util/virpci.c
index b38f717c..349f313c 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -2166,26 +2166,6 @@ virPCIDeviceAddressParse(char *address,
 }
 
 
-bool
-virZPCIDeviceAddressIsValid(virZPCIDeviceAddressPtr zpci)
-{
-    /* We don't need to check fid because fid covers
-     * all range of uint32 type.
-     */
-    if (zpci->uid_set &&
-        (zpci->uid > VIR_DOMAIN_DEVICE_ZPCI_MAX_UID ||
-         zpci->uid == 0)) {
-        virReportError(VIR_ERR_XML_ERROR,
-                       _("Invalid PCI address uid='0x%.4x', "
-                         "must be > 0x0000 and <= 0x%.4x"),
-                       zpci->uid,
-                       VIR_DOMAIN_DEVICE_ZPCI_MAX_UID);
-        return false;
-    }
-
-    return true;
-}
-
 bool
 virZPCIDeviceAddressIsIncomplete(const virZPCIDeviceAddress *addr)
 {
diff --git a/src/util/virpci.h b/src/util/virpci.h
index e937348f..e9c49716 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -249,7 +249,6 @@ int virPCIDeviceAddressParse(char *address, virPCIDeviceAddressPtr bdf);
 
 bool virZPCIDeviceAddressIsIncomplete(const virZPCIDeviceAddress *addr);
 bool virZPCIDeviceAddressIsPresent(const virZPCIDeviceAddress *addr);
-bool virZPCIDeviceAddressIsValid(virZPCIDeviceAddressPtr zpci);
 
 int virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path,
                                  int pfNetDevIdx,
-- 
2.21.1






[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux