virt-host-validate: Report an error if failed to detect CGroups

As a part of its checks, virt-host-validate calls virCgroupNew()
to detect CGroup controllers which are then printed out. However,
virCgroupNew() can fail (with appropriate error message set).
Let's print an error onto stderr if that happens.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Fabiano Fidêncio <fabiano@fidencio.org>
This commit is contained in:
Michal Privoznik 2021-06-08 09:17:52 +02:00
parent e7ae82dcc5
commit 52d2571b58

View File

@ -290,8 +290,11 @@ int virHostValidateCGroupControllers(const char *hvname,
int ret = 0;
size_t i;
if (virCgroupNew("/", -1, &group) < 0)
if (virCgroupNew("/", -1, &group) < 0) {
fprintf(stderr, "Unable to initialize cgroups: %s\n",
virGetLastErrorMessage());
return VIR_HOST_VALIDATE_FAILURE(level);
}
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
int flag = 1 << i;