首页 > 系统相关 >使用qemu来dump虚拟机的内存,然后用crash来分析

使用qemu来dump虚拟机的内存,然后用crash来分析

时间:2023-09-22 20:34:10浏览次数:42  
标签:crash guest 0.000000 mem 虚拟机 BIOS Copyright dump

场景

如果虚拟机没有开启kdump,或者卡死了,那么可以进入qemu的monitor模式将虚机的内存保存到文件中,然后使用crash工具进行分析。

示例

  • 启动虚拟机,然后按ctrl+a c进入monitor,查看帮助
(qemu) help dump-guest-memory
dump-guest-memory [-p] [-d] [-z|-l|-s|-w] filename [begin length] -- dump guest memory into file 'filename'.
                        -p: do paging to get guest's memory mapping.
                        -d: return immediately (do not wait for completion).
                        -z: dump in kdump-compressed format, with zlib compression.
                        -l: dump in kdump-compressed format, with lzo compression.
                        -s: dump in kdump-compressed format, with snappy compression.
                        -w: dump in Windows crashdump format (can be used instead of ELF-dump converting),
                            for Windows x64 guests with vmcoreinfo driver only.
                        begin: the starting physical address.
                        length: the memory size, in bytes.
  • 保存虚机的全部内存,采用zlib压缩
(qemu) dump-guest-memory -z guest.img

$ ls -lh guest.img
-rwxrwxrwx 1 root root 241M Sep 22 05:17 guest.img
  • 使用crash工具进行分析
$ crash guest.img linux-6.2/vmlinux

crash 8.0.3
Copyright (C) 2002-2022  Red Hat, Inc.
Copyright (C) 2004, 2005, 2006, 2010  IBM Corporation
Copyright (C) 1999-2006  Hewlett-Packard Co
Copyright (C) 2005, 2006, 2011, 2012  Fujitsu Limited
Copyright (C) 2006, 2007  VA Linux Systems Japan K.K.
Copyright (C) 2005, 2011, 2020-2022  NEC Corporation
Copyright (C) 1999, 2002, 2007  Silicon Graphics, Inc.
Copyright (C) 1999, 2000, 2001, 2002  Mission Critical Linux, Inc.
Copyright (C) 2015, 2021  VMware, Inc.
This program is free software, covered by the GNU General Public License,
and you are welcome to change it and/or distribute copies of it under
certain conditions.  Enter "help copying" to see the conditions.
This program has absolutely no warranty.  Enter "help warranty" for details.

GNU gdb (GDB) 10.2
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...

please wait... (determining panic task)
      KERNEL: linux-6.2/vmlinux
    DUMPFILE: guest.img  [PARTIAL DUMP]
        CPUS: 8
        DATE: Fri Sep 22 05:16:53 PDT 2023
      UPTIME: 00:01:12
LOAD AVERAGE: 0.39, 0.14, 0.05
       TASKS: 181
    NODENAME: ubuntu-vm
     RELEASE: 6.2.0+
     VERSION: #4 SMP PREEMPT_DYNAMIC Mon Aug 14 02:28:01 PDT 2023
     MACHINE: x86_64  (3194 Mhz)
      MEMORY: 8 GB
       PANIC: ""
         PID: 0
     COMMAND: "swapper/0"
        TASK: ffffffff8362cac0  (1 of 8)  [THREAD_INFO: ffffffff8362cac0]
         CPU: 0
       STATE: TASK_RUNNING (ACTIVE)
     WARNING: panic task not found

crash>

查看dmesg:

