21.2. Dumping a virtual machine core
To analyze why a virtual machine (VM) crashed or malfunctioned, you can dump the VM core to a file on disk for later analysis and diagnostics.
21.2.1. How virtual machine core dumping works 复制链接链接已复制到粘贴板!
A virtual machine (VM) requires numerous running processes to work accurately and efficiently. In some cases, a running VM may terminate unexpectedly or malfunction while you are using it. Restarting the VM may cause the data to be reset or lost, which makes it difficult to diagnose the exact problem that caused the VM to crash.
In such cases, you can use the virsh dump utility to save (or dump) the core of a VM to a file before you reboot the VM. The core dump file contains a raw physical memory image of the VM which contains detailed information about the VM. This information can be used to diagnose VM problems, either manually, or by using a tool such as the crash utility.
21.2.2. Creating a virtual machine core dump file 复制链接链接已复制到粘贴板!
A virtual machine (VM) core dump contains detailed information about the state of a VM at any given time. This information, which is similar to a snapshot of the VM, can help you detect problems if a VM malfunctions or shuts down suddenly.
Prerequisites
- Make sure you have sufficient disk space to save the file. Note that the space occupied by the VM depends on the amount of RAM allocated to the VM.
Procedure
Use the
virsh dumputility.For example, the following command dumps the
test-guest1VM’s cores, its memory and the CPU common register file tosample-core.filein the/core/filedirectory.# virsh dump test-guest1 /core/file/sample-core.file --memory-only Domain 'test-guest1' dumped to /core/file/sample-core.file重要The
crashutility no longer supports the default file format of the virsh dump command. To analyze a core dump file by usingcrash, you must create the file with the--memory-onlyoption.Additionally, you must use the
--memory-onlyoption when creating a core dump file to attach to a Red Hat Support Case.
Troubleshooting
If the virsh dump command fails with a System is deadlocked on memory error, ensure you are assigning sufficient memory for the core dump file. To do so, use the following crashkernel option value. Alternatively, do not use crashkernel at all, which assigns core dump memory automatically.
crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M