summaryrefslogtreecommitdiff
path: root/kvmd
diff options
context:
space:
mode:
authormfunkey <[email protected]>2022-01-06 03:01:45 +0100
committerGitHub <[email protected]>2022-01-06 05:01:45 +0300
commit04f9bbe56894e3d4a5cc43f530099266e76f987b (patch)
tree7508f45b2b3db3a5e452a700f53ff24eaaea8e8c /kvmd
parent9f44a120a76172c2caa8cce8158c4c53345c1bcd (diff)
Make kvmd-net start/stop work without error while changing configuration (#76)
Diffstat (limited to 'kvmd')
-rw-r--r--kvmd/apps/otg/__init__.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/kvmd/apps/otg/__init__.py b/kvmd/apps/otg/__init__.py
index 55076ff9..ffda8443 100644
--- a/kvmd/apps/otg/__init__.py
+++ b/kvmd/apps/otg/__init__.py
@@ -68,11 +68,16 @@ def _rmdir(path: str) -> None:
os.rmdir(path)
-def _unlink(path: str) -> None:
- get_logger().info("RM ------ %s", path)
+def _unlink(path: str, optional: bool=False) -> None:
+ logger = get_logger()
+ if optional and not os.access(path, os.F_OK):
+ logger.info("SKIP ---- %s", path)
+ return
+ logger.info("RM ------ %s", path)
os.unlink(path)
+
def _write(path: str, text: str, optional: bool=False) -> None:
logger = get_logger()
if optional and not os.access(path, os.F_OK):
@@ -267,8 +272,7 @@ def _cmd_stop(config: Section) -> None:
logger.info("Disabling gadget %r ...", config.otg.gadget)
_write(join(gadget_path, "UDC"), "")
- if config.otg.devices.ethernet.driver == "rndis":
- _unlink(join(gadget_path, "os_desc/c.1"))
+ _unlink(join(gadget_path, "os_desc/c.1"), True)
config_path = join(gadget_path, "configs/c.1")
for func in os.listdir(config_path):