Solve the bitsizedtask:
"Move validation checks out of domain XML parsing"
Resolves:
https://wiki.libvirt.org/page/BiteSizedTasks#Move_validation_checks_out_o...
Signed-off-by: Suyang Chen <dawson0xff(a)gmail.com>
---
src/conf/domain_conf.c | 43 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 995f87bcbe..eb63800b9a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6589,6 +6589,46 @@ virDomainDefMemtuneValidate(const virDomainDef *def)
return 0;
}
+static int
+virDomainDefCputuneValidate(const virDomainDef *def)
+{
+ if (def->cputune.global_period > 0 &&
+ (def->cputune.global_period < 1000 || def->cputune.global_period >
1000000)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Value of cputune global period must be in range "
+ "[1000, 1000000]"));
+ return -1;
+ }
+
+ if (def->cputune.emulator_period > 0 &&
+ (def->cputune.emulator_period < 1000 ||
+ def->cputune.emulator_period > 1000000)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Value of cputune emulator_period must be in range "
+ "[1000, 1000000]"));
+ return -1;
+ }
+
+ if (def->cputune.emulator_period > 0 &&
+ (def->cputune.emulator_period < 1000 ||
+ def->cputune.emulator_period > 1000000)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Value of cputune emulator_period must be in range "
+ "[1000, 1000000]"));
+ return -1;
+ }
+
+ if (def->cputune.iothread_period > 0 &&
+ (def->cputune.iothread_period < 1000 ||
+ def->cputune.iothread_period > 1000000)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Value of cputune iothread_period must be in range "
+ "[1000, 1000000]"));
+ return -1;
+ }
+
+ return 0;
+}
static int
virDomainDefValidateInternal(const virDomainDef *def)
@@ -6628,6 +6668,9 @@ virDomainDefValidateInternal(const virDomainDef *def)
if (virDomainDefMemtuneValidate(def) < 0)
return -1;
+ if (virDomainDefCputuneValidate(def) < 0)
+ return -1;
+
return 0;
}
--
2.20.1