[PATCH v3 11/14] domain_conf.c: move virDomainControllerDefValidate() to domain_validate.c

Daniel Henrique Barboza danielhb413 at gmail.com
Tue Dec 8 22:20:27 UTC 2020


Next patch will add more validations to this function. Let's move
it to domain_validate.c beforehand.

Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
---
 src/conf/domain_conf.c     | 37 -------------------------------------
 src/conf/domain_validate.c | 37 +++++++++++++++++++++++++++++++++++++
 src/conf/domain_validate.h |  1 +
 3 files changed, 38 insertions(+), 37 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 064d77d933..453dc6cf6a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6211,43 +6211,6 @@ virDomainNetDefValidate(const virDomainNetDef *net)
 }
 
 
-static int
-virDomainControllerDefValidate(const virDomainControllerDef *controller)
-{
-    if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) {
-        const virDomainPCIControllerOpts *opts = &controller->opts.pciopts;
-
-        if (controller->idx > 255) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("PCI controller index %d too high, maximum is 255"),
-                           controller->idx);
-            return -1;
-        }
-
-        /* Only validate the target index if it's been set */
-        if (opts->targetIndex != -1) {
-
-            if (opts->targetIndex < 0 || opts->targetIndex > 30) {
-                virReportError(VIR_ERR_XML_ERROR,
-                               _("PCI controller target index '%d' out of "
-                                 "range - must be 0-30"),
-                               opts->targetIndex);
-                return -1;
-            }
-
-            if ((controller->idx == 0 && opts->targetIndex != 0) ||
-                (controller->idx != 0 && opts->targetIndex == 0)) {
-                virReportError(VIR_ERR_XML_ERROR, "%s",
-                               _("Only the PCI controller with index 0 can "
-                                 "have target index 0, and vice versa"));
-                return -1;
-            }
-        }
-    }
-    return 0;
-}
-
-
 static int
 virDomainHostdevDefValidate(const virDomainHostdevDef *hostdev)
 {
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index 09ab908ea3..416c24f97b 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -517,3 +517,40 @@ virDomainDefTunablesValidate(const virDomainDef *def)
 
     return 0;
 }
+
+
+int
+virDomainControllerDefValidate(const virDomainControllerDef *controller)
+{
+    if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) {
+        const virDomainPCIControllerOpts *opts = &controller->opts.pciopts;
+
+        if (controller->idx > 255) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("PCI controller index %d too high, maximum is 255"),
+                           controller->idx);
+            return -1;
+        }
+
+        /* Only validate the target index if it's been set */
+        if (opts->targetIndex != -1) {
+
+            if (opts->targetIndex < 0 || opts->targetIndex > 30) {
+                virReportError(VIR_ERR_XML_ERROR,
+                               _("PCI controller target index '%d' out of "
+                                 "range - must be 0-30"),
+                               opts->targetIndex);
+                return -1;
+            }
+
+            if ((controller->idx == 0 && opts->targetIndex != 0) ||
+                (controller->idx != 0 && opts->targetIndex == 0)) {
+                virReportError(VIR_ERR_XML_ERROR, "%s",
+                               _("Only the PCI controller with index 0 can "
+                                 "have target index 0, and vice versa"));
+                return -1;
+            }
+        }
+    }
+    return 0;
+}
diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h
index 2bd9e71073..e8004e358d 100644
--- a/src/conf/domain_validate.h
+++ b/src/conf/domain_validate.h
@@ -43,3 +43,4 @@ int virDomainRNGDefValidate(const virDomainRNGDef *rng,
 int virDomainSmartcardDefValidate(const virDomainSmartcardDef *smartcard,
                                   const virDomainDef *def);
 int virDomainDefTunablesValidate(const virDomainDef *def);
+int virDomainControllerDefValidate(const virDomainControllerDef *controller);
-- 
2.26.2




More information about the libvir-list mailing list