From d1b618c627d848ed4549912d83be397f969935d2 Mon Sep 17 00:00:00 2001 Message-Id: From: Pavel Hrdina Date: Mon, 1 Jul 2019 17:06:22 +0200 Subject: [PATCH] vircgroup: introduce cgroup v1 backend files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Fabiano Fidêncio Reviewed-by: Ján Tomko Signed-off-by: Pavel Hrdina (cherry picked from commit 1f221d610dc510b82f17407a81a0acd56d9efc5b) Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297 Signed-off-by: Pavel Hrdina Message-Id: Reviewed-by: Ján Tomko --- src/Makefile.am | 1 + src/libvirt_private.syms | 3 ++ src/util/Makefile.inc.am | 2 ++ src/util/vircgroupbackend.c | 2 ++ src/util/vircgroupv1.c | 55 +++++++++++++++++++++++++++++++++++++ src/util/vircgroupv1.h | 27 ++++++++++++++++++ 6 files changed, 90 insertions(+) create mode 100644 src/util/vircgroupv1.c create mode 100644 src/util/vircgroupv1.h diff --git a/src/Makefile.am b/src/Makefile.am index c4e797f5a2..0def0a3b19 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -679,6 +679,7 @@ libvirt_setuid_rpc_client_la_SOURCES = \ util/virbuffer.c \ util/vircgroup.c \ util/vircgroupbackend.c \ + util/vircgroupv1.c \ util/vircommand.c \ util/virconf.c \ util/virdbus.c \ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 627eb5e587..b144955154 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1595,6 +1595,9 @@ virCgroupTerminateMachine; virCgroupBackendGetAll; virCgroupBackendRegister; +# util/vircgroupv1.h +virCgroupV1Register; + # util/virclosecallbacks.h virCloseCallbacksGet; virCloseCallbacksGetConn; diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am index a9185bd7b7..725ece98e9 100644 --- a/src/util/Makefile.inc.am +++ b/src/util/Makefile.inc.am @@ -25,6 +25,8 @@ UTIL_SOURCES = \ util/vircgroup.h util/vircgrouppriv.h \ util/vircgroupbackend.c \ util/vircgroupbackend.h \ + util/vircgroupv1.c \ + util/vircgroupv1.h \ util/virclosecallbacks.c \ util/virclosecallbacks.h \ util/vircommand.c \ diff --git a/src/util/vircgroupbackend.c b/src/util/vircgroupbackend.c index e014bfc0e6..d854c9711d 100644 --- a/src/util/vircgroupbackend.c +++ b/src/util/vircgroupbackend.c @@ -20,6 +20,7 @@ #include #include "vircgroupbackend.h" +#include "vircgroupv1.h" #include "virerror.h" #include "virthread.h" @@ -49,6 +50,7 @@ virCgroupBackendRegister(virCgroupBackendPtr backend) static void virCgroupBackendOnceInit(void) { + virCgroupV1Register(); } diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c new file mode 100644 index 0000000000..4dda7865f1 --- /dev/null +++ b/src/util/vircgroupv1.c @@ -0,0 +1,55 @@ +/* + * vircgroupv1.c: methods for cgroups v1 backend + * + * Copyright (C) 2010-2015,2018 Red Hat, Inc. + * Copyright IBM Corp. 2008 + * + * 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 + * . + */ +#include + +#include "internal.h" + +#define __VIR_CGROUP_ALLOW_INCLUDE_PRIV_H__ +#include "vircgrouppriv.h" +#undef __VIR_CGROUP_ALLOW_INCLUDE_PRIV_H__ + +#include "vircgroup.h" +#include "vircgroupbackend.h" +#include "vircgroupv1.h" +#include "virlog.h" + +VIR_LOG_INIT("util.cgroup"); + +#define VIR_FROM_THIS VIR_FROM_CGROUP + + +VIR_ENUM_DECL(virCgroupV1Controller); +VIR_ENUM_IMPL(virCgroupV1Controller, VIR_CGROUP_CONTROLLER_LAST, + "cpu", "cpuacct", "cpuset", "memory", "devices", + "freezer", "blkio", "net_cls", "perf_event", + "name=systemd"); + + +virCgroupBackend virCgroupV1Backend = { + .type = VIR_CGROUP_BACKEND_TYPE_V1, +}; + + +void +virCgroupV1Register(void) +{ + virCgroupBackendRegister(&virCgroupV1Backend); +} diff --git a/src/util/vircgroupv1.h b/src/util/vircgroupv1.h new file mode 100644 index 0000000000..517517c109 --- /dev/null +++ b/src/util/vircgroupv1.h @@ -0,0 +1,27 @@ +/* + * vircgroupv1.h: methods for cgroups v1 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 + * . + */ + +#ifndef __VIR_CGROUP_V1_H__ +# define __VIR_CGROUP_V1_H__ + +void +virCgroupV1Register(void); + +#endif /* __VIR_CGROUP_V1_H__ */ -- 2.22.0