mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
conf: Enforce ranges on cputune variables
The limits are documented at http://libvirt.org/formatdomain.html#elementsCPUTuning . Enforce them when going through XML parsing in addition to being enforced by the API.
This commit is contained in:
parent
5e5ca84e31
commit
f8e3221f99
@ -9677,6 +9677,14 @@ virDomainDefParseXML(virCapsPtr caps,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (def->cputune.period > 0 &&
|
||||||
|
(def->cputune.period < 1000 || def->cputune.period > 1000000)) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("Value of cputune period must be in range "
|
||||||
|
"[1000, 1000000]"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (virXPathLongLong("string(./cputune/quota[1])", ctxt,
|
if (virXPathLongLong("string(./cputune/quota[1])", ctxt,
|
||||||
&def->cputune.quota) < -1) {
|
&def->cputune.quota) < -1) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
@ -9684,6 +9692,15 @@ virDomainDefParseXML(virCapsPtr caps,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (def->cputune.quota > 0 &&
|
||||||
|
(def->cputune.quota < 1000 ||
|
||||||
|
def->cputune.quota > 18446744073709551)) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("Value of cputune quota must be in range "
|
||||||
|
"[1000, 18446744073709551]"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (virXPathULongLong("string(./cputune/emulator_period[1])", ctxt,
|
if (virXPathULongLong("string(./cputune/emulator_period[1])", ctxt,
|
||||||
&def->cputune.emulator_period) < -1) {
|
&def->cputune.emulator_period) < -1) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
@ -9691,6 +9708,15 @@ virDomainDefParseXML(virCapsPtr caps,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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]"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (virXPathLongLong("string(./cputune/emulator_quota[1])", ctxt,
|
if (virXPathLongLong("string(./cputune/emulator_quota[1])", ctxt,
|
||||||
&def->cputune.emulator_quota) < -1) {
|
&def->cputune.emulator_quota) < -1) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
@ -9698,6 +9724,15 @@ virDomainDefParseXML(virCapsPtr caps,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (def->cputune.emulator_quota > 0 &&
|
||||||
|
(def->cputune.emulator_quota < 1000 ||
|
||||||
|
def->cputune.emulator_quota > 18446744073709551)) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("Value of cputune emulator_quota must be in range "
|
||||||
|
"[1000, 18446744073709551]"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if ((n = virXPathNodeSet("./cputune/vcpupin", ctxt, &nodes)) < 0)
|
if ((n = virXPathNodeSet("./cputune/vcpupin", ctxt, &nodes)) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user