2018-08-15 11:10:24 +00:00
|
|
|
/*
|
|
|
|
* vircgroupbackend.h: methods for cgroups backend
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VIR_CGROUP_BACKEND_H__
|
|
|
|
# define __VIR_CGROUP_BACKEND_H__
|
|
|
|
|
|
|
|
# include "internal.h"
|
|
|
|
|
|
|
|
# include "vircgroup.h"
|
|
|
|
|
2018-09-13 14:27:56 +00:00
|
|
|
# define CGROUP_MAX_VAL 512
|
2018-08-15 11:10:24 +00:00
|
|
|
|
2018-09-18 14:11:47 +00:00
|
|
|
typedef enum {
|
|
|
|
VIR_CGROUP_NONE = 0, /* create subdir under each cgroup if possible. */
|
|
|
|
VIR_CGROUP_MEM_HIERACHY = 1 << 0, /* call virCgroupSetMemoryUseHierarchy
|
|
|
|
* before creating subcgroups and
|
|
|
|
* attaching tasks
|
|
|
|
*/
|
|
|
|
} virCgroupBackendFlags;
|
|
|
|
|
2018-08-15 11:10:24 +00:00
|
|
|
typedef enum {
|
|
|
|
VIR_CGROUP_BACKEND_TYPE_V1 = 0,
|
|
|
|
VIR_CGROUP_BACKEND_TYPE_LAST,
|
|
|
|
} virCgroupBackendType;
|
|
|
|
|
2018-09-13 14:27:56 +00:00
|
|
|
typedef bool
|
|
|
|
(*virCgroupAvailableCB)(void);
|
|
|
|
|
2018-09-14 11:21:19 +00:00
|
|
|
typedef bool
|
|
|
|
(*virCgroupValidateMachineGroupCB)(virCgroupPtr group,
|
|
|
|
const char *name,
|
|
|
|
const char *drivername,
|
|
|
|
const char *machinename);
|
|
|
|
|
2018-08-17 07:46:10 +00:00
|
|
|
typedef int
|
|
|
|
(*virCgroupCopyMountsCB)(virCgroupPtr group,
|
|
|
|
virCgroupPtr parent);
|
|
|
|
|
2018-09-14 10:53:47 +00:00
|
|
|
typedef int
|
|
|
|
(*virCgroupCopyPlacementCB)(virCgroupPtr group,
|
|
|
|
const char *path,
|
|
|
|
virCgroupPtr parent);
|
|
|
|
|
2018-09-14 10:51:27 +00:00
|
|
|
typedef int
|
|
|
|
(*virCgroupDetectMountsCB)(virCgroupPtr group,
|
|
|
|
const char *mntType,
|
|
|
|
const char *mntOpts,
|
|
|
|
const char *mntDir);
|
|
|
|
|
|
|
|
typedef int
|
|
|
|
(*virCgroupDetectPlacementCB)(virCgroupPtr group,
|
|
|
|
const char *path,
|
|
|
|
const char *controllers,
|
|
|
|
const char *selfpath);
|
|
|
|
|
2018-08-24 13:15:23 +00:00
|
|
|
typedef int
|
|
|
|
(*virCgroupValidatePlacementCB)(virCgroupPtr group,
|
|
|
|
pid_t pid);
|
|
|
|
|
2018-08-17 10:00:29 +00:00
|
|
|
typedef char *
|
|
|
|
(*virCgroupStealPlacementCB)(virCgroupPtr group);
|
|
|
|
|
2018-09-24 23:12:22 +00:00
|
|
|
typedef int
|
|
|
|
(*virCgroupDetectControllersCB)(virCgroupPtr group,
|
|
|
|
int controllers);
|
|
|
|
|
2018-08-19 17:17:27 +00:00
|
|
|
typedef bool
|
|
|
|
(*virCgroupHasControllerCB)(virCgroupPtr cgroup,
|
|
|
|
int controller);
|
|
|
|
|
2018-08-19 17:20:25 +00:00
|
|
|
typedef int
|
|
|
|
(*virCgroupGetAnyControllerCB)(virCgroupPtr group);
|
|
|
|
|
2018-08-19 17:24:58 +00:00
|
|
|
typedef int
|
|
|
|
(*virCgroupPathOfControllerCB)(virCgroupPtr group,
|
|
|
|
int controller,
|
|
|
|
const char *key,
|
|
|
|
char **path);
|
|
|
|
|
2018-09-18 14:11:47 +00:00
|
|
|
typedef int
|
|
|
|
(*virCgroupMakeGroupCB)(virCgroupPtr parent,
|
|
|
|
virCgroupPtr group,
|
|
|
|
bool create,
|
|
|
|
unsigned int flags);
|
|
|
|
|
2018-08-17 08:02:05 +00:00
|
|
|
typedef int
|
|
|
|
(*virCgroupRemoveCB)(virCgroupPtr group);
|
|
|
|
|
2018-08-15 11:10:24 +00:00
|
|
|
struct _virCgroupBackend {
|
|
|
|
virCgroupBackendType type;
|
2018-09-13 14:27:56 +00:00
|
|
|
|
|
|
|
/* Mandatory callbacks that need to be implemented for every backend. */
|
|
|
|
virCgroupAvailableCB available;
|
2018-09-14 11:21:19 +00:00
|
|
|
virCgroupValidateMachineGroupCB validateMachineGroup;
|
2018-08-17 07:46:10 +00:00
|
|
|
virCgroupCopyMountsCB copyMounts;
|
2018-09-14 10:53:47 +00:00
|
|
|
virCgroupCopyPlacementCB copyPlacement;
|
2018-09-14 10:51:27 +00:00
|
|
|
virCgroupDetectMountsCB detectMounts;
|
|
|
|
virCgroupDetectPlacementCB detectPlacement;
|
2018-08-24 13:15:23 +00:00
|
|
|
virCgroupValidatePlacementCB validatePlacement;
|
2018-08-17 10:00:29 +00:00
|
|
|
virCgroupStealPlacementCB stealPlacement;
|
2018-09-24 23:12:22 +00:00
|
|
|
virCgroupDetectControllersCB detectControllers;
|
2018-08-19 17:17:27 +00:00
|
|
|
virCgroupHasControllerCB hasController;
|
2018-08-19 17:20:25 +00:00
|
|
|
virCgroupGetAnyControllerCB getAnyController;
|
2018-08-19 17:24:58 +00:00
|
|
|
virCgroupPathOfControllerCB pathOfController;
|
2018-09-18 14:11:47 +00:00
|
|
|
virCgroupMakeGroupCB makeGroup;
|
2018-08-17 08:02:05 +00:00
|
|
|
virCgroupRemoveCB remove;
|
2018-08-15 11:10:24 +00:00
|
|
|
};
|
|
|
|
typedef struct _virCgroupBackend virCgroupBackend;
|
|
|
|
typedef virCgroupBackend *virCgroupBackendPtr;
|
|
|
|
|
|
|
|
void
|
|
|
|
virCgroupBackendRegister(virCgroupBackendPtr backend);
|
|
|
|
|
|
|
|
virCgroupBackendPtr *
|
|
|
|
virCgroupBackendGetAll(void);
|
|
|
|
|
|
|
|
#endif /* __VIR_CGROUP_BACKEND_H__ */
|