Skip to content

Conversation

@guzu
Copy link

@guzu guzu commented Dec 1, 2025

This is a duplicate of #364 witch was accidentally closed; marked as merged by Github because of a force push.


To debug or just understand why a test failed it could be interesting to have more logs from the VM.
For instance, sometimes tests failed because a VM isn't able to get an IP in the time limit of test.

Using unix_vm_with_serial_console fixture, a test can ask to log serial output for a VM (Unix in this case, or could be Linux instead).
The fixture also ensure that the serial output is enabled by modifying the kernel command-line, because for the moment images we are importing for the tests don't have the console enabled.
This is debatable, but at least for now we try this patch set without modifying any of the current images.


The branch is on top eva/log-test-failure (#362) and ideally would also require that branch eva/local-cmd-generalize (#359) be merged also.
That's why the PR is not on top master.

Windows not supported (yet?). VM type (Unix or Windows) depends on test.
Distro classes only implement the console configuration and is specific to bootloader, but should move more methods from VM to UnixVM or WindowsVM.

Tested with:

uv run pytest \
    tests/misc/test_serial_console_logging.py::TestWithSessionLogging::test_vm_reboots \
    --hosts=10.1.30.2 --log-cli-level=debug --no-collect-logs-on-failure

With the following VMs on a XCP-ng 8.3 :

  almalinux-8.5-uefi-created_8.2-zstd.xva
  almalinux-9-05082022-uefi-created_8.2-zstd.xva
  alpine-minimal-uefi-3.21.3-created-8.2.zstd.xva
  centos-stream-9-04082022-uefi-created_8.2-zstd.xva
  centos6-32-PVINPVH-created_8.2-zstd.xva
  centos6-32-hvm-created_8.2-zstd.xva
  centos6-64-PVINPVH-created_8.2-zstd.xva
  debian-11.1-gui-created_8.2-zstd.xva
  debian-12-created_8.2-zstd.xva
  openSUSE-Leap-15-4-uefi-created_8.2-zstd.xva
  ubuntu-22.04-server-uefi-created_8.2.xva
  ubuntu-24.04-server-uefi-created_8.2.xva

Not tested:

 debian-12.1-uefi-created_8.2-zstd.xva
 debian-uefi-10.4.0-created_8.2-zstd-efitools.xva
 freebsd-13.2-uefi-created_8.2-zstd.xva
 freebsd-14-uefi-created_8.2-zstd.xva

guzu added 2 commits December 1, 2025 10:39
Introduce SerialConsoleLogger that captures serial console output from
VMs using 'xl console -t serial' via background SSH processes.

Features:
- Background monitoring with automatic VM reboot/crash handling;
  domid tracking using UUID of the VM.
- Logs to the same pytest-logs/ than reports gathered on failed
  tests.

Also add unix_vm_with_serial_console fixture that configures Linux VMs
to output kernel logs to serial console by modifying bootloader configs
(GRUB/extlinux) for supported distributions.

Signed-off-by: Emmanuel Varagnat <[email protected]>
Create VM class hierarchy to support distribution-specific
functionality:
  VM → UnixVM → {AlpineVM, AlmaVM, CentOSVM, DebianVM, OpenSuseVM,
                 UbuntuVM, FreeBSD}
  VM → WindowsVM

Each distro class implements configure_serial_console() for its specific
bootloader configuration.

UnixVM provides class methods for auto-detection and conversion:
- detect_distro(vm): Detect distro from /etc/os-release
- get_distro_class(distro): Map distro ID to VM subclass
- from_vm_auto_detect(vm): Auto-detect and convert in one call

More VM refactoring to come...

Signed-off-by: Emmanuel Varagnat <[email protected]>
@stormi stormi requested review from a team and dinhngtu December 1, 2025 12:18
@stormi
Copy link
Member

stormi commented Dec 1, 2025

Since it's still a draft, with a few unknowns, I suggest a "live" discussion/review with the interested parties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants