Capture screenshot when QEMU timeouts in boot tests
@lzap is already working on this.
Since Dec 20, 2025.
Assessment
This issue has not been assessed yet.
Description
If we encounter a timeout, we currently just give up which is okay if an image is configured for serial console. But installers are not. Let's just add a bit of code that captures a small screenshot so it is not too big for base64 encoded block to be thrown in the CICD output:
import socket
import json
import base64
import subprocess
from pathlib import Path
def capture_qemu_screenshot(qmp_socket_path, ppm_path):
"""Connects to QMP and saves a raw PPM screenshot."""
client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
try:
client.connect(str(qmp_socket_path))
# 1. Negotiate QMP capabilities
client.recv(1024) # Consumes the greeting
client.sendall(json.dumps({"execute": "qmp_capabilities"}).encode())
client.recv(1024) # Consumes the return
# 2. Execute Screendump
dump_cmd = {
"execute": "screendump",
"arguments": {"filename": str(ppm_path)}
}
client.sendall(json.dumps(dump_cmd).encode())
client.recv(1024) # Ensure command finished
finally:
client.close()
def process_and_print_base64(ppm_path):
"""Shrinks the image and prints base64 for CI/CD logs."""
png_path = ppm_path.with_suffix(".png")
# Use ImageMagick to crush the size: 8-bit grayscale, 400px wide
# This makes the Base64 string small enough to not bloat CI logs.
subprocess.run([
"convert", str(ppm_path),
"-resize", "400x",
"-colorspace", "gray",
"-colors", "16", # Further reduces file size
str(png_path)
], check=True)
with open(png_path, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
print("\n--- BEGIN QEMU SCREENSHOT ---")
print(encoded_string)
print("--- END QEMU SCREENSHOT ---\n")
- Dominant language
- Go
- Stars
- 77
- Forks
- 103
- Avg merge
- 3d 6h
- Merged PRs (30d)
- 53
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from osbuild/image-builder
-
admin/has-jira area/bootc area/docs
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
osbuild/image-builder#2695 · 1 comment ·
-
area/docs
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
osbuild/image-builder#2363 ·
-
admin/has-jira area/bootc bug
osbuild/image-builder#2697 · 4 comments · 1 assignee ·
-
admin/has-jira area/bootc area/ci
Difficulty 3/5 1-2 days Newbie friendliness 68/100
osbuild/image-builder#2694 · 1 comment ·
-
admin/has-jira area/bootc bug
Difficulty 4/5 3-5 days Newbie friendliness 52/100
osbuild/image-builder#2681 · 2 comments ·
All issues in osbuild/image-builder
Similar issues
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
blinklabs-io/bursa#904 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · 2 comments ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100