Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
257272b
fix - change class for file code icon
anaHue Jul 4, 2022
d217a51
Merge pull request #829 from anaHue/fix_missing_icon
Drumor Jul 4, 2022
8387d00
add - submission date to feedback
anaHue Jul 6, 2022
92edb30
use strftime instead of replacing microseconds
anaHue Jul 7, 2022
752bc46
corrected the display for submission date
anaHue Jul 7, 2022
eccc423
Merge pull request #831 from anaHue/fix_issue_278
Drumor Jul 7, 2022
d8c2ecc
[frontend/course admin] switch course settings layout to tabs (#821)
Drumor Jul 12, 2022
d5726df
[frontend/course_admin] fix bad student count (#836)
Drumor Jul 12, 2022
7de1fb1
[filesystems/local] use copy2 instead of copy (#840)
anaHue Jul 12, 2022
b55107c
[frontend/course_admin] move tags page to settings page (#841)
Drumor Jul 15, 2022
c1f47ac
[course_admin/edit_tabs] add network interface hint tooltip (#839)
anaHue Jul 15, 2022
fc5bde4
[frontend] Moving the concept of weight into the Task Dispenser (#849)
maleclercq Jul 26, 2022
7a4a27d
[task_dispenser/combinatory_test] now return a proper dispenser data …
maleclercq Jul 27, 2022
7c05707
[frontend] Moving the number of stored submission into the Task Dispe…
maleclercq Jul 27, 2022
18d6025
[ci] temporarily mitigate issue with markupsafe
anthonygego Jul 27, 2022
78e05cf
[frontend] Moving the concept of evaluation submission into the Task …
maleclercq Jul 28, 2022
4b64864
[doc] fix #856 : typo in hidden-until docs
anthonygego Jul 29, 2022
ae95c5e
[frontend] Categories managed by the Task Dispenser (#855)
maleclercq Jul 29, 2022
83a76a0
[routes] adapt CookielessConverter to new werkzeug router
anthonygego Aug 3, 2022
a1dc28f
[backend] do not erase previous state in case of errors
anthonygego Aug 10, 2022
cad231e
Merge pull request #857 from UCL-INGI/keep_state_on_errors
Drumor Aug 10, 2022
0c52359
[installer] Add default configuration flag (#860)
nrybowski Sep 12, 2022
300e7ce
[audiences] replace import/export format by human-readable CSV
Drumor Sep 13, 2022
d495824
[frontend/parsable_text] fix hidden-until behaviour when time is passed
anthonygego Sep 13, 2022
e7ffd0d
[frontend/tasks] add ssh client option to use password authentication…
FlyearthR Sep 22, 2022
64d71e3
Update issue templates
nrybowski Sep 22, 2022
0a882b1
[frontend/i18n] fix variable name in portuguese string
anthonygego Oct 10, 2022
706ec66
Translated using Weblate (French)
anthonygego Aug 31, 2022
b8523f7
[frontend/course_admin] add additional course fields (#825)
Drumor Oct 17, 2022
3599289
Merge pull request #859 from INGIbot/weblate-inginious-frontend
anthonygego Oct 17, 2022
39f3a86
[frontend/tests] Removing and migrating legacy tests (#879)
Drumor Oct 25, 2022
0959be6
[frontend/installer] fix containers build (#877)
Drumor Oct 25, 2022
bed7d63
[utils/task-tester] Updated version of task-tester
nrybowski Aug 10, 2022
0ca5988
[utils/task-tester] Add generic way to add problem types from plugins
nrybowski Sep 7, 2022
dea7f3d
[utils/task-tester] Improve logs
nrybowski Sep 7, 2022
e77822c
[utils/task-tester] Move to dir and add submissions anonymizer
nrybowski Sep 7, 2022
38ba24c
[utils/task-tester] Dump anonymized submissions in course-alike struc…
nrybowski Sep 8, 2022
633218d
[utils/task-tester] Improve submissions anonymizer script
nrybowski Sep 12, 2022
4e6dc94
[utils/task_tester] Modular anonymized fields
nrybowski Sep 22, 2022
f4c8ae3
[utils/task-tester] Fix failing tag value concatanation to logs
nrybowski Oct 5, 2022
6e49a9d
[utils/task-tester] Refactor logging system
nrybowski Oct 12, 2022
0ae0236
[utils/task-tester] Add warning on task anonymizer
nrybowski Oct 12, 2022
565f102
[utils/task-tester] Update scripts documentation
nrybowski Oct 19, 2022
7aec561
[utils/task-tester] Add simple tests and get taskid from submission
nrybowski Nov 3, 2022
ce34c1f
[utils/task-tester] Automatically load problem types
nrybowski Nov 3, 2022
7e6a664
[docs] update setup instructions for Ubuntu (#873)
Drumor Nov 3, 2022
daa97fe
Add roadmap link in README (#889)
nrybowski Nov 3, 2022
f6c2108
Translated using Weblate (French)
NoaQuenon Nov 2, 2022
f0918bd
Merge pull request #890 from INGIbot/weblate-inginious-frontend
anthonygego Nov 16, 2022
427d4d7
Merge pull request #861 from nrybowski/task_test
anthonygego Nov 28, 2022
103dc9e
[common/tasks_problems] Problem types auto-discovery (#866)
nrybowski Nov 30, 2022
c38f4de
File extensions must be separated by commas
tbarbette Dec 7, 2022
443e0e2
Merge pull request #902 from tbarbette/patch-1
Drumor Dec 7, 2022
d84f8c9
[backend] BackendJobDone should be sent to the job initiating client
anthonygego Dec 14, 2022
dd96507
Update installation.rst
petitpouletrose Dec 21, 2022
85f764d
Merge pull request #906 from petitpouletrose/patch-1
Drumor Jan 2, 2023
8e05424
Update copyright dates
anthonygego Feb 2, 2023
a0dfe26
[frontend/tasks] fix call for task_user_can_submit
anthonygego Feb 9, 2023
ed6d038
Added translation using Weblate (Hebrew)
yarons Feb 11, 2023
adceeb4
Translated using Weblate (Hebrew)
yarons Feb 11, 2023
96ec030
Translated using Weblate (Hebrew)
yarons Feb 11, 2023
6e4f025
Merge pull request #911 from INGIbot/weblate-inginious-frontend
Drumor Feb 13, 2023
3de90fb
[docker_agent] fix container timestamp for docker 23+
anthonygego Feb 28, 2023
9f645aa
Merge pull request #913 from UCL-INGI/container_created_time
nrybowski Feb 28, 2023
1b778bb
[agent_docker] add support for nvidia runtime
anthonygego Mar 1, 2023
ff216fe
[docs] add documentation for other docker runtimes
anthonygego Mar 2, 2023
9392a74
Addition of a "centralize" property for match problem to display only…
Mar 3, 2023
f769064
Addition of a "centralize" property for match problem. Js behaviour a…
Mar 6, 2023
79c784f
Merge pull request #918 from UCL-INGI/fix_909
anthonygego Mar 6, 2023
1c6fe48
[course_admin] filter non activate and "empty username" users. (#919)
Drumor Mar 6, 2023
14aba42
import prebuilded files (bootstrap RTL)
Feb 23, 2023
ef1e5ee
style files for RTL
Feb 23, 2023
2e97fc9
RTL activation logic
Feb 23, 2023
17d6b5f
Localization file updates
Feb 23, 2023
8c4e934
Make a unique grunt file
Mar 2, 2023
eff6a19
Update after conflicted rebase
Mar 2, 2023
5795088
Get same version of bootswatch. (update to 4.5.3)
Mar 2, 2023
8843f80
Update style based on remarks + rebuild minified js files.
Mar 6, 2023
5c4eb0b
Merge pull request #910 from UCL-INGI/RTL
anthonygego Mar 7, 2023
678a688
[frontend/tasks] move submission_limit to task_dispensers
anthonygego Jan 3, 2023
7c9095c
[frontend/tasks] move group_submission_mode to task_dispensers
anthonygego Jan 3, 2023
152b4d3
[frontend/tasks] move task accessibility to task_dispensers (1/2)
anthonygego Jan 4, 2023
196c865
[frontend/tasks] move task accessibility to task_dispensers (2/2)
anthonygego Jan 6, 2023
afed13e
[frontend/tasks] mark the current task dispenser as selected in the s…
anthonygego Jan 6, 2023
56767f2
[course_admin/edit_tasks] remove task deletion from the task edit page
anthonygego Jan 6, 2023
e3cba97
[frontend/task_dispenser] remove dead code in sectionslist
anthonygego Jan 6, 2023
57b6c51
[frontend/task_dispenser] remove id and rank from sectionslist
anthonygego Jan 6, 2023
88ff4db
[frontend/task_dispenser] improve dispenser data structure
anthonygego Jan 9, 2023
d4a3023
[frontend/task_dispensers] optimize fetching multiple accessibilities
anthonygego Jan 10, 2023
0ea62cc
[frontend/task_dispensers] optimize course grade computation
anthonygego Jan 11, 2023
25a163c
[frontend/task_dispensers] make CombinatoryTest inherit from TableOfC…
anthonygego Jan 11, 2023
57b6d32
[frontend/task_dispensers] sort dangling tasks by name natural order
anthonygego Jan 11, 2023
56d9d02
[frontend/task_dispensers] make task config fields set modular
anthonygego Jan 12, 2023
dcba35a
[plugins/upcoming_tasks] clean plugin according to task dispensers ch…
anthonygego Jan 16, 2023
2c587eb
[frontend/task_dispenser] fix get_all_categories if no tasks
anthonygego Mar 14, 2023
00637ab
[frontend/task_dispenser] remove duplicate dispenser structure gencode
anthonygego Mar 14, 2023
3de072e
[frontend/js] update minified js
anthonygego Mar 14, 2023
31a8b8e
Merge pull request #915 from UCL-INGI/nvidia_runtime
Drumor Mar 22, 2023
2b054c4
Merge pull request #908 from UCL-INGI/task_disp_refactor
Drumor Mar 23, 2023
cebfaad
[frontend/course] Additional fields for student (#832)
Drumor Mar 29, 2023
c2f58fe
[submission_manager] forward user settings in submission input (#835)
Drumor Apr 5, 2023
ddb8ad1
[frontend] remove social share feature (#933)
Drumor Apr 6, 2023
c78ee4b
Update transalations (#934)
Drumor Apr 6, 2023
684c885
Update translation files
weblate Apr 6, 2023
b936d3a
Translated using Weblate (French)
Apr 6, 2023
145fc84
[frontend/templates] replace css btn-default by btn-secondary
anthonygego Apr 17, 2023
6fcd7c5
[agent/docker] replace SSH opt-in by env types
anthonygego Apr 20, 2023
b3f66e3
Merge pull request #940 from UCL-INGI/fix_887
Drumor Apr 20, 2023
789df86
Merge pull request #935 from INGIbot/weblate-inginious-frontend
anthonygego Apr 20, 2023
09629d1
[frontend/submission_manager] catch DocumentTooLarge exception
anthonygego Apr 26, 2023
f348216
Merge pull request #941 from UCL-INGI/fix_697
Drumor Apr 26, 2023
509210c
[frontend/flask] fix session_cookie_name deprecation
anthonygego May 5, 2023
7fc0983
[setup] temporarily restrict to requests<2.2.29
anthonygego May 5, 2023
88d9b49
[base/kvm] Add KVM enabled base container
nrybowski May 23, 2023
16303b4
[base/kvm] Fixes + make codacy happy
nrybowski May 23, 2023
f8a83de
Enable KVM passthrough agent-side
nrybowski May 24, 2023
ecbcfd2
[base/kvm] Fix virtme patch + add missing telnet config
nrybowski May 24, 2023
a954d86
[base/kvm] Fix virtme-run path
nrybowski May 24, 2023
99a07f6
[base/kvm] Automated KVM launch on student container launch
nrybowski May 25, 2023
e7c4628
[base/kvm] Launch telnet to KVM at SSH connection
nrybowski May 25, 2023
703ba30
[base/kvm] Hardcode qemu-kvm src rpm URL
nrybowski May 26, 2023
d726555
[env/kvm] Launch task script, if any, on student SSH login
nrybowski Aug 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: Bug report
about: Create a report to help us improve
title: Add the context of the bug at the beginning of the title, if possible, e.g.
[frontend/installer]
labels: Bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**INGInious installation details**
- Version: [e.g. v.0.8.2 or the git hash]
- Containers version (if applicable) [e.g. the git hash]

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Feature request
about: Suggest an idea for this project
title: Add the context of the feature request at the beginning of the title, if possible,
e.g. [frontend/installer]
labels: Feature request
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
14 changes: 10 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get install -y libtidy5deb1 libzmq3-dev
pip3 install nose==1.3.7 selenium==3.141.0 coverage pyvirtualdisplay pytest
pip3 install coverage pytest virtualenv

- name: Start services
run: |
Expand All @@ -37,13 +37,19 @@ jobs:

- name: Install INGInious
run: pip3 install .

- name: Launch nose tests
run: nosetests -v --with-coverage --cover-package=inginious --cover-branches --cover-html -I "^test_"
- name: Mitigate MarkupSafe 2.1+ issues
run: pip3 install --upgrade markupsafe==2.0.1

- name: Launch pytest tests
run: coverage run --branch -m pytest -v

- name: Launch pytest tests not requiring INGInious modules
run: |
virtualenv env
env/bin/pip3 install jinja2 pytest coverage
env/bin/coverage run --branch -m pytest -v utils

- name: Generate coverage report
if: always()
run: |
Expand Down
2 changes: 1 addition & 1 deletion COPYRIGHTS
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The vast majority of the files are

Copyright (c) 2014-2022 Anthony Gégo, Guillaume Derval
Copyright (c) 2014-2023 Anthony Gégo, Guillaume Derval
and Pierre Reinbold

Some of the files contain contributions from other persons, institutions or
Expand Down
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ The documentation is available on Read the Docs:

On Linux, run ``make html`` in the directory ``/doc`` to create a html version of the documentation.

Roadmap
-------

INGInious is continuously improved. The various Work In Progress tasks are described in the Roadmap_ of the project.

.. _Roadmap: https://github.com/UCL-INGI/INGInious/wiki/Roadmap

Notes on security
-----------------

Expand Down
13 changes: 12 additions & 1 deletion base-containers/base/bin/_run_student_intern
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ logger = setup_logger()
# Check the runtimes
runtime = sys.argv[1]
parent_runtime = sys.argv[2]
kvm_enabled = sys.argv[3] == "True"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd document the args at both sides, here and at the call side in _docker_interface.py (to avoid implementing a useless argumentparser that would be self documenting)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The arguments managment will be replaced by an argparser.

shared_kernel, both_same_kernel = check_runtimes(runtime, parent_runtime)
# shared_kernal: boolean, True when this student_container is running on docker runtime. False when running on kata runtime.
# only_dockers: boolean, True when this student_container and its parent grading_container are both running on docker runtimes.
Expand Down Expand Up @@ -56,6 +57,16 @@ for name, (spath, append) in system_files.items():

logger.info("student container started and received initial command")

# If the current container requires KVM passthrough for interactive session, launch KVM start script as root.
if kvm_enabled and start_cmd["ssh"]:
kvm_start_path = os.environ.get('KVM_START_PATH')
if kvm_start_path is None:
logger.warning('KVM start script not found.')
exit(250)
else:
subprocess.Popen(shlex.split(kvm_start_path))
logger.info('KVM launched')

# Start the process
os.chdir(start_cmd["working_dir"])
set_limits = lambda: set_limits_user(user) # To know if the command should be executed as root or worker
Expand Down Expand Up @@ -93,7 +104,7 @@ scripts_isolation(True) # Setup script finished, make the scripts directory iso
# Handle SSH
if start_cmd["ssh"]:
logger.info("student container is starting ssh session")
retval = handle_ssh_session(student_container_id, both_same_kernel, event_loop, socket_unix, container_stdout, user)
retval = handle_ssh_session(student_container_id, both_same_kernel, event_loop, socket_unix, container_stdout, user, kvm_enabled)
logger.info("student container finished ssh session")

# Run teardown script
Expand Down
13 changes: 9 additions & 4 deletions base-containers/base/inginious_container_api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def execute_process(args, stdin_string="", internal_command=False, user="worker"
return stdout.read(), stderr.read()


def start_ssh_server(ssh_user):
def start_ssh_server(ssh_user, kvm_enabled: bool = False):
# Generate password
password, _ = execute_process(["/usr/bin/openssl", "rand", "-base64", "10"], internal_command=True, user=ssh_user)
password = password.decode('utf8').strip()
Expand All @@ -70,13 +70,18 @@ def start_ssh_server(ssh_user):
os.unlink("/run/nologin")

permit_root_login = "yes" if ssh_user == "root" else "no"
shell_forward = '-c "telnet localhost 2223"' if kvm_enabled else ''

# Wait for telnet session
if kvm_enabled:
while not os.path.exists('/task/student/kvm/.telnet'): pass

# Start the ssh server
execute_process(["/usr/sbin/sshd",
"-p", "22",
"-o", "PermitRootLogin={}".format(permit_root_login),
"-o", "PasswordAuthentication=yes", "-o", "StrictModes=no",
"-o", "ForceCommand=echo LOGIN: Good luck !; script -q .ssh_logs; cp .ssh_logs /task/student/.ssh_logs; echo LOGOUT: Good bye!",
"-o", f"ForceCommand=echo LOGIN: Good luck !; script {shell_forward} -q .ssh_logs; cp .ssh_logs /task/student/.ssh_logs; echo LOGOUT: Good bye!",
"-o", "AllowUsers={}".format(ssh_user)], internal_command=True, user=ssh_user)
return ssh_user, password
#When logging in, student is in a special interactive shell where everything is logged into a file.
Expand Down Expand Up @@ -179,9 +184,9 @@ def handle_signals(concerned_subprocess, com_socket):
sys.exit()


def handle_ssh_session(container_id, both_dockers, event_loop, socket_unix, container_stdout, user):
def handle_ssh_session(container_id, both_dockers, event_loop, socket_unix, container_stdout, user, kvm_enabled: bool = False):
""" Start the ssh server and send identification information """
ssh_user, password = start_ssh_server(user)
ssh_user, password = start_ssh_server(user, kvm_enabled)
if both_dockers:
# Send ssh information to the grading container
message = msgpack.dumps({"type": "ssh_student", "ssh_user": ssh_user, "password": password}) # constant size
Expand Down
102 changes: 102 additions & 0 deletions base-containers/kvm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
ARG VERSION=latest
ARG REGISTRY

# Rockylinux does not enable 9P virtfs in the shipped QEMU builds, hence we have to rebuild our own version
# Inspired from https://github.com/acudovs/qemu-kvm-virtfs/blob/master/rpmbuild/build
FROM rockylinux:8 as builder

# Enable additional repos
RUN dnf -y install 'dnf-command(config-manager)' &&\
dnf config-manager --set-enabled powertools

# Install dependencies to build QEMU
RUN yum -y update && yum -y install \
glusterfs-api-devel \
glusterfs-devel \
iasl \
libcacard-devel \
libpmem-devel \
nss-devel \
pkgconfig \
spice-protocol \
spice-server-devel \
usbredir-devel \
yum-utils \
'pkgconfig(epoxy)' \
'pkgconfig(gbm)' \
'pkgconfig(libdrm)' \
git

# Apply patches and build QEMU
WORKDIR /opt
RUN yum-builddep -y qemu-kvm
#RUN yumdownloader --source qemu-kvm
RUN wget "http://download.rockylinux.org/pub/rocky/8/AppStream/source/tree/Packages/q/qemu-kvm-6.2.0-32.module%2Bel8.8.0%2B1279%2B230c2115.src.rpm"
RUN rpm -Uvh qemu-kvm-*.src.rpm
#RUN git clone https://git.rockylinux.org/staging/rpms/qemu-kvm.git &&\
# git -C qemu-kvm checkout r8s-stream-rhel &&\
# if [[ ! -d /root/rpmbuild ]]; then mkdir /root/rpmbuild; fi &&\
# mv qemu-kvm/{SOURCES,SPECS} /root/rpmbuild/
RUN sed -i -e 's/--disable-virtfs/--enable-virtfs/' \
-e 's/--disable-virtiofsd/--enable-virtiofsd/g' \
/root/rpmbuild/SPECS/qemu-kvm.spec
RUN sed -i -e '/^%files -n qemu-kvm-common/,/^$/s/^$/%{_bindir}\/virtfs-proxy-helper\n%{_mandir}\/man1\/virtfs-proxy-helper.1.gz\n/' \
-e '/^%if %{rhev}$/,/^%else$/s/pkgsuffix -ev/pkgsuffix -virtfs/' \
-e '/%define rhel_rhev_conflicts()/ a Provides: %1-ev = %{epoch}:%{version}-%{release} \\\nObsoletes: %1-ev < %{obsoletes_version} \\' \
-e 's/rm -rf ${RPM_BUILD_ROOT}%{_mandir}\/man1\/virtfs-proxy-helper\*//g' \
-e 's/rm -rf ${RPM_BUILD_ROOT}%{_libexecdir}\/virtfs-proxy-helper/mv ${RPM_BUILD_ROOT}%{_libexecdir}\/virtfs-proxy-helper ${RPM_BUILD_ROOT}%{_bindir}\/virtfs-proxy-helper/g' \
/root/rpmbuild/SPECS/qemu-kvm.spec
COPY virtio-9p-pci.patch /root/rpmbuild/SOURCES/
COPY qemu-kvm.spec.patch /tmp
RUN patch /root/rpmbuild/SPECS/qemu-kvm.spec /tmp/qemu-kvm.spec.patch
#RUN mkdir /tmp/qemu-6.2.0 &&\
# cp /root/rpmbuild/SOURCES/* /tmp/qemu-6.2.0/ &&\
# cd /tmp &&\
# tar cJf /tmp/qemu-6.2.0.tar.xz qemu-6.2.0 &&\
# mv /tmp/qemu-6.2.0.tar.xz /root/rpmbuild/SOURCES/
RUN rpmbuild -ba --clean /root/rpmbuild/SPECS/qemu-kvm.spec

# Build GNU telnetd server since classical builds do not allow running bash as login util
RUN wget "https://ftp.gnu.org/gnu/inetutils/inetutils-2.4.tar.xz" &&\
tar xf inetutils-2.4.tar.xz &&\
cd inetutils-2.4 &&\
./configure --disable-servers --disable-clients --enable-telnetd --enable-telnet &&\
make -j$(nproc)

# =====================
# KVM base container
# =====================
FROM ${REGISTRY}/inginious/env-base:${VERSION}
Comment thread
anthonygego marked this conversation as resolved.
LABEL org.inginious.kvm 1

# Install QEMU with 9P virtifs enabled
COPY --from=builder /root/rpmbuild/RPMS/x86_64/qemu-*.rpm /tmp/
RUN yum localinstall -y /tmp/*rpm &&\
rm -rf /tmp/*rpm &&\
ln -s /usr/libexec/qemu-kvm /bin/qemu-kvm

# Install GNU telnet utils
COPY --from=builder /opt/inetutils-2.4/telnet/telnet /usr/sbin
COPY --from=builder /opt/inetutils-2.4/telnetd/telnetd /usr/sbin

# Install dependecies
RUN dnf install -y expect xinetd git

# Make xinet config readable for worker user in SSH container
RUN chmod 644 /etc/xinetd.conf

# Install virtme
WORKDIR /opt
COPY virtme.patch .
RUN git clone https://github.com/amluto/virtme &&\
git -C virtme apply < virtme.patch &&\
ln -s $(pwd)/virtme/virtme-run /bin/virtme-run

WORKDIR /

# Get expect script launching the VM
COPY run.expect setup.sh telnet_login.sh /
ENV KVM_START_PATH=/run.expect

# Add telnetd config
COPY telnet /etc/xinetd.d/
Empty file added base-containers/kvm/README.md
Empty file.
11 changes: 11 additions & 0 deletions base-containers/kvm/qemu-kvm.spec.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- qemu-kvm.spec 2023-05-22 13:26:12.087046202 +0000
+++ /root/rpmbuild/SPECS/qemu-kvm.spec 2023-05-22 12:40:09.838715272 +0000
@@ -652,6 +652,8 @@
Patch256: kvm-dma-helpers-prevent-dma_blk_cb-vs-dma_aio_cancel-rac.patch
# For bz#2090990 - qemu crash with error scsi_req_unref(SCSIRequest *): Assertion `req->refcount > 0' failed or scsi_dma_complete(void *, int): Assertion `r->req.aiocb != NULL' failed [8.7.0]
Patch257: kvm-virtio-scsi-reset-SCSI-devices-from-main-loop-thread.patch
+# Enable 9P virtfs
+Patch258: virtio-9p-pci.patch

BuildRequires: wget
BuildRequires: rpm-build
11 changes: 11 additions & 0 deletions base-containers/kvm/run.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/expect -f

log_user 0
set timeout 600
spawn /setup.sh
expect "virtme-init: console is ttyS0\r"
send -- "ip a add 10.0.2.15/24 dev enp0s2\r"
send -- "ip l set dev enp0s2 up\r"
send -- "touch /tmp/student/.telnet\r"
send -- "stdbuf -oL xinetd -d\r"
wait
28 changes: 28 additions & 0 deletions base-containers/kvm/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#! /bin/bash -x

# Load env variables
STUDENT_DIR=/task/student
KVM_DIR="${STUDENT_DIR}/kvm"
SCRIPTS_DIR="${STUDENT_DIR}/scripts"
STUDENT_LOGIN="${SCRIPTS_DIR}/student_login"

# Set kvm group in human-readable way
groupdel kvm
groupadd -g $(stat -c '%g' /dev/kvm) kvm

# Create RW dir mounted in the KVM
mkdir "${KVM_DIR}"
chown worker:worker /task
chown worker:worker "${KVM_DIR}"

# Copy the kernel in a path readable by "worker" within the SSH container
cp "${SCRIPTS_DIR}/bzImage" /tmp

# Copy student_login file, if any, in a path readable by "worker" within the VM
if [[ -f "${STUDENT_LOGIN}" ]]
then
cp "${STUDENT_LOGIN}" /
fi

# Launch the KVM as "worker"
su - worker -G worker -G kvm -c "virtme-run --cpus 2 --memory 256 --kimg /tmp/bzImage --rwdir=/tmp/student=${KVM_DIR}"
10 changes: 10 additions & 0 deletions base-containers/kvm/telnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
service telnet
{
flags = REUSE IPv4
socket_type = stream
wait = no
user = root
server = /usr/sbin/telnetd
server_args = -E /telnet_login.sh
disable = no
}
21 changes: 21 additions & 0 deletions base-containers/kvm/telnet_login.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#! /bin/bash

FIRST=/tmp/.first
STUDENT_LOGIN="/student_login"

if [[ ! -f "${FIRST}" ]]
then
# On first login within the KVM
touch "${FIRST}"

if [[ -f "${STUDENT_LOGIN}" ]]
then
# If the task specifies a given setup to launch (e.g. a mininet script), run it
./"${STUDENT_LOGIN}"
else
# Else, simply spawn a shell in the KVM
/bin/bash
fi
else
/bin/bash
fi
10 changes: 10 additions & 0 deletions base-containers/kvm/virtio-9p-pci.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
+++ a/configs/devices/x86_64-softmmu/x86_64-rh-devices.mak 2023-05-22 12:17:06.102529121 +0000
--- /dev/null
@@ -90,6 +90,7 @@
CONFIG_VHOST_USER_BLK=y
CONFIG_VIRTIO_PCI=y
CONFIG_VIRTIO_VGA=y
+CONFIG_VIRTIO_9P=y
CONFIG_VMMOUSE=y
CONFIG_VMPORT=y
CONFIG_VTD=y
Loading