<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 18, 2018 at 5:45 PM, Pavel Hrdina <span dir="ltr"><<a href="mailto:phrdina@redhat.com" target="_blank">phrdina@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We will need to extract current cgroup v1 implementation into separate<br>
backend because there will be new cgroup v2 implementation and both will<br>
have to co-exit.<br></blockquote><div><br></div><div>typo: co-exit -> co-exist<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Signed-off-by: Pavel Hrdina <<a href="mailto:phrdina@redhat.com" target="_blank">phrdina@redhat.com</a>><br></blockquote><div><br></div><div>Reviewed-by: Fabiano Fidêncio <<a href="mailto:fidencio@redhat.com" target="_blank">fidencio@redhat.com</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br>
 src/Makefile.am             |  1 +<br>
 src/libvirt_private.syms    |  3 ++<br>
 src/util/<a href="http://Makefile.inc.am" rel="noreferrer" target="_blank">Makefile.inc.am</a>    |  2 ++<br>
 src/util/vircgroupbackend.c | 64 ++++++++++++++++++++++++++++++<wbr>+++++++<br>
 src/util/vircgroupbackend.h | 46 ++++++++++++++++++++++++++<br>
 5 files changed, 116 insertions(+)<br>
 create mode 100644 src/util/vircgroupbackend.c<br>
 create mode 100644 src/util/vircgroupbackend.h<br>
<br>
diff --git a/src/Makefile.am b/src/Makefile.am<br>
index 2a3ed0d42d..3465629005 100644<br>
--- a/src/Makefile.am<br>
+++ b/src/Makefile.am<br>
@@ -673,6 +673,7 @@ libvirt_setuid_rpc_client_la_S<wbr>OURCES = \<br>
                util/virbitmap.c \<br>
                util/virbuffer.c \<br>
                util/vircgroup.c \<br>
+               util/vircgroupbackend.c \<br>
                util/vircommand.c \<br>
                util/virconf.c \<br>
                util/virdbus.c \<br>
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms<br>
index 75c59fbf89..eb302b3559 100644<br>
--- a/src/libvirt_private.syms<br>
+++ b/src/libvirt_private.syms<br>
@@ -1576,6 +1576,9 @@ virCgroupSetOwner;<br>
 virCgroupSupportsCpuBW;<br>
 virCgroupTerminateMachine;<br>
<br>
+# util/vircgroupbackend.h<br>
+virCgroupBackendGetAll;<br>
+virCgroupBackendRegister;<br>
<br>
 # util/virclosecallbacks.h<br>
 virCloseCallbacksGet;<br>
diff --git a/src/util/<a href="http://Makefile.inc.am" rel="noreferrer" target="_blank">Makefile.inc.am</a> b/src/util/<a href="http://Makefile.inc.am" rel="noreferrer" target="_blank">Makefile.inc.am</a><br>
index a22265606c..1b236ca62b 100644<br>
--- a/src/util/<a href="http://Makefile.inc.am" rel="noreferrer" target="_blank">Makefile.inc.am</a><br>
+++ b/src/util/<a href="http://Makefile.inc.am" rel="noreferrer" target="_blank">Makefile.inc.am</a><br>
@@ -23,6 +23,8 @@ UTIL_SOURCES = \<br>
        util/virperf.h \<br>
        util/vircgroup.c \<br>
        util/vircgroup.h util/vircgrouppriv.h \<br>
+       util/vircgroupbackend.c \<br>
+       util/vircgroupbackend.h \<br>
        util/virclosecallbacks.c \<br>
        util/virclosecallbacks.h \<br>
        util/vircommand.c \<br>
