dump虚拟机中的一段内存

方法:使用 virsh qemu-monitor-command 命名,它的基本用法是:

$ virsh qemu-monitor-command --help
  NAME
    qemu-monitor-command - QEMU 监控程序命令

  SYNOPSIS
    qemu-monitor-command <domain> [--hmp] [--pretty] {[--cmd] <string>}...

  DESCRIPTION
    QEMU 监控程序命令

  OPTIONS
    [--domain] <string>  domain name, id or uuid
    --hmp            采用认同监控协议的命令
    --pretty         以美化格式输出任意 qemu 监视器协议输出结果
    [--cmd] <string>  命令

这里需要了解一下 qemu monitor 所支持的命令,详见参考资料,dump 虚拟机中的一段内存需要使用 x/fmt 命令,它的基本格式是: 

x/fmt addr
	Virtual memory dump starting at addr.
	
fmt is a format which tells the command how to format the data. 
        Its syntax is: /{count}{format}{size}

count
	is the number of items to be dumped.
format
	can be x (hex), d (signed decimal), u (unsigned decimal), 
        o (octal),c (char) or i (asm instruction).
size
	can be b (8 bits), h (16 bits), w (32 bits) or g (64 bits). 
        On x86,h or w can be specified with the i format 
        to respectively select 16 or 32 bit code instruction size.

下面是使用示例,dump 虚拟机 generic 从虚拟地址 0xffffffff8020b2c0 开始的 256 条指令到 memory.dump 文件:

$ virsh qemu-monitor-command generic --hmp x/256i 0xffffffff8020b2c0 > memory.dump
$ head memory.dump 
0xffffffff8020b2c0:  move	v0,a0
0xffffffff8020b2c4:  sltiu	t2,a2,40
0xffffffff8020b2c8:  andi	t0,a0,0xf
0xffffffff8020b2cc:  bnez	t2,0xffffffff8020b620
0xffffffff8020b2d0:  andi	t1,a1,0xf
0xffffffff8020b2d4:  beqz	t0,0xffffffff8020b308
0xffffffff8020b2d8:  bnec	t0,t8,0xffffffff8020b29c
0xffffffff8020b2dc:  ldr	t3,0(a1)
0xffffffff8020b2e0:  sltiu	t4,t0,8
0xffffffff8020b2e4:  ldl	t3,7(a1)

 

 

 

参考资料:

1. https://qemu.readthedocs.io/en/latest/system/monitor.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值