1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

domain_validate: use defines for cpu period and quota limits

Commints <bc760f4d7c4f964fadcb2a73e126b0053e7a9b06> and
<98a09ca48ed4fc011abf2aa290e02ce1b8f1bb5f> fixed the code to use
defines instead of magic numbers but missed this place.

Following commit <ed1ba69f5a8132f8c1e73d2a1f142d70de0b564a> changed
the cpu quota limit to reflect what kernel actually allows so using
the defines fixes XML validations as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Pavel Hrdina 2021-02-19 19:41:59 +01:00
parent ef7849ee5f
commit 22cae2ea4b

View File

@ -23,6 +23,7 @@
#include "domain_validate.h"
#include "domain_conf.h"
#include "snapshot_conf.h"
#include "vircgroup.h"
#include "virconftypes.h"
#include "virlog.h"
#include "virutil.h"
@ -1200,10 +1201,13 @@ virDomainDefOSValidate(const virDomainDef *def,
#define CPUTUNE_VALIDATE_PERIOD(name) \
do { \
if (def->cputune.name > 0 && \
(def->cputune.name < 1000 || def->cputune.name > 1000000)) { \
(def->cputune.name < VIR_CGROUP_CPU_PERIOD_MIN || \
def->cputune.name > VIR_CGROUP_CPU_PERIOD_MAX)) { \
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, \
_("Value of cputune '%s' must be in range " \
"[1000, 1000000]"), #name); \
_("Value of cputune '%s' must be in range [%llu, %llu]"), \
#name, \
VIR_CGROUP_CPU_PERIOD_MIN, \
VIR_CGROUP_CPU_PERIOD_MAX); \
return -1; \
} \
} while (0)
@ -1211,11 +1215,13 @@ virDomainDefOSValidate(const virDomainDef *def,
#define CPUTUNE_VALIDATE_QUOTA(name) \
do { \
if (def->cputune.name > 0 && \
(def->cputune.name < 1000 || \
def->cputune.name > 18446744073709551LL)) { \
(def->cputune.name < VIR_CGROUP_CPU_QUOTA_MIN || \
def->cputune.name > VIR_CGROUP_CPU_QUOTA_MAX)) { \
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, \
_("Value of cputune '%s' must be in range " \
"[1000, 18446744073709551]"), #name); \
_("Value of cputune '%s' must be in range [%llu, %llu]"), \
#name, \
VIR_CGROUP_CPU_QUOTA_MIN, \
VIR_CGROUP_CPU_QUOTA_MAX); \
return -1; \
} \
} while (0)