diff --git a/src/util/vircgroupbackend.c b/src/util/vircgroupbackend.c<br>
new file mode 100644<br>
index 0000000000..e014bfc0e6<br>
--- /dev/null<br>
+++ b/src/util/vircgroupbackend.c<br>
@@ -0,0 +1,64 @@<br>
+/*<br>
+ * vircgroupbackend.c: methods for cgroups backend<br>
+ *<br>
+ * Copyright (C) 2018 Red Hat, Inc.<br>
+ *<br>
+ * This library is free software; you can redistribute it and/or<br>
+ * modify it under the terms of the GNU Lesser General Public<br>
+ * License as published by the Free Software Foundation; either<br>
+ * version 2.1 of the License, or (at your option) any later version.<br>
+ *<br>
+ * This library is distributed in the hope that it will be useful,<br>
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU<br>
+ * Lesser General Public License for more details.<br>
+ *<br>
+ * You should have received a copy of the GNU Lesser General Public<br>
+ * License along with this library.  If not, see<br>
+ * <<a href="http://www.gnu.org/licenses/" rel="noreferrer" target="_blank">http://www.gnu.org/licenses/</a>><wbr>.<br>
+ */<br>
+#include <config.h><br>
+<br>
+#include "vircgroupbackend.h"<br>
+#include "virerror.h"<br>
+#include "virthread.h"<br>
+<br>
+#define VIR_FROM_THIS VIR_FROM_CGROUP<br>
+<br>
+VIR_ENUM_DECL(virCgroupBacken<wbr>d);<br>
+VIR_ENUM_IMPL(virCgroupBacken<wbr>d, VIR_CGROUP_BACKEND_TYPE_LAST,<br>
+              "cgroup V1");<br>
+<br>
+static virOnceControl virCgroupBackendOnce = VIR_ONCE_CONTROL_INITIALIZER;<br>
+static virCgroupBackendPtr virCgroupBackends[VIR_CGROUP_B<wbr>ACKEND_TYPE_LAST] = { 0 };<br>
+<br>
+void<br>
+virCgroupBackendRegister(virC<wbr>groupBackendPtr backend)<br>
+{<br>
+    if (virCgroupBackends[backend->ty<wbr>pe]) {<br>
+        virReportError(VIR_ERR_INTERNA<wbr>L_ERROR,<br>
+                       _("Cgroup backend '%s' already registered."),<br>
+                       virCgroupBackendTypeToString(<wbr>backend->type));<br>
+        return;<br>
+    }<br>
+<br>
+    virCgroupBackends[backend->typ<wbr>e] = backend;<br>
+}<br>
+<br>
+<br>
+static void<br>
+virCgroupBackendOnceInit(void<wbr>)<br>
+{<br>
+}<br>
+<br>
+<br>
+virCgroupBackendPtr *<br>
+virCgroupBackendGetAll(void)<br>
+{<br>
+    if (virOnce(&virCgroupBackendOnce<wbr>, virCgroupBackendOnceInit) < 0) {<br>
+        virReportError(VIR_ERR_INTERNA<wbr>L_ERROR, "%s",<br>
+                       _("Failed to initialize cgroup backend."));<br>
+        return NULL;<br>
+    }<br>
+    return virCgroupBackends;<br>
+}<br>
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h<br>
new file mode 100644<br>
index 0000000000..db052485a8<br>
--- /dev/null<br>
+++ b/src/util/vircgroupbackend.h<br>
@@ -0,0 +1,46 @@<br>
+/*<br>
+ * vircgroupbackend.h: methods for cgroups backend<br>
+ *<br>
+ * Copyright (C) 2018 Red Hat, Inc.<br>
+ *<br>
+ * This library is free software; you can redistribute it and/or<br>
+ * modify it under the terms of the GNU Lesser General Public<br>
+ * License as published by the Free Software Foundation; either<br>
+ * version 2.1 of the License, or (at your option) any later version.<br>
+ *<br>
+ * This library is distributed in the hope that it will be useful,<br>
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU<br>
+ * Lesser General Public License for more details.<br>
+ *<br>
+ * You should have received a copy of the GNU Lesser General Public<br>
+ * License along with this library.  If not, see<br>
+ * <<a href="http://www.gnu.org/licenses/" rel="noreferrer" target="_blank">http://www.gnu.org/licenses/</a>><wbr>.<br>
+ */<br>
+<br>
+#ifndef __VIR_CGROUP_BACKEND_H__<br>
+# define __VIR_CGROUP_BACKEND_H__<br>
+<br>
+# include "internal.h"<br>
+<br>
+# include "vircgroup.h"<br>
+<br>
+<br>
+typedef enum {<br>
+    VIR_CGROUP_BACKEND_TYPE_V1 = 0,<br>
+    VIR_CGROUP_BACKEND_TYPE_LAST,<br>
+} virCgroupBackendType;<br>
+<br>
+struct _virCgroupBackend {<br>
+    virCgroupBackendType type;<br>
+};<br>
+typedef struct _virCgroupBackend virCgroupBackend;<br>
+typedef virCgroupBackend *virCgroupBackendPtr;<br>
+<br>
+void<br>
+virCgroupBackendRegister(virC<wbr>groupBackendPtr backend);<br>
+<br>
+virCgroupBackendPtr *<br>
+virCgroupBackendGetAll(void);<br>
+<br>
+#endif /* __VIR_CGROUP_BACKEND_H__ */<br>
<span class="m_6937705529379875533HOEnZb"><font color="#888888">-- <br>
2.17.1<br>
<br>
--<br>
libvir-list mailing list<br>
<a href="mailto:libvir-list@redhat.com" target="_blank">libvir-list@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/libvir-list" rel="noreferrer" target="_blank">https://www.redhat.com/mailman<wbr>/listinfo/libvir-list</a><br>
</font></span></blockquote></div><br></div></div>