[libvirt] [PATCH] conf: Add a function virDomainDefCputuneValidate

Suyang Chen posted 1 patch 9 weeks ago
Failed in applying to current master (apply log)
src/conf/domain_conf.c | 43 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)

[libvirt] [PATCH] conf: Add a function virDomainDefCputuneValidate

Posted by Suyang Chen 9 weeks ago
Solve the bitsizedtask:
"Move validation checks out of domain XML parsing"

Resolves: https://wiki.libvirt.org/page/BiteSizedTasks#Move_validation_checks_out_of_domain_XML_parsing

Signed-off-by: Suyang Chen <dawson0xff@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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] conf: Add a function virDomainDefCputuneValidate

Posted by Peter Krempa 9 weeks ago
On Tue, Mar 12, 2019 at 12:54:05 -0600, Suyang Chen wrote:
> Solve the bitsizedtask:
> "Move validation checks out of domain XML parsing"

The commit message should describe this individual change.

> 
> Resolves: https://wiki.libvirt.org/page/BiteSizedTasks#Move_validation_checks_out_of_domain_XML_parsing
> 
> Signed-off-by: Suyang Chen <dawson0xff@gmail.com>
> ---
>  src/conf/domain_conf.c | 43 ++++++++++++++++++++++++++++++++++++++++++

Your patch is not removing it, but rather just adding a duplicate copy
of the checks.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list