summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorentin LABBE <clabbe@baylibre.com>2019-01-07 16:42:10 +0100
committerCorentin LABBE <clabbe@baylibre.com>2019-01-07 16:44:11 +0100
commit866fbb4ed9f7bcc86900ab48f400a29d59013fa9 (patch)
tree0efb0ed4281e934b6d2d42824416d61cc629a139
parentc9c15fa790ddc7da4f12f929c76f3cd5ff682760 (diff)
lavalab-gen.py: prevent duplication of device map
If two qemu with KVM enabled are on the same node, the device map "/dev/kvm:/dev/kvm" will be present twice. This patch adds an helper for preventing this. This will also clean the code later which adds serial device.
-rwxr-xr-xlavalab-gen.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/lavalab-gen.py b/lavalab-gen.py
index 1d91f23..e814e5e 100755
--- a/lavalab-gen.py
+++ b/lavalab-gen.py
@@ -66,6 +66,17 @@ template_settings_conf = string.Template("""
}
""")
+def dockcomp_add_device(dockcomp, worker_name, devicemap):
+ if "devices" in dockcomp["services"][worker_name]:
+ dc_devices = dockcomp["services"][worker_name]["devices"]
+ else:
+ dockcomp["services"][worker_name]["devices"] = []
+ dc_devices = dockcomp["services"][worker_name]["devices"]
+ for dmap in dc_devices:
+ if dmap == devicemap:
+ return
+ dc_devices.append(devicemap)
+
def usage():
print("%s [boardsfile.yaml]" % sys.argv[0])
@@ -424,12 +435,7 @@ def main():
if "kvm" in board:
use_kvm = board["kvm"]
if use_kvm:
- if "devices" in dockcomp["services"][worker_name]:
- dc_devices = dockcomp["services"][worker_name]["devices"]
- else:
- dockcomp["services"][worker_name]["devices"] = []
- dc_devices = dockcomp["services"][worker_name]["devices"]
- dc_devices.append("/dev/kvm:/dev/kvm")
+ dockcomp_add_device(dockcomp, worker_name, "/dev/kvm:/dev/kvm")
# board specific hacks
if devicetype == "qemu" and not use_kvm:
device_line += "{% set no_kvm = True %}\n"
@@ -457,13 +463,8 @@ def main():
fp = open("output/%s/udev/99-lavaworker-udev.rules" % host, "a")
fp.write(udev_line)
fp.close()
- if "devices" in dockcomp["services"][worker_name]:
- dc_devices = dockcomp["services"][worker_name]["devices"]
- else:
- dockcomp["services"][worker_name]["devices"] = []
- dc_devices = dockcomp["services"][worker_name]["devices"]
if not "bind_dev" in slave:
- dc_devices.append("/dev/%s:/dev/%s" % (board_name, board_name))
+ dockcomp_add_device(dockcomp, worker_name, "/dev/%s:/dev/%s" % (board_name, board_name))
use_conmux = False
use_ser2net = False
use_screen = False