[Devel] [PATCH RHEL7 COMMIT] ve/uts_ns: Implement cgroup interface to configure ve's os_release
Konstantin Khorenko
khorenko at odin.com
Mon May 18 02:52:48 PDT 2015
The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.5.1
------>
commit 3c5b30b0520f4ca33608737b25aef6c45c05fb71
Author: Kirill Tkhai <ktkhai at odin.com>
Date: Mon May 18 13:52:48 2015 +0400
ve/uts_ns: Implement cgroup interface to configure ve's os_release
It's the similar to VZCTL_VE_CONFIGURE ioctl in PCS6.
Note: max_write_len is __NEW_UTS_LEN + 1, because I want to allow
echo ... > ve.os_release, which adds trailing '\n' to the string
(see man echo for details).
Extra symbol will be cut in ve_os_release_write().
https://jira.sw.ru/browse/PSBM-32273
Signed-off-by: Kirill Tkhai <ktkhai at odin.com>
Reviewed-by: Cyrill Gorcunov <gorcunov at odin.com>
---
kernel/ve/ve.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 6ab409f..e598d15 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -1032,6 +1032,54 @@ static int ve_mount_opts_write(struct cgroup *cg, struct cftype *cft,
return 0;
}
+static int ve_os_release_read(struct cgroup *cg, struct cftype *cft,
+ struct seq_file *m)
+{
+ struct ve_struct *ve = cgroup_ve(cg);
+ int ret = 0;
+
+ down_read(&ve->op_sem);
+
+ if (!ve->ve_ns) {
+ ret = -ENOENT;
+ goto up_opsem;
+ }
+
+ down_read(&uts_sem);
+ seq_puts(m, ve->ve_ns->uts_ns->name.release);
+ seq_putc(m, '\n');
+ up_read(&uts_sem);
+up_opsem:
+ up_read(&ve->op_sem);
+
+ return ret;
+}
+
+static int ve_os_release_write(struct cgroup *cg, struct cftype *cft,
+ const char *buffer)
+{
+ struct ve_struct *ve = cgroup_ve(cg);
+ char *release;
+ int ret = 0;
+
+ down_read(&ve->op_sem);
+
+ if (!ve->ve_ns) {
+ ret = -ENOENT;
+ goto up_opsem;
+ }
+
+ down_write(&uts_sem);
+ release = ve->ve_ns->uts_ns->name.release;
+ strncpy(release, buffer, __NEW_UTS_LEN);
+ release[__NEW_UTS_LEN] = '\0';
+ up_write(&uts_sem);
+up_opsem:
+ up_read(&ve->op_sem);
+
+ return ret;
+}
+
static struct cftype ve_cftypes[] = {
{
.name = "state",
@@ -1049,6 +1097,13 @@ static struct cftype ve_cftypes[] = {
.flags = CFTYPE_NOT_ON_ROOT,
.write_string = ve_mount_opts_write,
},
+ {
+ .name = "os_release",
+ .max_write_len = __NEW_UTS_LEN + 1,
+ .flags = CFTYPE_NOT_ON_ROOT,
+ .read_seq_string = ve_os_release_read,
+ .write_string = ve_os_release_write,
+ },
{ }
};
More information about the Devel
mailing list