From 75a146e19ee8a7cd796188d8551fccf983f154c0 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Sun, 13 Oct 2024 18:12:46 -0500 Subject: [PATCH] newvm: Configure serial console log file When a VM uses a serial port for its default console, kernel messages (e.g. panics) are lost if no console client is connected at the time. This is a major disadvantage when compared to a graphical console, which usually at least keeps a "screenshot" of the console when the kernel crashes. While researching the available console device types to determine how best to implement a tool that would both log the output from the serial console at all times, while still allowing interactive connections to it, I discovered that _libvirt_ actually already has this exact functionality built-in: https://libvirt.org/formatdomain.html#consoles-serial-parallel-channel-devices --- newvm.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/newvm.sh b/newvm.sh index b2ca0d0..32ea733 100755 --- a/newvm.sh +++ b/newvm.sh @@ -128,6 +128,7 @@ set -- \ --disk pool=default,size=${disk_size},cache=none \ --network ${network} \ --os-variant fedora$(rpm -E %fedora) \ + --console pty,target.type=serial,log.file=/var/log/libvirt/console/${name}.log \ --sound none \ --redirdev none \ --rng /dev/random \