]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
domain_conf.c: move blkio path check to domain_validate.c
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Fri, 4 Dec 2020 14:28:31 +0000 (11:28 -0300)
committerDaniel Henrique Barboza <danielhb413@gmail.com>
Wed, 9 Dec 2020 12:51:51 +0000 (09:51 -0300)
Move this check to a new virDomainDefTunablesValidate(), which
is called by virDomainDefValidateInternal().

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/conf/domain_conf.c
src/conf/domain_validate.c
src/conf/domain_validate.h

index 40417c2fd0fd45cb4ca7fa4f643e2b2c5aefbd7d..2e918ec76397a37b88db84f05207c22a7fdec554 100644 (file)
@@ -6983,6 +6983,9 @@ virDomainDefValidateInternal(const virDomainDef *def,
     if (virDomainDefVideoValidate(def) < 0)
         return -1;
 
+    if (virDomainDefTunablesValidate(def) < 0)
+        return -1;
+
     if (virDomainNumaDefValidate(def->numa) < 0)
         return -1;
 
@@ -20880,7 +20883,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 */
@@ -20901,15 +20904,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);
 
index 6fca604d17ada9712734e9754578a2cd18eb086c..09ab908ea385edebe210311013aeade5de929a95 100644 (file)
@@ -496,3 +496,24 @@ virDomainSmartcardDefValidate(const virDomainSmartcardDef *smartcard,
 
     return 0;
 }
+
+
+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;
+}
index d65de504220c6c8b050335f5edb3322940e8106b..2bd9e71073e9d22067a8984279b32b806328ab0f 100644 (file)
@@ -42,3 +42,4 @@ int virDomainRNGDefValidate(const virDomainRNGDef *rng,
                             const virDomainDef *def);
 int virDomainSmartcardDefValidate(const virDomainSmartcardDef *smartcard,
                                   const virDomainDef *def);
+int virDomainDefTunablesValidate(const virDomainDef *def);