vircgroupbackend: Extend error messages in VIR_CGROUP_BACKEND_CALL()

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>
This commit is contained in:
Michal Privoznik 2021-04-16 16:14:33 +02:00
parent edce157f11
commit a0815484b1
2 changed files with 6 additions and 3 deletions

View 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",

View 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__); \