crash> dmesg
[    0.000000] Linux version 6.2.0+ (pengdl@ubuntu) (gcc (Ubuntu 8.4.0-3ubuntu2) 8.4.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #4 SMP PREEMPT_DYNAMIC Mon Aug 14 02:28:01 PDT 2023
[    0.000000] Command line: noinitrd rootfstype=ext4 root=/dev/vda rw console=ttyS0 crashkernel=1G  nokaslr
[    0.000000] x86/fpu: x87 FPU will use FXSAVE
[    0.000000] signal: max sigframe size: 1440
[    0.000000] BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[    0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000000100000-0x00000000bffdcfff] usable
[    0.000000] BIOS-e820: [mem 0x00000000bffdd000-0x00000000bfffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000feffc000-0x00000000feffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000100000000-0x000000023fffffff] usable
[    0.000000] NX (Execute Disable) protection: active
[    0.000000] SMBIOS 2.8 present.
[    0.000000] DMI: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
[    0.000000] Hypervisor detected: KVM
[    0.000000] kvm-clock: Using msrs 4b564d01 and 4b564d00
[    0.000004] kvm-clock: using sched offset of 1180034822 cycles
[    0.000009] clocksource: kvm-clock: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns
[    0.000040] tsc: Detected 3194.004 MHz processor
[    0.001718] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
...

标签:crash,guest,0.000000,mem,虚拟机,BIOS,Copyright,dump
From: https://www.cnblogs.com/pengdonglin137/p/17723303.html

相关文章

  • 虚拟机镜像无网络
    问题虚拟机连不上网解决打开虚拟机设置网络适配器:网络连接选择“NAT模式”......
  • tcpdump后台不间断抓包
    版本1的抓包命令这两天排查一个小问题,需要在服务器上使用tcpdump24小时不间断抓包,这里简单记录下。先看下tcpdump的语法:tcpdump[-AbdDefhHIJKlLnNOpqStuUvxX#][-Bbuffer_size][-ccount][-Cfile_size][-Grotate_seconds][-F......
  • 迁移虚拟机使用遇到的问题
    迁移背景本次在迁移前的主机系统为REDHAT8,每台机器配置了专门的ip+搭建好yum环境迁移时虚拟机版本需要统一如果不统一,需要在.vmx文件中修改 2.虚拟网络编辑器要与迁移前保持一致 3.搭建好yum路径要与迁移前路径保持一致4.如果开机后ifconfig不显示,需要使用nmclinon......
  • tcpdump使用
    背景最近一直在排查线上问题,发现好多是客户自己网络的问题,因此此处记录下tcpdump使用命令1.先获取网卡名称iplinkshow2.使用tcpdump监控指定域名及端口tcpdump-i<网卡名称>-vnnhostwww.baidu.comxxx.pcap3.将xxx.pcap移到自己本地电脑,使用wireshark打开进行分......
  • mysqldump导出命令
    导出数据备份数据[root@sf105113bin]#mysqldump-h127.0.0.1-P3306-uroot-p--add-locks-qdbname>dbname.sql//参数依次为:-h主机-p端口-u用户名-p密码--add-locks:导出过程中锁定表,完成后回解锁。-q:不缓冲查询,直接导出至标准输出2.  ......
  • vmware虚拟机中的centos设置固定ip
    1、使用桥接模式,确保虚拟机目前可联网因为我们要使用目前的配置,使得目前ip为固定ip,确保ip无冲突 2、查看目前ip配置ipaddrshow #查看ip,找到虚拟机目前联网的网络接口,我的是ens33ipaddrshowens33 #查看,确定inet172.16.200.102/20  ip和子网掩码iproute......
  • M2芯片MAC安装windows虚拟机
    安装windows虚拟机MAC虚拟软件用的是VMwareFusionpro13及更高版本,使用的镜像是ARM的,X64的不能用。在虚拟机启动时,出现以下界面1-2秒后按下f2,进入安装系统界面,否则会出现报错StartPXEoverIPv4安装windows系统,因为默认安装在连接网络那一步无法选择网络,所以在出现选择国家选......
  • M2芯片MAC安装CentOS7.9虚拟机
    安装CentOS7.91、官网下载的ARM镜像均不可用,卡在installcentos7界面。需找寻下载适合M1/2MAC的ARM镜像才行。例如从官网下载的CentOS-7-aarch64-Minimal-2009.iso安装时一直卡在这个界面。镜像下载地址:CentOS-7-aarch64-08191738.mpghttps://www.aliyundrive.com/s/nu972LGBLF......
  • 拒绝废话 xshell,MobaXterm,vs code,pycharm连接虚拟机配置,详细懒人教程
    配置虚拟机配置静态ipvim/etc/sysconfig/network-scripts/ifcfg-ens33ifcfg-ens33文件内容TYPE=EthernetPROXY_METHOD=noneBROWSER_ONLY=noBOOTPROTO=static#设置为静态ipDEFROUTE=yesIPV4_FAILURE_FATAL=noIPV6INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_......
  • python中dump和dumps的区别
    dumpdump是将json数据写进文件dumpsdumps是将字典类型的数据转换为字符串如果不能区分好这两个函数,就很容易犯这个错误:TypeError:init()gotanunexpectedkeywordargument'fp'(别问我为啥知道奥~)......