c313de
From d1b618c627d848ed4549912d83be397f969935d2 Mon Sep 17 00:00:00 2001
c313de
Message-Id: <d1b618c627d848ed4549912d83be397f969935d2@dist-git>
c313de
From: Pavel Hrdina <phrdina@redhat.com>
c313de
Date: Mon, 1 Jul 2019 17:06:22 +0200
c313de
Subject: [PATCH] vircgroup: introduce cgroup v1 backend files
c313de
MIME-Version: 1.0
c313de
Content-Type: text/plain; charset=UTF-8
c313de
Content-Transfer-Encoding: 8bit
c313de
c313de
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
c313de
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c313de
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c313de
(cherry picked from commit 1f221d610dc510b82f17407a81a0acd56d9efc5b)
c313de
c313de
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
c313de
c313de
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c313de
Message-Id: <d49ee905c005a855d89ed463e81aa935b07f003e.1561993100.git.phrdina@redhat.com>
c313de
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c313de
---
c313de
 src/Makefile.am             |  1 +
c313de
 src/libvirt_private.syms    |  3 ++
c313de
 src/util/Makefile.inc.am    |  2 ++
c313de
 src/util/vircgroupbackend.c |  2 ++
c313de
 src/util/vircgroupv1.c      | 55 +++++++++++++++++++++++++++++++++++++
c313de
 src/util/vircgroupv1.h      | 27 ++++++++++++++++++
c313de
 6 files changed, 90 insertions(+)
c313de
 create mode 100644 src/util/vircgroupv1.c
c313de
 create mode 100644 src/util/vircgroupv1.h
c313de
c313de
diff --git a/src/Makefile.am b/src/Makefile.am
c313de
index c4e797f5a2..0def0a3b19 100644
c313de
--- a/src/Makefile.am
c313de
+++ b/src/Makefile.am
c313de
@@ -679,6 +679,7 @@ libvirt_setuid_rpc_client_la_SOURCES = \
c313de
 		util/virbuffer.c \
c313de
 		util/vircgroup.c \
c313de
 		util/vircgroupbackend.c \
c313de
+		util/vircgroupv1.c \
c313de
 		util/vircommand.c \
c313de
 		util/virconf.c \
c313de
 		util/virdbus.c \
c313de
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
c313de
index 627eb5e587..b144955154 100644
c313de
--- a/src/libvirt_private.syms
c313de
+++ b/src/libvirt_private.syms
c313de
@@ -1595,6 +1595,9 @@ virCgroupTerminateMachine;
c313de
 virCgroupBackendGetAll;
c313de
 virCgroupBackendRegister;
c313de
 
c313de
+# util/vircgroupv1.h
c313de
+virCgroupV1Register;
c313de
+
c313de
 # util/virclosecallbacks.h
c313de
 virCloseCallbacksGet;
c313de
 virCloseCallbacksGetConn;
c313de
diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am
c313de
index a9185bd7b7..725ece98e9 100644
c313de
--- a/src/util/Makefile.inc.am
c313de
+++ b/src/util/Makefile.inc.am
c313de
@@ -25,6 +25,8 @@ UTIL_SOURCES = \
c313de
 	util/vircgroup.h util/vircgrouppriv.h \
c313de
 	util/vircgroupbackend.c \
c313de
 	util/vircgroupbackend.h \
c313de
+	util/vircgroupv1.c \
c313de
+	util/vircgroupv1.h \
c313de
 	util/virclosecallbacks.c \
c313de
 	util/virclosecallbacks.h \
c313de
 	util/vircommand.c \
c313de
diff --git a/src/util/vircgroupbackend.c b/src/util/vircgroupbackend.c
c313de
index e014bfc0e6..d854c9711d 100644
c313de
--- a/src/util/vircgroupbackend.c
c313de
+++ b/src/util/vircgroupbackend.c
c313de
@@ -20,6 +20,7 @@
c313de
 #include <config.h>
c313de
 
c313de
 #include "vircgroupbackend.h"
c313de
+#include "vircgroupv1.h"
c313de
 #include "virerror.h"
c313de
 #include "virthread.h"
c313de
 
c313de
@@ -49,6 +50,7 @@ virCgroupBackendRegister(virCgroupBackendPtr backend)
c313de
 static void
c313de
 virCgroupBackendOnceInit(void)
c313de
 {
c313de
+    virCgroupV1Register();
c313de
 }
c313de
 
c313de
 
c313de
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
c313de
new file mode 100644
c313de
index 0000000000..4dda7865f1
c313de
--- /dev/null
c313de
+++ b/src/util/vircgroupv1.c
c313de
@@ -0,0 +1,55 @@
c313de
+/*
c313de
+ * vircgroupv1.c: methods for cgroups v1 backend
c313de
+ *
c313de
+ * Copyright (C) 2010-2015,2018 Red Hat, Inc.
c313de
+ * Copyright IBM Corp. 2008
c313de
+ *
c313de
+ * This library is free software; you can redistribute it and/or
c313de
+ * modify it under the terms of the GNU Lesser General Public
c313de
+ * License as published by the Free Software Foundation; either
c313de
+ * version 2.1 of the License, or (at your option) any later version.
c313de
+ *
c313de
+ * This library is distributed in the hope that it will be useful,
c313de
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
c313de
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
c313de
+ * Lesser General Public License for more details.
c313de
+ *
c313de
+ * You should have received a copy of the GNU Lesser General Public
c313de
+ * License along with this library.  If not, see
c313de
+ * <http://www.gnu.org/licenses/>.
c313de
+ */
c313de
+#include <config.h>
c313de
+
c313de
+#include "internal.h"
c313de
+
c313de
+#define __VIR_CGROUP_ALLOW_INCLUDE_PRIV_H__
c313de
+#include "vircgrouppriv.h"
c313de
+#undef __VIR_CGROUP_ALLOW_INCLUDE_PRIV_H__
c313de
+
c313de
+#include "vircgroup.h"
c313de
+#include "vircgroupbackend.h"
c313de
+#include "vircgroupv1.h"
c313de
+#include "virlog.h"
c313de
+
c313de
+VIR_LOG_INIT("util.cgroup");
c313de
+
c313de
+#define VIR_FROM_THIS VIR_FROM_CGROUP
c313de
+
c313de
+
c313de
+VIR_ENUM_DECL(virCgroupV1Controller);
c313de
+VIR_ENUM_IMPL(virCgroupV1Controller, VIR_CGROUP_CONTROLLER_LAST,
c313de
+              "cpu", "cpuacct", "cpuset", "memory", "devices",
c313de
+              "freezer", "blkio", "net_cls", "perf_event",
c313de
+              "name=systemd");
c313de
+
c313de
+
c313de
+virCgroupBackend virCgroupV1Backend = {
c313de
+    .type = VIR_CGROUP_BACKEND_TYPE_V1,
c313de
+};
c313de
+
c313de
+
c313de
+void
c313de
+virCgroupV1Register(void)
c313de
+{
c313de
+    virCgroupBackendRegister(&virCgroupV1Backend);
c313de
+}
c313de
diff --git a/src/util/vircgroupv1.h b/src/util/vircgroupv1.h
c313de
new file mode 100644
c313de
index 0000000000..517517c109
c313de
--- /dev/null
c313de
+++ b/src/util/vircgroupv1.h
c313de
@@ -0,0 +1,27 @@
c313de
+/*
c313de
+ * vircgroupv1.h: methods for cgroups v1 backend
c313de
+ *
c313de
+ * Copyright (C) 2018 Red Hat, Inc.
c313de
+ *
c313de
+ * This library is free software; you can redistribute it and/or
c313de
+ * modify it under the terms of the GNU Lesser General Public
c313de
+ * License as published by the Free Software Foundation; either
c313de
+ * version 2.1 of the License, or (at your option) any later version.
c313de
+ *
c313de
+ * This library is distributed in the hope that it will be useful,
c313de
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
c313de
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
c313de
+ * Lesser General Public License for more details.
c313de
+ *
c313de
+ * You should have received a copy of the GNU Lesser General Public
c313de
+ * License along with this library.  If not, see
c313de
+ * <http://www.gnu.org/licenses/>.
c313de
+ */
c313de
+
c313de
+#ifndef __VIR_CGROUP_V1_H__
c313de
+# define __VIR_CGROUP_V1_H__
c313de
+
c313de
+void
c313de
+virCgroupV1Register(void);
c313de
+
c313de
+#endif /* __VIR_CGROUP_V1_H__ */
c313de
-- 
c313de
2.22.0
c313de