mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-15 10:40:28 +08:00
optional host_mac and kvm_mac
This commit is contained in:
parent
630593492a
commit
1b62570466
@ -404,8 +404,8 @@ def _get_config_scheme() -> Dict:
|
|||||||
|
|
||||||
"ethernet": {
|
"ethernet": {
|
||||||
"enabled": Option(False, type=valid_bool),
|
"enabled": Option(False, type=valid_bool),
|
||||||
"host_mac": Option("", type=valid_mac, only_if="enabled"),
|
"host_mac": Option("", type=(lambda arg: (valid_mac(arg) if arg else ""))),
|
||||||
"kvm_mac": Option("", type=valid_mac, only_if="enabled"),
|
"kvm_mac": Option("", type=(lambda arg: (valid_mac(arg) if arg else ""))),
|
||||||
},
|
},
|
||||||
|
|
||||||
"drives": {
|
"drives": {
|
||||||
|
|||||||
@ -112,12 +112,14 @@ def _create_serial(gadget_path: str, config_path: str) -> None:
|
|||||||
|
|
||||||
|
|
||||||
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, host_mac: str, kvm_mac: str) -> None:
|
||||||
if host_mac == kvm_mac:
|
if host_mac and kvm_mac and host_mac == kvm_mac:
|
||||||
raise RuntimeError("Ethernet host_mac should not be equal to 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, "functions/ecm.usb0")
|
||||||
_mkdir(func_path)
|
_mkdir(func_path)
|
||||||
_write(join(func_path, "host_addr"), host_mac)
|
if host_mac:
|
||||||
_write(join(func_path, "dev_addr"), kvm_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, "ecm.usb0"))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user