render / rpms / libvirt

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