]> git.proxmox.com Git - mirror_lxcfs.git/blob - bindings.c
api_extensions: add and log api extensions
[mirror_lxcfs.git] / bindings.c
1 /* lxcfs
2 *
3 * Copyright © 2014-2016 Canonical, Inc
4 * Author: Serge Hallyn <serge.hallyn@ubuntu.com>
5 *
6 * See COPYING file for details.
7 */
8
9 #ifndef _GNU_SOURCE
10 #define _GNU_SOURCE
11 #endif
12
13 #ifndef FUSE_USE_VERSION
14 #define FUSE_USE_VERSION 26
15 #endif
16
17 #define _FILE_OFFSET_BITS 64
18
19 #include <dirent.h>
20 #include <errno.h>
21 #include <fcntl.h>
22 #include <fuse.h>
23 #include <inttypes.h>
24 #include <libgen.h>
25 #include <pthread.h>
26 #include <sched.h>
27 #include <stdarg.h>
28 #include <stdbool.h>
29 #include <stdint.h>
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <time.h>
34 #include <unistd.h>
35 #include <wait.h>
36 #include <linux/magic.h>
37 #include <linux/sched.h>
38 #include <sys/epoll.h>
39 #include <sys/mman.h>
40 #include <sys/mount.h>
41 #include <sys/param.h>
42 #include <signal.h>
43 #include <sys/socket.h>
44 #include <sys/syscall.h>
45 #include <sys/sysinfo.h>
46 #include <sys/vfs.h>
47
48 #include "api_extensions.h"
49 #include "bindings.h"
50 #include "config.h"
51 #include "cgroup_fuse.h"
52 #include "cgroups/cgroup.h"
53 #include "cgroups/cgroup_utils.h"
54 #include "memory_utils.h"
55 #include "proc_cpuview.h"
56 #include "utils.h"
57
58 static bool can_use_pidfd;
59
60 /* Define pivot_root() if missing from the C library */
61 #ifndef HAVE_PIVOT_ROOT
62 static int pivot_root(const char *new_root, const char *put_old)
63 {
64 #ifdef __NR_pivot_root
65 return syscall(__NR_pivot_root, new_root, put_old);
66 #else
67 errno = ENOSYS;
68 return -1;
69 #endif
70 }
71 #else
72 extern int pivot_root(const char *new_root, const char *put_old);
73 #endif
74
75 /*
76 * A table caching which pid is init for a pid namespace.
77 * When looking up which pid is init for $qpid, we first
78 * 1. Stat /proc/$qpid/ns/pid.
79 * 2. Check whether the ino_t is in our store.
80 * a. if not, fork a child in qpid's ns to send us
81 * ucred.pid = 1, and read the initpid. Cache
82 * initpid and creation time for /proc/initpid
83 * in a new store entry.
84 * b. if so, verify that /proc/initpid still matches
85 * what we have saved. If not, clear the store
86 * entry and go back to a. If so, return the
87 * cached initpid.
88 */
89 struct pidns_init_store {
90 ino_t ino; /* inode number for /proc/$pid/ns/pid */
91 pid_t initpid; /* the pid of nit in that ns */
92 int init_pidfd;
93 long int ctime; /* the time at which /proc/$initpid was created */
94 struct pidns_init_store *next;
95 long int lastcheck;
96 };
97
98 /* lol - look at how they are allocated in the kernel */
99 #define PIDNS_HASH_SIZE 4096
100 #define HASH(x) ((x) % PIDNS_HASH_SIZE)
101
102 static struct pidns_init_store *pidns_hash_table[PIDNS_HASH_SIZE];
103 static pthread_mutex_t pidns_store_mutex = PTHREAD_MUTEX_INITIALIZER;
104
105 static void lock_mutex(pthread_mutex_t *l)
106 {
107 int ret;
108
109 ret = pthread_mutex_lock(l);
110 if (ret)
111 log_exit("%s - returned %d\n", strerror(ret), ret);
112 }
113
114 struct cgroup_ops *cgroup_ops;
115
116 static void unlock_mutex(pthread_mutex_t *l)
117 {
118 int ret;
119
120 ret = pthread_mutex_unlock(l);
121 if (ret)
122 log_exit("%s - returned %d\n", strerror(ret), ret);
123 }
124
125 static void store_lock(void)
126 {
127 lock_mutex(&pidns_store_mutex);
128 }
129
130 static void store_unlock(void)
131 {
132 unlock_mutex(&pidns_store_mutex);
133 }
134
135 /* /proc/ = 6
136 * +
137 * <pid-as-str> = INTTYPE_TO_STRLEN(pid_t)
138 * +
139 * \0 = 1
140 */
141 #define LXCFS_PROC_PID_LEN \
142 (STRLITERALLEN("/proc/") + INTTYPE_TO_STRLEN(uint64_t) + +1)
143
144 /* Must be called under store_lock */
145 static bool initpid_still_valid(struct pidns_init_store *entry)
146 {
147 bool valid = true;
148
149 if (entry->init_pidfd >= 0) {
150 if (pidfd_send_signal(entry->init_pidfd, 0, NULL, 0))
151 valid = false;
152 } else {
153 struct stat st;
154 char path[LXCFS_PROC_PID_LEN];
155
156 snprintf(path, sizeof(path), "/proc/%d", entry->initpid);
157
158 if (stat(path, &st) || entry->ctime != st.st_ctime)
159 valid = false;
160 }
161
162 return valid;
163 }
164
165 /* Must be called under store_lock */
166 static void remove_initpid(struct pidns_init_store *entry)
167 {
168 struct pidns_init_store *it;
169 int ino_hash;
170
171 lxcfs_debug("Removing cached entry for pid %d from init pid cache",
172 entry->initpid);
173
174 ino_hash = HASH(entry->ino);
175 if (pidns_hash_table[ino_hash] == entry) {
176 pidns_hash_table[ino_hash] = entry->next;
177 close_prot_errno_disarm(entry->init_pidfd);
178 free_disarm(entry);
179 return;
180 }
181
182 it = pidns_hash_table[ino_hash];
183 while (it) {
184 if (it->next == entry) {
185 it->next = entry->next;
186 close_prot_errno_disarm(entry->init_pidfd);
187 free_disarm(entry);
188 return;
189 }
190 it = it->next;
191 }
192 }
193
194 #define PURGE_SECS 5
195 /* Must be called under store_lock */
196 static void prune_initpid_store(void)
197 {
198 static long int last_prune = 0;
199 long int now, threshold;
200
201 if (!last_prune) {
202 last_prune = time(NULL);
203 return;
204 }
205
206 now = time(NULL);
207 if (now < last_prune + PURGE_SECS)
208 return;
209
210 lxcfs_debug("Pruning init pid cache");
211
212 last_prune = now;
213 threshold = now - 2 * PURGE_SECS;
214
215 for (int i = 0; i < PIDNS_HASH_SIZE; i++) {
216 for (struct pidns_init_store *entry = pidns_hash_table[i], *prev = NULL; entry;) {
217 if (entry->lastcheck < threshold) {
218 struct pidns_init_store *cur = entry;
219
220 lxcfs_debug("Removed cache entry for pid %d to init pid cache", cur->initpid);
221
222 if (prev)
223 prev->next = entry->next;
224 else
225 pidns_hash_table[i] = entry->next;
226 entry = entry->next;
227 close_prot_errno_disarm(cur->init_pidfd);
228 free_disarm(cur);
229 } else {
230 prev = entry;
231 entry = entry->next;
232 }
233 }
234 }
235 }
236
237 /* Must be called under store_lock */
238 static void save_initpid(struct stat *sb, pid_t pid)
239 {
240 __do_free struct pidns_init_store *entry = NULL;
241 __do_close_prot_errno int pidfd = -EBADF;
242 char path[LXCFS_PROC_PID_LEN];
243 struct lxcfs_opts *opts = fuse_get_context()->private_data;
244 struct stat st;
245 int ino_hash;
246
247 if (opts->use_pidfd && can_use_pidfd) {
248 pidfd = pidfd_open(pid, 0);
249 if (pidfd < 0)
250 return;
251 }
252
253 snprintf(path, sizeof(path), "/proc/%d", pid);
254 if (stat(path, &st))
255 return;
256
257 entry = malloc(sizeof(*entry));
258 if (entry)
259 return;
260
261 ino_hash = HASH(entry->ino);
262 *entry = (struct pidns_init_store){
263 .ino = sb->st_ino,
264 .initpid = pid,
265 .ctime = st.st_ctime,
266 .next = pidns_hash_table[ino_hash],
267 .lastcheck = time(NULL),
268 .init_pidfd = move_fd(pidfd),
269 };
270 pidns_hash_table[ino_hash] = move_ptr(entry);
271
272 lxcfs_debug("Added cache entry %d for pid %d to init pid cache", ino_hash, pid);
273 }
274
275 /*
276 * Given the stat(2) info for a nsfd pid inode, lookup the init_pid_store
277 * entry for the inode number and creation time. Verify that the init pid
278 * is still valid. If not, remove it. Return the entry if valid, NULL
279 * otherwise.
280 * Must be called under store_lock
281 */
282 static struct pidns_init_store *lookup_verify_initpid(struct stat *sb)
283 {
284 struct pidns_init_store *entry = pidns_hash_table[HASH(sb->st_ino)];
285
286 while (entry) {
287 if (entry->ino == sb->st_ino) {
288 if (initpid_still_valid(entry)) {
289 entry->lastcheck = time(NULL);
290 return entry;
291 }
292
293 remove_initpid(entry);
294 return NULL;
295 }
296 entry = entry->next;
297 }
298
299 return NULL;
300 }
301
302 static int send_creds_clone_wrapper(void *arg)
303 {
304 struct ucred cred;
305 char v;
306 int sock = *(int *)arg;
307
308 /* we are the child */
309 cred.uid = 0;
310 cred.gid = 0;
311 cred.pid = 1;
312 v = '1';
313 if (send_creds(sock, &cred, v, true) != SEND_CREDS_OK)
314 return 1;
315 return 0;
316 }
317
318 /*
319 * Let's use the "standard stack limit" (i.e. glibc thread size default) for
320 * stack sizes: 8MB.
321 */
322 #define __LXCFS_STACK_SIZE (8 * 1024 * 1024)
323 static pid_t lxcfs_clone(int (*fn)(void *), void *arg, int flags)
324 {
325 pid_t ret;
326 void *stack;
327
328 stack = malloc(__LXCFS_STACK_SIZE);
329 if (!stack)
330 return ret_errno(ENOMEM);
331
332 #ifdef __ia64__
333 ret = __clone2(fn, stack, __LXCFS_STACK_SIZE, flags | SIGCHLD, arg, NULL);
334 #else
335 ret = clone(fn, stack + __LXCFS_STACK_SIZE, flags | SIGCHLD, arg, NULL);
336 #endif
337 return ret;
338 }
339
340 #define LXCFS_PROC_PID_NS_LEN \
341 (STRLITERALLEN("/proc/") + INTTYPE_TO_STRLEN(uint64_t) + \
342 STRLITERALLEN("/ns/pid") + 1)
343
344 /*
345 * clone a task which switches to @task's namespace and writes '1'.
346 * over a unix sock so we can read the task's reaper's pid in our
347 * namespace
348 *
349 * Note: glibc's fork() does not respect pidns, which can lead to failed
350 * assertions inside glibc (and thus failed forks) if the child's pid in
351 * the pidns and the parent pid outside are identical. Using clone prevents
352 * this issue.
353 */
354 static void write_task_init_pid_exit(int sock, pid_t target)
355 {
356 __do_close_prot_errno int fd = -EBADF;
357 char path[LXCFS_PROC_PID_NS_LEN];
358 pid_t pid;
359
360 snprintf(path, sizeof(path), "/proc/%d/ns/pid", (int)target);
361 fd = open(path, O_RDONLY | O_CLOEXEC);
362 if (fd < 0)
363 log_exit("write_task_init_pid_exit open of ns/pid");
364
365 if (setns(fd, 0))
366 log_exit("Failed to setns to pid namespace of process %d", target);
367
368 pid = lxcfs_clone(send_creds_clone_wrapper, &sock, 0);
369 if (pid < 0)
370 _exit(EXIT_FAILURE);
371
372 if (pid != 0) {
373 if (!wait_for_pid(pid))
374 _exit(EXIT_FAILURE);
375
376 _exit(EXIT_SUCCESS);
377 }
378 }
379
380 static pid_t get_init_pid_for_task(pid_t task)
381 {
382 char v = '0';
383 pid_t pid_ret = -1;
384 pid_t pid;
385 int sock[2];
386 struct ucred cred;
387
388 if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sock) < 0)
389 return -1;
390
391 pid = fork();
392 if (pid < 0)
393 goto out;
394
395 if (pid == 0) {
396 close(sock[1]);
397 write_task_init_pid_exit(sock[0], task);
398 _exit(EXIT_SUCCESS);
399 }
400
401 if (!recv_creds(sock[1], &cred, &v))
402 goto out;
403
404 pid_ret = cred.pid;
405
406 out:
407 close(sock[0]);
408 close(sock[1]);
409 if (pid > 0)
410 wait_for_pid(pid);
411
412 return pid_ret;
413 }
414
415 pid_t lookup_initpid_in_store(pid_t pid)
416 {
417 pid_t answer = 0;
418 char path[LXCFS_PROC_PID_NS_LEN];
419 struct stat st;
420 struct pidns_init_store *entry;
421
422 snprintf(path, sizeof(path), "/proc/%d/ns/pid", pid);
423
424 store_lock();
425 if (stat(path, &st))
426 goto out;
427
428 entry = lookup_verify_initpid(&st);
429 if (entry) {
430 answer = entry->initpid;
431 goto out;
432 }
433
434 answer = get_init_pid_for_task(pid);
435 if (answer > 0)
436 save_initpid(&st, answer);
437
438 out:
439 /*
440 * Prune at the end in case we're returning the value we were about to
441 * return.
442 */
443 prune_initpid_store();
444
445 store_unlock();
446
447 return answer;
448 }
449
450 /*
451 * Functions needed to setup cgroups in the __constructor__.
452 */
453
454 static bool umount_if_mounted(void)
455 {
456 if (umount2(BASEDIR, MNT_DETACH) < 0 && errno != EINVAL) {
457 lxcfs_error("Failed to unmount %s: %s.\n", BASEDIR, strerror(errno));
458 return false;
459 }
460 return true;
461 }
462
463 /* __typeof__ should be safe to use with all compilers. */
464 typedef __typeof__(((struct statfs *)NULL)->f_type) fs_type_magic;
465 static bool has_fs_type(const struct statfs *fs, fs_type_magic magic_val)
466 {
467 return (fs->f_type == (fs_type_magic)magic_val);
468 }
469
470 /*
471 * looking at fs/proc_namespace.c, it appears we can
472 * actually expect the rootfs entry to very specifically contain
473 * " - rootfs rootfs "
474 * IIUC, so long as we've chrooted so that rootfs is not our root,
475 * the rootfs entry should always be skipped in mountinfo contents.
476 */
477 static bool is_on_ramfs(void)
478 {
479 __do_free char *line = NULL;
480 __do_fclose FILE *f = NULL;
481 size_t len = 0;
482
483 f = fopen("/proc/self/mountinfo", "re");
484 if (!f)
485 return false;
486
487 while (getline(&line, &len, f) != -1) {
488 int i;
489 char *p, *p2;
490
491 for (p = line, i = 0; p && i < 4; i++)
492 p = strchr(p + 1, ' ');
493 if (!p)
494 continue;
495
496 p2 = strchr(p + 1, ' ');
497 if (!p2)
498 continue;
499 *p2 = '\0';
500 if (strcmp(p + 1, "/") == 0) {
501 /* This is '/'. Is it the ramfs? */
502 p = strchr(p2 + 1, '-');
503 if (p && strncmp(p, "- rootfs rootfs ", 16) == 0)
504 return true;
505 }
506 }
507
508 return false;
509 }
510
511 static int pivot_enter()
512 {
513 __do_close_prot_errno int oldroot = -EBADF, newroot = -EBADF;
514
515 oldroot = open("/", O_DIRECTORY | O_RDONLY);
516 if (oldroot < 0)
517 return log_error_errno(-1, errno,
518 "Failed to open old root for fchdir");
519
520 newroot = open(ROOTDIR, O_DIRECTORY | O_RDONLY);
521 if (newroot < 0)
522 return log_error_errno(-1, errno,
523 "Failed to open new root for fchdir");
524
525 /* change into new root fs */
526 if (fchdir(newroot) < 0)
527 return log_error_errno(-1,
528 errno, "Failed to change directory to new rootfs: %s",
529 ROOTDIR);
530
531 /* pivot_root into our new root fs */
532 if (pivot_root(".", ".") < 0)
533 return log_error_errno(-1, errno,
534 "pivot_root() syscall failed: %s",
535 strerror(errno));
536
537 /*
538 * At this point the old-root is mounted on top of our new-root.
539 * To unmounted it we must not be chdir'd into it, so escape back
540 * to the old-root.
541 */
542 if (fchdir(oldroot) < 0)
543 return log_error_errno(-1, errno, "Failed to enter old root");
544
545 if (umount2(".", MNT_DETACH) < 0)
546 return log_error_errno(-1, errno, "Failed to detach old root");
547
548 if (fchdir(newroot) < 0)
549 return log_error_errno(-1, errno, "Failed to re-enter new root");
550
551 return 0;
552 }
553
554 static int chroot_enter()
555 {
556 if (mount(ROOTDIR, "/", NULL, MS_REC | MS_BIND, NULL)) {
557 lxcfs_error("Failed to recursively bind-mount %s into /.", ROOTDIR);
558 return -1;
559 }
560
561 if (chroot(".") < 0) {
562 lxcfs_error("Call to chroot() failed: %s.\n", strerror(errno));
563 return -1;
564 }
565
566 if (chdir("/") < 0) {
567 lxcfs_error("Failed to change directory: %s.\n", strerror(errno));
568 return -1;
569 }
570
571 return 0;
572 }
573
574 static int permute_and_enter(void)
575 {
576 struct statfs sb;
577
578 if (statfs("/", &sb) < 0) {
579 lxcfs_error("%s\n", "Could not stat / mountpoint.");
580 return -1;
581 }
582
583 /* has_fs_type() is not reliable. When the ramfs is a tmpfs it will
584 * likely report TMPFS_MAGIC. Hence, when it reports no we still check
585 * /proc/1/mountinfo. */
586 if (has_fs_type(&sb, RAMFS_MAGIC) || is_on_ramfs())
587 return chroot_enter();
588
589 if (pivot_enter() < 0) {
590 lxcfs_error("%s\n", "Could not perform pivot root.");
591 return -1;
592 }
593
594 return 0;
595 }
596
597 /* Prepare our new clean root. */
598 static int permute_prepare(void)
599 {
600 if (mkdir(ROOTDIR, 0700) < 0 && errno != EEXIST) {
601 lxcfs_error("%s\n", "Failed to create directory for new root.");
602 return -1;
603 }
604
605 if (mount("/", ROOTDIR, NULL, MS_BIND, 0) < 0) {
606 lxcfs_error("Failed to bind-mount / for new root: %s.\n", strerror(errno));
607 return -1;
608 }
609
610 if (mount(RUNTIME_PATH, ROOTDIR RUNTIME_PATH, NULL, MS_BIND, 0) < 0) {
611 lxcfs_error("Failed to bind-mount /run into new root: %s.\n", strerror(errno));
612 return -1;
613 }
614
615 if (mount(BASEDIR, ROOTDIR BASEDIR, NULL, MS_REC | MS_MOVE, 0) < 0) {
616 printf("Failed to move " BASEDIR " into new root: %s.\n", strerror(errno));
617 return -1;
618 }
619
620 return 0;
621 }
622
623 /* Calls chroot() on ramfs, pivot_root() in all other cases. */
624 static bool permute_root(void)
625 {
626 /* Prepare new root. */
627 if (permute_prepare() < 0)
628 return false;
629
630 /* Pivot into new root. */
631 if (permute_and_enter() < 0)
632 return false;
633
634 return true;
635 }
636
637 static bool cgfs_prepare_mounts(void)
638 {
639 if (!mkdir_p(BASEDIR, 0700)) {
640 lxcfs_error("%s\n", "Failed to create lxcfs cgroup mountpoint.");
641 return false;
642 }
643
644 if (!umount_if_mounted()) {
645 lxcfs_error("%s\n", "Failed to clean up old lxcfs cgroup mountpoint.");
646 return false;
647 }
648
649 if (unshare(CLONE_NEWNS) < 0) {
650 lxcfs_error("Failed to unshare mount namespace: %s.\n", strerror(errno));
651 return false;
652 }
653
654 cgroup_ops->mntns_fd = preserve_ns(getpid(), "mnt");
655 if (cgroup_ops->mntns_fd < 0) {
656 lxcfs_error("Failed to preserve mount namespace: %s.\n", strerror(errno));
657 return false;
658 }
659
660 if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0) < 0) {
661 lxcfs_error("Failed to remount / private: %s.\n", strerror(errno));
662 return false;
663 }
664
665 if (mount("tmpfs", BASEDIR, "tmpfs", 0, "size=100000,mode=700") < 0) {
666 lxcfs_error("%s\n", "Failed to mount tmpfs over lxcfs cgroup mountpoint.");
667 return false;
668 }
669
670 return true;
671 }
672
673 static bool cgfs_mount_hierarchies(void)
674 {
675 if (!mkdir_p(BASEDIR DEFAULT_CGROUP_MOUNTPOINT, 0755))
676 return false;
677
678 if (!cgroup_ops->mount(cgroup_ops, BASEDIR))
679 return false;
680
681 for (struct hierarchy **h = cgroup_ops->hierarchies; h && *h; h++) {
682 __do_free char *path = must_make_path(BASEDIR, (*h)->mountpoint, NULL);
683 (*h)->fd = open(path, O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW);
684 if ((*h)->fd < 0)
685 return false;
686 }
687
688 return true;
689 }
690
691 static bool cgfs_setup_controllers(void)
692 {
693 if (!cgfs_prepare_mounts())
694 return false;
695
696 if (!cgfs_mount_hierarchies())
697 return log_error_errno(false, errno, "Failed to set up private lxcfs cgroup mounts");
698
699 if (!permute_root())
700 return false;
701
702 return true;
703 }
704
705 static void __attribute__((constructor)) lxcfs_init(void)
706 {
707 __do_close_prot_errno int init_ns = -EBADF, pidfd = -EBADF;
708 int i = 0;
709 pid_t pid;
710 char *cret;
711 char cwd[MAXPATHLEN];
712
713 cgroup_ops = cgroup_init();
714 if (!cgroup_ops)
715 log_exit("Failed to initialize cgroup support");
716
717 /* Preserve initial namespace. */
718 pid = getpid();
719 init_ns = preserve_ns(pid, "mnt");
720 if (init_ns < 0)
721 log_exit("Failed to preserve initial mount namespace");
722
723 cret = getcwd(cwd, MAXPATHLEN);
724 if (!cret)
725 log_exit("%s - Could not retrieve current working directory", strerror(errno));
726
727 /* This function calls unshare(CLONE_NEWNS) our initial mount namespace
728 * to privately mount lxcfs cgroups. */
729 if (!cgfs_setup_controllers())
730 log_exit("Failed to setup private cgroup mounts for lxcfs");
731
732 if (setns(init_ns, 0) < 0)
733 log_exit("%s - Failed to switch back to initial mount namespace", strerror(errno));
734
735 if (!cret || chdir(cwd) < 0)
736 log_exit("%s - Could not change back to original working directory", strerror(errno));
737
738 if (!init_cpuview())
739 log_exit("Failed to init CPU view");
740
741 fprintf(stderr, "mount namespace: %d\n", cgroup_ops->mntns_fd);
742 fprintf(stderr, "hierarchies:\n");
743
744 for (struct hierarchy **h = cgroup_ops->hierarchies; h && *h; h++, i++) {
745 __do_free char *controllers = lxc_string_join(",", (const char **)(*h)->controllers, false);
746 fprintf(stderr, " %2d: fd: %3d: %s\n", i, (*h)->fd, controllers ?: "");
747 }
748
749 pidfd = pidfd_open(pid, 0);
750 if (pidfd >= 0 && pidfd_send_signal(pidfd, 0, NULL, 0) == 0) {
751 can_use_pidfd = true;
752 fprintf(stderr, "Kernel supports pidfds\n");
753 }
754
755 fprintf(stderr, "api_extensions:\n");
756 for (i = 0; i < nr_api_extensions; i++)
757 fprintf(stderr, "- %s\n", api_extensions[i]);
758 }
759
760 static void __attribute__((destructor)) lxcfs_exit(void)
761 {
762 lxcfs_debug("%s\n", "Running destructor for liblxcfs");
763 free_cpuview();
764 cgroup_exit(cgroup_ops);
765 }