Generate 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.

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 server-side functionalities, such as host libraries and the libvirt daemon, and 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 libvirt debug logs persistently, or only for the current session.

Afterwards, you can attach the collected logs when requesting support with a VM problem.

Enable libvirt debug logs persistently

To ensure that your virtualization host automatically logs debug information, configure libvirt debug logging to be automatically enabled whenever libvirt starts.

About this task

By default, virtqemud is the main libvirt daemon in RHEL 10. To make persistent changes in the libvirt configuration, you must edit the virtqemud.conf file, located in the /etc/libvirt directory.

Procedure

  1. Open the virtqemud.conf file in an editor.
  2. Replace or set the filters according to your requirements.
    Table 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.

    Sample daemon settings for logging filters

    The following settings:

    • Log all error and warning messages from the remote, util.json, and rpc 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"
  3. Save and exit.
  4. Restart the libvirt daemon.
    $ systemctl restart virtqemud.service

Enable libvirt debug logs during runtime

To temporarily gather virtualization debugging information, you can modify the runtime settings of the libvirt daemon to enable debug logs and save them to an output file.

Before you begin

  • Make sure the libvirt-admin package is installed.

About this task

Modifying libvirt runtime settings is useful in the following scenarios:

  • When restarting the libvirt daemon is not possible because restarting fixes the problem.
  • When another process, such as migration or backup, is running at the same time.
  • When you want to try a command without editing the configuration files or restarting the daemon.

Procedure

  1. Optional: Back up the active set of log filters.
    # virt-admin -c virtqemud:///system daemon-log-filters >> virt-filters-backup

    This makes it possible to restore the active set of filter after generating the logs. If you do not restore the filters, the messages continue to be logged, which might affect system performance.

  2. Use the virt-admin utility to enable debugging and set the filters according to your requirements.
    Table 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.

    Sample virt-admin setting for logging filters

    The following command:

    • Logs all error and warning messages from the remote, util.json, and rpc 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"
  3. 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"
  4. Optional: You can also remove the filters to generate a log file that contains all VM-related information. However, it is not recommended because this file might 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:
  5. Optional: Restore the filters to their original state by using the backup file that you created previously.
    # virt-admin -c virtqemud:///system daemon-log-filters "<original-filters>"

    In this command, replace <original-filters> with the content of virt-filters-backup.

    Note that if you do not restore the filters, the messages continue to be logged, which might affect system performance.

Attach libvirt debug logs to support requests

To diagnose and resolve virtual machine (VM) problems, you might have to request additional support. Attaching 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 resolution for a VM-related problem.

Procedure

  • 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.