Skip to content

Commit

Permalink
virtme: kick udev when running as root
Browse files Browse the repository at this point in the history
When running virtme-ng instances inside docker containers we may not
have a proper udev support on the host.

As a result the communication over virtio-serial port may not work
properly.

This can be solved by running the following command on the host (as
root), before starting the virtme-ng instances:

  # udevadm trigger --subsystem-match --action=change

Considering that we typicall run vng as root inside docker this can help
to automatically solve potential issues in this scenario.

This fixes issue #51.

Signed-off-by: Andrea Righi <[email protected]>
  • Loading branch information
Andrea Righi committed Dec 21, 2023
1 parent 3ff20c5 commit 7ea01f4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions virtme/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,14 @@ def do_script(shellcmd: str, show_boot_console=False) -> None:
kernelargs.extend(arch.earlyconsole_args())
kernelargs.extend(console_args)

# Kick udev to make sure virtio-serial devices are correctly populated
# on the host.
#
# This action will be done only if running as root and this allows to
# to properly support virtme-ng instances running inside docker.
if os.geteuid() == 0:
os.system("udevadm trigger --subsystem-match --action=change")

# Set up a virtserialport for script I/O
#
# NOTE: we need two additional I/O ports for /dev/stdout and
Expand Down

0 comments on commit 7ea01f4

Please sign in to comment.