[Devel] [PATCH RHEL7 COMMIT] connector: introduce VE-aware get_cdev() helper

Konstantin Khorenko khorenko at virtuozzo.com
Thu Aug 31 17:40:28 MSK 2017


The commit is pushed to "branch-rh7-3.10.0-514.26.1.vz7.35.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.26.1.vz7.35.5
------>
commit 1dd02e8904050497fc1eb9c74485c526184679b0
Author: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
Date:   Thu Aug 31 17:40:28 2017 +0300

    connector: introduce VE-aware get_cdev() helper
    
    Once containerized, device won't be one and for all.
    Thus make a helper template and use it instead of direct device object access.
    Use ve0 for now.
    
    Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
    Reviewed-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 drivers/connector/connector.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index da26064..407fe52 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -63,6 +63,12 @@ static int cn_already_initialized;
  * a new message.
  *
  */
+
+static struct cn_dev *get_cdev(struct ve_struct *ve)
+{
+	return &cdev;
+}
+
 int cn_netlink_send(struct cn_msg *msg, u32 __group, gfp_t gfp_mask)
 {
 	struct cn_callback_entry *__cbq;
@@ -70,7 +76,7 @@ int cn_netlink_send(struct cn_msg *msg, u32 __group, gfp_t gfp_mask)
 	struct sk_buff *skb;
 	struct nlmsghdr *nlh;
 	struct cn_msg *data;
-	struct cn_dev *dev = &cdev;
+	struct cn_dev *dev = get_cdev(get_ve0());
 	u32 group = 0;
 	int found = 0;
 
@@ -123,7 +129,7 @@ EXPORT_SYMBOL_GPL(cn_netlink_send);
 static int cn_call_callback(struct sk_buff *skb)
 {
 	struct cn_callback_entry *i, *cbq = NULL;
-	struct cn_dev *dev = &cdev;
+	struct cn_dev *dev = get_cdev(get_ve0());
 	struct cn_msg *msg = nlmsg_data(nlmsg_hdr(skb));
 	struct netlink_skb_parms *nsp = &NETLINK_CB(skb);
 	int err = -ENODEV;
@@ -190,7 +196,7 @@ int cn_add_callback(struct cb_id *id, const char *name,
 				     struct netlink_skb_parms *))
 {
 	int err;
-	struct cn_dev *dev = &cdev;
+	struct cn_dev *dev = get_cdev(get_ve0());
 
 	if (!cn_already_initialized)
 		return -EAGAIN;
@@ -213,7 +219,7 @@ EXPORT_SYMBOL_GPL(cn_add_callback);
  */
 void cn_del_callback(struct cb_id *id)
 {
-	struct cn_dev *dev = &cdev;
+	struct cn_dev *dev = get_cdev(get_ve0());
 
 	cn_queue_del_callback(dev->cbdev, id);
 }
@@ -221,7 +227,7 @@ EXPORT_SYMBOL_GPL(cn_del_callback);
 
 static int cn_proc_show(struct seq_file *m, void *v)
 {
-	struct cn_queue_dev *dev = cdev.cbdev;
+	struct cn_queue_dev *dev = get_cdev(get_ve0())->cbdev;
 	struct cn_callback_entry *cbq;
 
 	seq_printf(m, "Name            ID\n");
@@ -255,7 +261,7 @@ static const struct file_operations cn_file_ops = {
 
 static int cn_init(void)
 {
-	struct cn_dev *dev = &cdev;
+	struct cn_dev *dev = get_cdev(get_ve0());
 	struct netlink_kernel_cfg cfg = {
 		.groups	= CN_NETLINK_USERS + 0xf,
 		.input	= cn_rx_skb,
@@ -280,7 +286,7 @@ static int cn_init(void)
 
 static void cn_fini(void)
 {
-	struct cn_dev *dev = &cdev;
+	struct cn_dev *dev = get_cdev(get_ve0());
 
 	cn_already_initialized = 0;
 


More information about the Devel mailing list