X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/waydroid.git/blobdiff_plain/4154902c599e7faf8fa35d1f9f31c1fa3b0b354e..HEAD:/tools/actions/container_manager.py diff --git a/tools/actions/container_manager.py b/tools/actions/container_manager.py index bb3b650..b14dd63 100644 --- a/tools/actions/container_manager.py +++ b/tools/actions/container_manager.py @@ -3,11 +3,8 @@ from shutil import which import logging import os -import time import glob import signal -import sys -import uuid import tools.config from tools import helpers from tools import services @@ -80,16 +77,19 @@ def set_permissions(args, perm_list=None, mode="777"): "/dev/mtk_cmdq", # Graphics - "/dev/dri", "/dev/graphics", "/dev/pvr_sync", "/dev/ion", ] + # DRM render nodes + perm_list.extend(glob.glob("/dev/dri/renderD*")) # Framebuffers perm_list.extend(glob.glob("/dev/fb*")) # Videos perm_list.extend(glob.glob("/dev/video*")) + # DMA-BUF Heaps + perm_list.extend(glob.glob("/dev/dma_heap/*")) for path in perm_list: chmod(path, mode) @@ -132,6 +132,8 @@ def do_start(args, session): if "session" in args: raise RuntimeError("Already tracking a session") + logging.info("Starting up container for a new session") + # Networking command = [tools.config.tools_src + "/data/scripts/waydroid-net.sh", "start"] @@ -146,14 +148,28 @@ def do_start(args, session): if which("start"): command = ["start", "cgroup-lite"] tools.helpers.run.user(args, command, check=False) + + # Keep schedtune around in case nesting is supported if os.path.ismount("/sys/fs/cgroup/schedtune"): - command = ["umount", "-l", "/sys/fs/cgroup/schedtune"] - tools.helpers.run.user(args, command, check=False) + try: + os.mkdir("/sys/fs/cgroup/schedtune/probe0") + os.mkdir("/sys/fs/cgroup/schedtune/probe0/probe1") + except: + command = ["umount", "-l", "/sys/fs/cgroup/schedtune"] + tools.helpers.run.user(args, command, check=False) + finally: + if os.path.exists("/sys/fs/cgroup/schedtune/probe0/probe1"): + os.rmdir("/sys/fs/cgroup/schedtune/probe0/probe1") + if os.path.exists("/sys/fs/cgroup/schedtune/probe0"): + os.rmdir("/sys/fs/cgroup/schedtune/probe0") #TODO: remove NFC hacks if which("stop"): command = ["stop", "nfcd"] tools.helpers.run.user(args, command, check=False) + elif which("systemctl") and (tools.helpers.run.user(args, ["systemctl", "is-active", "-q", "nfcd"], check=False) == 0): + command = ["systemctl", "stop", "nfcd"] + tools.helpers.run.user(args, command, check=False) # Set permissions set_permissions(args) @@ -178,6 +194,8 @@ def do_start(args, session): args.session = session def stop(args, quit_session=True): + logging.info("Stopping container") + try: services.hardware_manager.stop(args) status = helpers.lxc.status(args) @@ -195,6 +213,9 @@ def stop(args, quit_session=True): if which("start"): command = ["start", "nfcd"] tools.helpers.run.user(args, command, check=False) + elif which("systemctl") and (tools.helpers.run.user(args, ["systemctl", "is-enabled", "-q", "nfcd"], check=False) == 0): + command = ["systemctl", "start", "nfcd"] + tools.helpers.run.user(args, command, check=False) # Sensors if which("waydroid-sensord"): @@ -215,6 +236,7 @@ def stop(args, quit_session=True): if "session" in args: if quit_session: + logging.info("Terminating session because the container was stopped") try: os.kill(int(args.session["pid"]), signal.SIGUSR1) except: