The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at 
https://src.openvz.org/scm/ovz/vzkernel.git
after ark-5.14
------>
commit a330bb29df2e6753f7253b3fff51715705646607
Author: Kirill Tkhai <ktk...@virtuozzo.com>
Date:   Tue Sep 28 19:31:11 2021 +0300

    ve: Virtualize /proc/swaps to watch from inside CT
    
    Customize /proc/swaps when showing from !ve_is_super.
    Extracted from "Initial patch".
    
    Signed-off-by: Kirill Tkhai <ktk...@virtuozzo.com>
    
    (cherry picked from vz7 commit 88c087f1fdb4b0f7934804269df36035ab6b83eb)
    Signed-off-by: Konstantin Khorenko <khore...@virtuozzo.com>
    
    Reviewed-by: Andrey Ryabinin <aryabi...@virtuozzo.com>
    
    vz8 rebase changes:
    * virtinfo notifier substituted by direct call to si_meminfo_ve().
    
    (cherry picked from vz8 commit 72d4827a9827146d775181e5ba75c18b2c8ad163)
    Signed-off-by: Pavel Tikhomirov <ptikhomi...@virtuozzo.com>
---
 mm/swapfile.c | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/mm/swapfile.c b/mm/swapfile.c
index 6c3cdf079fb3..0b3493c28daa 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2792,11 +2792,36 @@ static const struct seq_operations swaps_op = {
        .show =         swap_show
 };
 
+extern void si_meminfo_ve(struct sysinfo *si, struct ve_struct *ve);
+
+static int swap_show_ve(struct seq_file *swap, void *v)
+{
+       struct ve_struct *ve = get_exec_env();
+       struct sysinfo si;
+
+       si_meminfo_ve(&si, ve);
+
+       seq_printf(swap, "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
+       if (!si.totalswap)
+               goto out;
+       seq_printf(swap, "%-40s%s\t%lu\t%lu\t%d\n",
+                       "/dev/null",
+                       "partition",
+                       si.totalswap  << (PAGE_SHIFT - 10),
+                       (si.totalswap - si.freeswap) << (PAGE_SHIFT - 10),
+                       -1);
+out:
+       return 0;
+}
+
 static int swaps_open(struct inode *inode, struct file *file)
 {
        struct seq_file *seq;
        int ret;
 
+       if (!ve_is_super(get_exec_env()))
+               return single_open(file, &swap_show_ve, NULL);
+
        ret = seq_open(file, &swaps_op);
        if (ret)
                return ret;
@@ -2806,12 +2831,21 @@ static int swaps_open(struct inode *inode, struct file 
*file)
        return 0;
 }
 
+static int swaps_release(struct inode *inode, struct file *file)
+{
+       struct seq_file *f = file->private_data;
+
+       if (f->op != &swaps_op)
+               return single_release(inode, file);
+       return seq_release(inode, file);
+}
+
 static const struct proc_ops swaps_proc_ops = {
        .proc_flags     = PROC_ENTRY_PERMANENT,
        .proc_open      = swaps_open,
        .proc_read      = seq_read,
        .proc_lseek     = seq_lseek,
-       .proc_release   = seq_release,
+       .proc_release   = swaps_release,
        .proc_poll      = swaps_poll,
 };
 
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to