diff options
author | Devaev Maxim <[email protected]> | 2020-09-30 03:53:39 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-09-30 04:53:21 +0300 |
commit | 771640a79c437ecc39296faee1c4dedb016d71a2 (patch) | |
tree | f71c1818c5bd1da6209e238829e3a43c231c683a /kvmd/apps/otg/__init__.py | |
parent | a86ec65024774bab1b6b62ec30a8cf46c0e1613d (diff) |
options to configure otg ethernet
Diffstat (limited to 'kvmd/apps/otg/__init__.py')
-rw-r--r-- | kvmd/apps/otg/__init__.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/kvmd/apps/otg/__init__.py b/kvmd/apps/otg/__init__.py index 8f5444bc..2085134b 100644 --- a/kvmd/apps/otg/__init__.py +++ b/kvmd/apps/otg/__init__.py @@ -97,6 +97,7 @@ def _find_udc(udc: str) -> str: def _check_config(config: Section) -> None: if ( not config.otg.acm.enabled + and not config.otg.ethernet.enabled and config.kvmd.hid.type != "otg" and config.kvmd.msd.type != "otg" ): @@ -110,6 +111,16 @@ def _create_acm(gadget_path: str, config_path: str) -> None: _symlink(func_path, join(config_path, "acm.usb0")) +def _create_ethernet(gadget_path: str, config_path: str, host_mac: str, kvm_mac: str) -> None: + if host_mac == kvm_mac: + raise RuntimeError("Ethernet host_mac should not be equal to kvm_mac") + func_path = join(gadget_path, "functions/ecm.usb0") + _mkdir(func_path) + _write(join(func_path, "host_addr"), host_mac) + _write(join(func_path, "dev_addr"), kvm_mac) + _symlink(func_path, join(config_path, "ecm.usb0")) + + def _create_hid(gadget_path: str, config_path: str, instance: int, hid: Hid) -> None: func_path = join(gadget_path, f"functions/hid.usb{instance}") _mkdir(func_path) @@ -181,6 +192,10 @@ def _cmd_start(config: Section) -> None: logger.info("Required ACM") _create_acm(gadget_path, config_path) + if config.otg.ethernet.enabled: + logger.info("Required Ethernet") + _create_ethernet(gadget_path, config_path, config.otg.ethernet.host_mac, config.otg.ethernet.kvm_mac) + if config.kvmd.hid.type == "otg": logger.info("Required HID") _create_hid(gadget_path, config_path, 0, KEYBOARD_HID) |