Chapitre 21. Diagnosing virtual machine problems
When working with virtual machines (VMs), you may encounter problems with varying levels of severity. Some problems may have a quick and easy fix, while for others, you may have to capture VM-related data and logs to report or diagnose the problems.
The following sections provide detailed information about generating logs and diagnosing some common VM problems, as well as about reporting these problems.
21.1. Generating libvirt debug logs
To diagnose virtual machine (VM) problems, it is helpful to generate and review libvirt debug logs. Attaching debug logs is also useful when asking for support to resolve VM-related problems.
The following sections explain what debug logs are, how you can set them to be persistent, enable them during runtime, and attach them when reporting problems.
21.1.1. Understanding libvirt debug logs
Debug logs are text files that contain data about events that occur during virtual machine (VM) runtime. The logs provide information about fundamental server-side functionalities, such as host libraries and the libvirt daemon. The log files also contain the standard error output (stderr
) of all running VMs.
Debug logging is not enabled by default and has to be enabled when libvirt starts. You can enable logging for a single session or persistently. You can also enable logging when a libvirt daemon session is already running by modifying the daemon run-time settings.
Attaching the libvirt debug logs is also useful when requesting support with a VM problem.
21.1.2. Enabling persistent settings for libvirt debug logs
You can configure libvirt debug logging to be automatically enabled whenever libvirt starts. By default, virtqemud
is the main libvirt daemon in RHEL 9. To make persistent changes in the libvirt configuration, you must edit the virtqemud.conf
file, located in the /etc/libvirt
directory.
In some cases, for example when you upgrade from RHEL 8, libvirtd
might still be the enabled libvirt daemon. In that case, you must edit the libvirtd.conf
file instead.
Procédure
-
Open the
virtqemud.conf
file in an editor. Replace or set the filters according to your requirements.
Tableau 21.1. Debugging filter values
1
logs all messages generated by libvirt.
2
logs all non-debugging information.
3
logs all warning and error messages. This is the default value.
4
logs only error messages.
Exemple 21.1. Sample daemon settings for logging filters
The following settings:
-
Log all error and warning messages from the
remote
,util.json
, andrpc
layers -
Log only error messages from the
event
layer. -
Save the filtered logs to
/var/log/libvirt/libvirt.log
log_filters="3:remote 4:event 3:util.json 3:rpc" log_outputs="1:file:/var/log/libvirt/libvirt.log"
-
Log all error and warning messages from the
- Save and exit.
Restart the libvirt daemon.
$ systemctl restart virtqemud.service
21.1.3. Enabling libvirt debug logs during runtime
You can modify the libvirt daemon’s runtime settings to enable debug logs and save them to an output file.
This is useful when restarting the libvirt daemon is not possible because restarting fixes the problem, or because there is another process, such as migration or backup, running at the same time. Modifying runtime settings is also useful if you want to try a command without editing the configuration files or restarting the daemon.
Conditions préalables
-
Make sure the
libvirt-admin
package is installed.
Procédure
Optional: Back up the active set of log filters.
# virt-admin -c virtqemud:///system daemon-log-filters >> virt-filters-backup
NoteIt is recommended that you back up the active set of filters so that you can restore them after generating the logs. If you do not restore the filters, the messages will continue to be logged which may affect system performance.
Use the
virt-admin
utility to enable debugging and set the filters according to your requirements.Tableau 21.2. Debugging filter values
1
logs all messages generated by libvirt.
2
logs all non-debugging information.
3
logs all warning and error messages. This is the default value.
4
logs only error messages.
Exemple 21.2. Sample virt-admin setting for logging filters
The following command:
-
Logs all error and warning messages from the
remote
,util.json
, andrpc
layers -
Logs only error messages from the
event
layer.
# virt-admin -c virtqemud:///system daemon-log-filters "3:remote 4:event 3:util.json 3:rpc"
-
Logs all error and warning messages from the
Use the
virt-admin
utility to save the logs to a specific file or directory.For example, the following command saves the log output to the
libvirt.log
file in the/var/log/libvirt/
directory.# virt-admin -c virtqemud:///system daemon-log-outputs "1:file:/var/log/libvirt/libvirt.log"
Optional: You can also remove the filters to generate a log file that contains all VM-related information. However, it is not recommended since this file may contain a large amount of redundant information produced by libvirt’s modules.
Use the
virt-admin
utility to specify an empty set of filters.# virt-admin -c virtqemud:///system daemon-log-filters Logging filters:
-
Optional: Restore the filters to their original state using the backup file.
Perform the second step with the saved values to restore the filters.
21.1.4. Attaching libvirt debug logs to support requests
You may have to request additional support to diagnose and resolve virtual machine (VM) problems. Attaching the debug logs to the support request is highly recommended to ensure that the support team has access to all the information they need to provide a quick resolution of the VM-related problem.
Procédure
- To report a problem and request support, open a support case.
Based on the encountered problems, attach the following logs along with your report:
-
For problems with the libvirt service, attach the
/var/log/libvirt/libvirt.log
file from the host. For problems with a specific VM, attach its respective log file.
For example, for the testguest1 VM, attach the
testguest1.log
file, which can be found at/var/log/libvirt/qemu/testguest1.log
.
-
For problems with the libvirt service, attach the
Ressources supplémentaires