summaryrefslogtreecommitdiff
path: root/kvmd
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-09-30 08:29:12 +0300
committerDevaev Maxim <[email protected]>2020-09-30 08:52:00 +0300
commit4bdb06f108543239b7cb3a547f3ace853b590274 (patch)
tree3def9304403be40e6c19d5bc9e1046099555898f /kvmd
parent1b62570466804a2fe0a21bbdccd7a289c8974496 (diff)
configurable ethernet driver
Diffstat (limited to 'kvmd')
-rw-r--r--kvmd/apps/__init__.py2
-rw-r--r--kvmd/apps/otg/__init__.py6
-rw-r--r--kvmd/validators/hw.py5
3 files changed, 10 insertions, 3 deletions
diff --git a/kvmd/apps/__init__.py b/kvmd/apps/__init__.py
index 149782c4..038441f2 100644
--- a/kvmd/apps/__init__.py
+++ b/kvmd/apps/__init__.py
@@ -94,6 +94,7 @@ from ..validators.kvm import valid_ugpio_view_table
from ..validators.hw import valid_gpio_pin
from ..validators.hw import valid_otg_gadget
from ..validators.hw import valid_otg_id
+from ..validators.hw import valid_otg_ethernet
# =====
@@ -404,6 +405,7 @@ def _get_config_scheme() -> Dict:
"ethernet": {
"enabled": Option(False, type=valid_bool),
+ "driver": Option("ecm", type=valid_otg_ethernet),
"host_mac": Option("", type=(lambda arg: (valid_mac(arg) if arg else ""))),
"kvm_mac": Option("", type=(lambda arg: (valid_mac(arg) if arg else ""))),
},
diff --git a/kvmd/apps/otg/__init__.py b/kvmd/apps/otg/__init__.py
index 6b98dc81..d727e938 100644
--- a/kvmd/apps/otg/__init__.py
+++ b/kvmd/apps/otg/__init__.py
@@ -111,16 +111,16 @@ def _create_serial(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:
+def _create_ethernet(gadget_path: str, config_path: str, driver: str, host_mac: str, kvm_mac: str) -> None:
if host_mac and kvm_mac and host_mac == kvm_mac:
raise RuntimeError("Ethernet host_mac should not be equal to kvm_mac")
- func_path = join(gadget_path, "functions/ecm.usb0")
+ func_path = join(gadget_path, f"functions/{driver}.usb0")
_mkdir(func_path)
if host_mac:
_write(join(func_path, "host_addr"), host_mac)
if kvm_mac:
_write(join(func_path, "dev_addr"), kvm_mac)
- _symlink(func_path, join(config_path, "ecm.usb0"))
+ _symlink(func_path, join(config_path, f"{driver}.usb0"))
def _create_hid(gadget_path: str, config_path: str, instance: int, hid: Hid) -> None:
diff --git a/kvmd/validators/hw.py b/kvmd/validators/hw.py
index 59a0363d..287786df 100644
--- a/kvmd/validators/hw.py
+++ b/kvmd/validators/hw.py
@@ -23,6 +23,7 @@
from typing import Any
from . import check_in_list
+from . import check_string_in_list
from . import check_re_match
from . import check_len
@@ -51,3 +52,7 @@ def valid_otg_gadget(arg: Any) -> str:
def valid_otg_id(arg: Any) -> int:
return int(valid_number(arg, min=0, max=65535, name="OTG ID"))
+
+
+def valid_otg_ethernet(arg: Any) -> str:
+ return check_string_in_list(arg, "OTG Ethernet driver", ["ecm", "eem", "ncm", "rndis"])