[PATCH 2/5] virt-host-validate: Report an error if failed to detect CGroups

Michal Privoznik mprivozn at redhat.com
Tue Jun 8 08:45:07 UTC 2021


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 at redhat.com>
---
 tools/virt-host-validate-common.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c
index 9412bb7514..c0cee43409 100644
--- a/tools/virt-host-validate-common.c
+++ b/tools/virt-host-validate-common.c
@@ -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;
-- 
2.31.1




More information about the libvir-list mailing list