Enable xenconsoled Serial Logging
Be sure to take into consideration the potential security implications of storing every detail from every management session conducted by serial. By nature of the interface, most will be root/sudoer logins.
On a fresh Red Hat/CentOS dom0 you will find /var/log/xen/console/ barren, or perhaps not even extant (mkdir -P). On older installations that come with a xend service, you can enable serial console recording globally (all domUs at once) by setting XENCONSOLED_LOG_GUESTS=yes in /etc/sysconfig/xend and restarting the xend service.
XENCONSOLED_LOG_HYPERVISOR=yes
XENCONSOLED_TIMESTAMP_HYPERVISOR_LOG=yes
XENCONSOLED_LOG_GUESTS=yes
XENCONSOLED_TIMESTAMP_GUEST_LOG=yes
XENCONSOLED_LOG_DIR=/var/log/xen/console/
On newer system.d installations run out of xencommons I had to run down the environment variables:
locate xenconsoled.service
/etc/systemd/system/multi-user.target.wants/xenconsoled.service
/usr/lib/systemd/system/xenconsoled.service
cat /usr/lib/systemd/system/xenconsoled.service
[Unit]
Description=Xenconsoled - handles logging from guest consoles and hypervisor
Requires=proc-xen.mount xenstored.service
After=proc-xen.mount xenstored.service
ConditionPathExists=/proc/xen/capabilities
[Service]
Type=simple
Environment=XENCONSOLED_ARGS=
Environment=XENCONSOLED_TRACE=none
Environment=XENCONSOLED_LOG_DIR=/var/log/xen/console
EnvironmentFile=/etc/sysconfig/xencommons
ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
ExecStartPre=/bin/mkdir -p ${XENCONSOLED_LOG_DIR}
ExecStart=/usr/sbin/xenconsoled -i --log=${XENCONSOLED_TRACE} --log-dir=${XENCONSOLED_LOG_DIR} $XENCONSOLED_ARGS
[Install]
WantedBy=multi-user.target
xenconsoled --help
Usage: xenconsoled [-h] [-V] [-v] [-i] [--log=none|guest|hv|all] [--log-dir=DIR] [--pid-file=PATH] [-t, --timestamp=none|guest|hv|all] [-o, --overflow-data=discard|keep]
Documentation regarding xenconsoled's options is scarce to say the least. At the time of publication I'm apparently the first person on the internet to have tried figuring out what important-sounding --overflow-data does. Fortunately xenconsoled plays nicely with being killed live on the command line and having its flags twiddled with - it will even auto-daemonize. Avoid spawning more than one instance at a time, though doing so produces no catastrophically ill effects.
Once you have settled on a configuration, it is made persistent by dropping environment variables into the very top of /etc/sysconfig/xencommons:
## Path: System/Virtualization
## Type: string
## Default: "none"
#
# Log xenconsoled messages (cf xl dmesg)
#XENCONSOLED_TRACE=[none|guest|hv|all]
XENCONSOLED_TRACE=all
XENCONSOLED_ARGS="--timestamp=all"
#XENCONSOLED_LOG_DIR=/var/log/xen/console
On Debian and derivatives like Ubuntu the same is accomplished by setting:
XENCONSOLED_ARGS="--timestamp=all --log=all --log-dir=/var/log/xen/console/"
in /etc/default/xend.
Another option is the direct route:
nohup xl console domain 2>&1 tee /var/log/xen/console/guest-domain.log &
Note that the actual client interface, xenconsole can be called directly, but typically is not in your PATH by default and must be called from its location. It accepts a domain ID number as opposed to a domain name, but allows one to specify if the interface to which you are connecting is provided by HVM/QEMU (serial) or PV (pv) using the --type flag:
/usr/lib64/xen/bin/xenconsole --help
Usage: /usr/lib64/xen/bin/xenconsole [OPTION] DOMID
Attaches to a virtual domain console
-h, --help display this help and exit
-n, --num N use console number N
--type TYPE console type. must be 'pv' or 'serial'
--start-notify-fd N file descriptor used to notify parent
xl list | grep domain
domain 5 8192 5 -b---- 119.1
/usr/lib64/xen/bin/xenconsole 5
You can tee your interactive session to a logfile, but unlike the configuration shown above the flow into the file will cease when you exit xenconsole:
/usr/lib64/xen/bin/xenconsole 5 tee:stdio,file:/var/log/xen/console/guest-domain.log
Some interesting and highly technical background on the provisioning and configuration of the underlaying serial devices and emulations is provided in https://xenbits.xenproject.org/docs/unstable/misc/console.txt however you are unlikely to find it useful to your logging endeavour unless you are engaged in extreme debugging.
Comments
There are no comments for this item.