[PATCH v2 6/9] domain_conf.c: move blkio path check to validate callback

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

 



Move this check to a new virDomainDefTunablesValidate(), which
is called by virDomainDefValidateInternal().

Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>
---
 src/conf/domain_conf.c | 35 +++++++++++++++++++++++++----------
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 230e89e786..290930cc85 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7397,6 +7397,27 @@ virDomainDefVideoValidate(const virDomainDef *def)
 }
 
 
+static int
+virDomainDefTunablesValidate(const virDomainDef *def)
+{
+    size_t i, j;
+
+    for (i = 0; i < def->blkio.ndevices; i++) {
+        for (j = 0; j < i; j++) {
+            if (STREQ(def->blkio.devices[j].path,
+                      def->blkio.devices[i].path)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               _("duplicate blkio device path '%s'"),
+                               def->blkio.devices[i].path);
+                return -1;
+            }
+        }
+    }
+
+    return 0;
+}
+
+
 static int
 virDomainDefValidateInternal(const virDomainDef *def,
                              virDomainXMLOptionPtr xmlopt)
@@ -7448,6 +7469,9 @@ virDomainDefValidateInternal(const virDomainDef *def,
     if (virDomainDefVideoValidate(def) < 0)
         return -1;
 
+    if (virDomainDefTunablesValidate(def) < 0)
+        return -1;
+
     if (virDomainNumaDefValidate(def->numa) < 0)
         return -1;
 
@@ -21342,7 +21366,7 @@ virDomainDefTunablesParse(virDomainDefPtr def,
                           unsigned int flags)
 {
     g_autofree xmlNodePtr *nodes = NULL;
-    size_t i, j;
+    size_t i;
     int n;
 
     /* Extract blkio cgroup tunables */
@@ -21363,15 +21387,6 @@ virDomainDefTunablesParse(virDomainDefPtr def,
                                          &def->blkio.devices[i]) < 0)
             return -1;
         def->blkio.ndevices++;
-        for (j = 0; j < i; j++) {
-            if (STREQ(def->blkio.devices[j].path,
-                      def->blkio.devices[i].path)) {
-                virReportError(VIR_ERR_XML_ERROR,
-                               _("duplicate blkio device path '%s'"),
-                               def->blkio.devices[i].path);
-                return -1;
-            }
-        }
     }
     VIR_FREE(nodes);
 
-- 
2.26.2




[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