[PATCH libvirt v2 3/5] 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 | 18 +++++++++++++++++-
 src/util/virpci.c        | 20 --------------------
 src/util/virpci.h        |  1 -
 5 files changed, 17 insertions(+), 26 deletions(-)

diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
index 21398e90..a641f3ce 100644
--- a/src/conf/device_conf.c
+++ b/src/conf/device_conf.c
@@ -77,9 +77,6 @@ virZPCIDeviceAddressParseXML(xmlNodePtr node,
         def.fid.isSet = true;
     }
 
-    if (!virZPCIDeviceAddressIsValid(&def))
-        return -1;
-
     addr->zpci = def;
 
     return 0;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index a4a09cf9..f0543bcc 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2839,7 +2839,6 @@ virPCIStubDriverTypeFromString;
 virPCIStubDriverTypeToString;
 virZPCIDeviceAddressIsIncomplete;
 virZPCIDeviceAddressIsPresent;
-virZPCIDeviceAddressIsValid;
 
 
 # util/virperf.h
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 0372ae7d..37c59416 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1018,7 +1018,9 @@ static int
 qemuValidateDomainDeviceDefZPCIAddress(virDomainDeviceInfoPtr info,
                                        virQEMUCapsPtr qemuCaps)
 {
-    if (virZPCIDeviceAddressIsPresent(&info->addr.pci.zpci) &&
+    virZPCIDeviceAddressPtr zpci = &info->addr.pci.zpci;
+
+    if (virZPCIDeviceAddressIsPresent(zpci) &&
         !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_ZPCI)) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        "%s",
@@ -1026,6 +1028,20 @@ qemuValidateDomainDeviceDefZPCIAddress(virDomainDeviceInfoPtr info,
         return -1;
     }
 
+    /* We don't need to check fid because fid covers
+     * all range of uint32 type.
+     */
+    if (zpci->uid.isSet &&
+        (zpci->uid.value > VIR_DOMAIN_DEVICE_ZPCI_MAX_UID ||
+         zpci->uid.value == 0)) {
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("Invalid PCI address uid='0x%.4x', "
+                         "must be > 0x0000 and <= 0x%.4x"),
+                       zpci->uid.value,
+                       VIR_DOMAIN_DEVICE_ZPCI_MAX_UID);
+        return -1;
+    }
+
     return 0;
 }
 
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 40ae5aec..3685f901 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -2167,26 +2167,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.isSet &&
-        (zpci->uid.value > VIR_DOMAIN_DEVICE_ZPCI_MAX_UID ||
-         zpci->uid.value == 0)) {
-        virReportError(VIR_ERR_XML_ERROR,
-                       _("Invalid PCI address uid='0x%.4x', "
-                         "must be > 0x0000 and <= 0x%.4x"),
-                       zpci->uid.value,
-                       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 f198df5d..b3322ba6 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -254,7 +254,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.25.4




[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