diff options
author | Devaev Maxim <[email protected]> | 2019-11-07 06:42:48 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2019-11-07 06:42:48 +0300 |
commit | 8abe4b1ac9d341eec17d211328b9f3cd9b59fa0a (patch) | |
tree | 87d08459405e48edd91c09662d440edc378de9a2 | |
parent | 10f8c2b3352c951549cc1249d6b24789fb94d688 (diff) |
v2 testing
-rw-r--r-- | Makefile | 14 | ||||
-rw-r--r-- | kvmd/plugins/msd/otg/__init__.py | 10 | ||||
-rw-r--r-- | kvmd/plugins/msd/otg/drive.py | 4 | ||||
-rw-r--r-- | testenv/Dockerfile | 9 | ||||
-rw-r--r-- | testenv/v2-hdmi.override.yaml | 32 |
5 files changed, 56 insertions, 13 deletions
@@ -7,6 +7,8 @@ TESTENV_LOOP ?= /dev/loop7 USTREAMER_MIN_VERSION ?= $(shell grep -o 'ustreamer>=[^"]\+' PKGBUILD | sed 's/ustreamer>=//g') +DEFAULT_PLATFORM ?= v1-vga + # ===== define optbool @@ -54,8 +56,8 @@ tox: testenv -it $(TESTENV_IMAGE) bash -c " \ cp /usr/share/kvmd/configs.default/kvmd/*.yaml /etc/kvmd \ && cp /usr/share/kvmd/configs.default/kvmd/*passwd /etc/kvmd \ - && cp /usr/share/kvmd/configs.default/kvmd/main/v1-vga.yaml /etc/kvmd/main.yaml \ - && cp /src/testenv/v1-vga.override.yaml /etc/kvmd/override.yaml \ + && cp /usr/share/kvmd/configs.default/kvmd/main/$(if $(P),$(P),v1-vga).yaml /etc/kvmd/main.yaml \ + && cp /src/testenv/$(if $(P),$(P),v1-vga).override.yaml /etc/kvmd/override.yaml \ && cd /src \ && tox -q -c testenv/tox.ini $(if $(E),-e $(E),-p auto) \ " @@ -78,8 +80,8 @@ run: testenv && cp -r /usr/share/kvmd/configs.default/nginx/* /etc/kvmd/nginx \ && cp /usr/share/kvmd/configs.default/kvmd/*.yaml /etc/kvmd \ && cp /usr/share/kvmd/configs.default/kvmd/*passwd /etc/kvmd \ - && cp /usr/share/kvmd/configs.default/kvmd/main/v1-vga.yaml /etc/kvmd/main.yaml \ - && cp /testenv/v1-vga.override.yaml /etc/kvmd/override.yaml \ + && cp /usr/share/kvmd/configs.default/kvmd/main/$(if $(P),$(P),$(DEFAULT_PLATFORM)).yaml /etc/kvmd/main.yaml \ + && cp /testenv/$(if $(P),$(P),$(DEFAULT_PLATFORM)).override.yaml /etc/kvmd/override.yaml \ && nginx -c /etc/kvmd/nginx/nginx.conf -g 'user http; error_log stderr;' \ && ln -s $(TESTENV_VIDEO) /dev/kvmd-video \ && (losetup -d /dev/kvmd-msd || true) \ @@ -100,8 +102,8 @@ run-ipmi: testenv -it $(TESTENV_IMAGE) /bin/bash -c " \ cp /usr/share/kvmd/configs.default/kvmd/*.yaml /etc/kvmd \ && cp /usr/share/kvmd/configs.default/kvmd/*passwd /etc/kvmd \ - && cp /usr/share/kvmd/configs.default/kvmd/main/v1-vga.yaml /etc/kvmd/main.yaml \ - && cp /testenv/v1-vga.override.yaml /etc/kvmd/override.yaml \ + && cp /usr/share/kvmd/configs.default/kvmd/main/$(if $(P),$(P),$(DEFAULT_PLATFORM)).yaml /etc/kvmd/main.yaml \ + && cp /testenv/$(if $(P),$(P),$(DEFAULT_PLATFORM)).override.yaml /etc/kvmd/override.yaml \ && $(if $(CMD),$(CMD),python -m kvmd.apps.ipmi) \ " diff --git a/kvmd/plugins/msd/otg/__init__.py b/kvmd/plugins/msd/otg/__init__.py index 76ef7d07..d6d5a36f 100644 --- a/kvmd/plugins/msd/otg/__init__.py +++ b/kvmd/plugins/msd/otg/__init__.py @@ -137,6 +137,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes remount_cmd: List[str], unlock_cmd: List[str], + sysfs_prefix: str, gadget: str, # XXX: Not from options, see /kvmd/apps/kvmd/__init__.py for details ) -> None: @@ -147,7 +148,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes self.__remount_cmd = remount_cmd self.__unlock_cmd = unlock_cmd - self.__drive = Drive(gadget, instance=0, lun=0) + self.__drive = Drive(sysfs_prefix, gadget, instance=0, lun=0) self.__new_file: Optional[aiofiles.base.AiofilesContextManager] = None self.__new_file_written = 0 @@ -164,9 +165,10 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes def get_plugin_options(cls) -> Dict: sudo = ["/usr/bin/sudo", "--non-interactive"] return { - "storage": Option("/var/lib/kvmd/msd", type=valid_abs_dir, unpack_as="storage_path"), - "remount_cmd": Option([*sudo, "/usr/bin/kvmd-helper-otgmsd-remount", "{mode}"], type=valid_command), - "unlock_cmd": Option([*sudo, "/usr/bin/kvmd-helper-otgmsd-unlock", "unlock"], type=valid_command), + "storage": Option("/var/lib/kvmd/msd", type=valid_abs_dir, unpack_as="storage_path"), + "remount_cmd": Option([*sudo, "/usr/bin/kvmd-helper-otgmsd-remount", "{mode}"], type=valid_command), + "unlock_cmd": Option([*sudo, "/usr/bin/kvmd-helper-otgmsd-unlock", "unlock"], type=valid_command), + "sysfs_prefix": Option("", type=(lambda arg: str(arg).strip())), } async def get_state(self) -> Dict: diff --git a/kvmd/plugins/msd/otg/drive.py b/kvmd/plugins/msd/otg/drive.py index e6457527..ff91afcf 100644 --- a/kvmd/plugins/msd/otg/drive.py +++ b/kvmd/plugins/msd/otg/drive.py @@ -34,9 +34,9 @@ class MsdDriveLockedError(MsdOperationError): # ===== class Drive: - def __init__(self, gadget: str, instance: int, lun: int) -> None: + def __init__(self, prefix: str, gadget: str, instance: int, lun: int) -> None: self.__path = os.path.join( - "/sys/kernel/config/usb_gadget", + f"{prefix}/sys/kernel/config/usb_gadget", gadget, f"functions/mass_storage.usb{instance}/lun.{lun}", ) diff --git a/testenv/Dockerfile b/testenv/Dockerfile index a33af7b1..9c23d29c 100644 --- a/testenv/Dockerfile +++ b/testenv/Dockerfile @@ -41,6 +41,13 @@ RUN git clone https://github.com/pikvm/ustreamer \ COPY testenv/requirements.txt requirements.txt RUN pip install -r requirements.txt -RUN mkdir -p /etc/kvmd/nginx +RUN mkdir -p \ + /etc/kvmd/nginx \ + /var/lib/kvmd/msd/{images,meta} \ + /fake_sysfs/sys/kernel/config/usb_gadget/kvmd/functions/mass_storage.usb0/lun.0 \ + && cd /fake_sysfs/sys/kernel/config/usb_gadget/kvmd/functions/mass_storage.usb0/lun.0 \ + && touch file \ + && echo 1 > cdrom \ + && echo 1 > ro CMD /bin/bash diff --git a/testenv/v2-hdmi.override.yaml b/testenv/v2-hdmi.override.yaml new file mode 100644 index 00000000..a205d666 --- /dev/null +++ b/testenv/v2-hdmi.override.yaml @@ -0,0 +1,32 @@ +kvmd: + server: + unix_mode: 0666 + + hid: + keyboard: + device: /dev/null + mouse: + device: /dev/null + noop: true + + msd: + remount_cmd: /bin/true + unlock_cmd: /bin/true + sysfs_prefix: /fake_sysfs + + streamer: + desired_fps: 30 + max_fps: 40 + cmd: + - "/usr/bin/ustreamer" + - "--device=/dev/kvmd-video" + - "--quality={quality}" + - "--desired-fps={desired_fps}" + - "--resolution=800x600" + - "--last-as-blank=0" + - "--unix={unix}" + - "--unix-rm" + - "--unix-mode=0666" + - "--exit-on-parent-death" + - "--process-name-prefix={process_name_prefix}" + - "--no-log-colors" |