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

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Thu Aug 17 17:01:18 MSK 2017


And thus containerize connector finally.

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

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

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());
 }
 



More information about the Devel mailing list