[Devel,v2,27/27] connector: add VE SS hook

Submitted by Stanislav Kinsburskiy on Aug. 17, 2017, 2:01 p.m.

Details

Message ID 20170817140118.23505.95428.stgit@localhost.localdomain
State New
Series "proc connector: containerize on per-VE basis"
Headers show

Commit Message

Stanislav Kinsburskiy Aug. 17, 2017, 2:01 p.m.
And thus containerize connector finally.

https://jira.sw.ru/browse/PSBM-60227

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
---
 drivers/connector/connector.c |   23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index 81854bf..752c692 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -273,8 +273,9 @@  static const struct file_operations cn_file_ops = {
 	.release = single_release
 };
 
-static int cn_init_ve(struct ve_struct *ve)
+static int cn_init_ve(void *data)
 {
+	struct ve_struct *ve = data;
 	struct cn_dev *dev;
 	struct netlink_kernel_cfg cfg = {
 		.groups	= CN_NETLINK_USERS + 0xf,
@@ -326,8 +327,9 @@  static int cn_init_ve(struct ve_struct *ve)
 	return err;
 }
 
-static void cn_fini_ve(struct ve_struct *ve)
+static void cn_fini_ve(void *data)
 {
+	struct ve_struct *ve = data;
 	struct cn_dev *dev = get_cdev(ve);
 	struct net *net = ve->ve_netns;
 
@@ -344,13 +346,28 @@  static void cn_fini_ve(struct ve_struct *ve)
 	ve->cn = NULL;
 }
 
+static struct ve_hook cn_ss_hook = {
+	.init = cn_init_ve,
+	.fini = cn_fini_ve,
+	.priority = HOOK_PRIO_DEFAULT,
+	.owner = THIS_MODULE,
+};
+
 static int cn_init(void)
 {
-	return cn_init_ve(get_ve0());
+	int err;
+
+	err = cn_init_ve(get_ve0());
+	if (err)
+		return err;
+
+	ve_hook_register(VE_SS_CHAIN, &cn_ss_hook);
+	return 0;
 }
 
 static void cn_fini(void)
 {
+	ve_hook_unregister(&cn_ss_hook);
 	return cn_fini_ve(get_ve0());
 }