[PATCH v3 04/16] Pull definition of structs out of vircgroup.c to vircgrouppriv.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

The definition of structs for cgroups are kept in vircgroup.c since
they are intended to be private from users of the API. To enable
effective testing, however, they need to be accessible. To address
the latter issue, without compronmising the former, this introduces
a new vircgrouppriv.h file to hold the struct definitions.

To prevent other files including this private header, it requires
that __VIR_CGROUP_ALLOW_INCLUDE_PRIV_H__ be defined before inclusion

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 src/Makefile.am          |  2 +-
 src/util/vircgroup.c     | 17 +++--------------
 src/util/vircgrouppriv.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 15 deletions(-)
 create mode 100644 src/util/vircgrouppriv.h

diff --git a/src/Makefile.am b/src/Makefile.am
index fc6b846..e2e9e37 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -69,7 +69,7 @@ UTIL_SOURCES =							\
 		util/virauthconfig.c util/virauthconfig.h	\
 		util/virbitmap.c util/virbitmap.h		\
 		util/virbuffer.c util/virbuffer.h		\
-		util/vircgroup.c util/vircgroup.h		\
+		util/vircgroup.c util/vircgroup.h util/vircgrouppriv.h	\
 		util/vircommand.c util/vircommand.h		\
 		util/virconf.c util/virconf.h			\
 		util/virdbus.c util/virdbus.h			\
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index dc2b431..dfa3c8a 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -37,10 +37,11 @@
 #include <libgen.h>
 #include <dirent.h>
 
-#include "internal.h"
+#define __VIR_CGROUP_ALLOW_INCLUDE_PRIV_H__
+#include "vircgrouppriv.h"
+
 #include "virutil.h"
 #include "viralloc.h"
-#include "vircgroup.h"
 #include "virlog.h"
 #include "virfile.h"
 #include "virhash.h"
@@ -52,18 +53,6 @@ VIR_ENUM_IMPL(virCgroupController, VIR_CGROUP_CONTROLLER_LAST,
               "cpu", "cpuacct", "cpuset", "memory", "devices",
               "freezer", "blkio");
 
-struct virCgroupController {
-    int type;
-    char *mountPoint;
-    char *placement;
-};
-
-struct virCgroup {
-    char *path;
-
-    struct virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST];
-};
-
 typedef enum {
     VIR_CGROUP_NONE = 0, /* create subdir under each cgroup if possible. */
     VIR_CGROUP_MEM_HIERACHY = 1 << 0, /* call virCgroupSetMemoryUseHierarchy
diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h
new file mode 100644
index 0000000..cc8cc0b
--- /dev/null
+++ b/src/util/vircgrouppriv.h
@@ -0,0 +1,46 @@
+/*
+ * vircgrouppriv.h: methods for managing control cgroups
+ *
+ * Copyright (C) 2011-2013 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
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ *  Dan Smith <danms@xxxxxxxxxx>
+ */
+
+#ifndef __VIR_CGROUP_ALLOW_INCLUDE_PRIV_H__
+# error "vircgrouppriv.h may only be included by vircgroup.c or its test suite"
+#endif
+
+#ifndef __VIR_CGROUP_PRIV_H__
+# define __VIR_CGROUP_PRIV_H__
+
+# include "vircgroup.h"
+
+struct virCgroupController {
+    int type;
+    char *mountPoint;
+    char *placement;
+};
+
+struct virCgroup {
+    char *path;
+
+    struct virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST];
+};
+
+#endif /* __VIR_CGROUP_PRIV_H__ */
-- 
1.8.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]