]> xenbits.xensource.com Git - libvirt.git/commitdiff
vircgroupbackend: Extend error messages in VIR_CGROUP_BACKEND_CALL()
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 16 Apr 2021 14:14:33 +0000 (16:14 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 19 Apr 2021 09:21:40 +0000 (11:21 +0200)
The VIR_CGROUP_BACKEND_CALL() macro gets a backend for controller
and calls corresponding callback in it. If either is NULL then an
error message is printed out. However, the error message contains
only the intended callback func and not controller or backend
found.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/util/vircgroupbackend.c
src/util/vircgroupbackend.h

index 53184cd060c15acdbef9dea0c614227fcbed1c5d..6d6f82cbb163e79d7d146c5baaa3b14bdaa6980d 100644 (file)
@@ -29,7 +29,6 @@
 
 #define VIR_FROM_THIS VIR_FROM_CGROUP
 
-VIR_ENUM_DECL(virCgroupBackend);
 VIR_ENUM_IMPL(virCgroupBackend,
               VIR_CGROUP_BACKEND_TYPE_LAST,
               "cgroup V2",
index c7f5708b86941b938b83203ea36180c39965402f..c4d56896b0eca04749899c0651f3e95f25f946ba 100644 (file)
@@ -58,6 +58,8 @@ typedef enum {
     VIR_CGROUP_BACKEND_TYPE_LAST,
 } virCgroupBackendType;
 
+VIR_ENUM_DECL(virCgroupBackend);
+
 typedef bool
 (*virCgroupAvailableCB)(void);
 
@@ -464,12 +466,14 @@ virCgroupBackendForController(virCgroup *group,
         virCgroupBackend *backend = virCgroupBackendForController(group, controller); \
         if (!backend) { \
             virReportError(VIR_ERR_INTERNAL_ERROR, \
-                           _("failed to get cgroup backend for '%s'"), #func); \
+                           _("failed to get cgroup backend for '%s' controller '%u'"), \
+                           #func, controller); \
             return ret; \
         } \
         if (!backend->func) { \
             virReportError(VIR_ERR_OPERATION_UNSUPPORTED, \
-                           _("operation '%s' not supported"), #func); \
+                           _("operation '%s' not supported for backend '%s'"), \
+                           #func, virCgroupBackendTypeToString(backend->type)); \
             return ret; \
         } \
         return backend->func(group, ##__VA_ARGS__); \