如何将QEMU的确定性记录和重放功能用于Linux内核引导? [英] How to use QEMU's deterministic record and replay feature for a Linux kernel boot?
问题描述
QEMU支持确定性记录和重播,如以下文档中所述: https ://github.com/qemu/qemu/blob/v2.9.0/docs/replay.txt
QEMU supports deterministic record and replay as documented at: https://github.com/qemu/qemu/blob/v2.9.0/docs/replay.txt
但是,对于完整的Linux内核引导,我无法重播:它总是挂在某个位置.
However, I could not get replay working for a full Linux kernel boot: it always hangs at some point.
这些是我正在运行的命令:
These are the commands I'm running:
#!/usr/bin/env bash
cmd="\
time \
./buildroot/output.x86_64~/host/usr/bin/qemu-system-x86_64 \
-M pc \
-append 'root=/dev/sda console=ttyS0 nokaslr printk.time=y - lkmc_eval=\"/rand_check.out;wget -S google.com;/poweroff.out;\"' \
-kernel './buildroot/output.x86_64~/images/bzImage' \
-nographic \
\
-drive file=./buildroot/output.x86_64~/images/rootfs.ext2,if=none,id=img-direct,format=raw \
-drive driver=blkreplay,if=none,image=img-direct,id=img-blkreplay \
-device ide-hd,drive=img-blkreplay \
\
-netdev user,id=net1 \
-device rtl8139,netdev=net1 \
-object filter-replay,id=replay,netdev=net1 \
"
echo "$cmd"
eval "$cmd -icount 'shift=7,rr=record,rrfile=replay.bin'"
# Different than previous.
eval "$cmd -icount 'shift=7,rr=record,rrfile=replay.bin'"
# Same as previous.
eval "$cmd -icount 'shift=7,rr=replay,rrfile=replay.bin'"
以及我的内核和根文件系统都是通过以下Buildroot设置生成的:使用QEMU v2.9.0的https://github.com/cirosantilli/linux-kernel-module-cheat/tree/0a1a600d49d1292be82a47cfde6f0355996478f0 .
and my kernel and root filesystem were generated with this Buildroot setup: https://github.com/cirosantilli/linux-kernel-module-cheat/tree/0a1a600d49d1292be82a47cfde6f0355996478f0 which uses QEMU v2.9.0.
lkmc_eval
被我的init
脚本规避了.在这里,我们打印通常是随机的用户空间内容,以检查我们是否确实具有确定性,然后关闭计算机电源.
lkmc_eval
gets evaled by my init
scripts. Here we print userspace stuff that is usually random to check that we are actually deterministic, and then power off the machine.
我是如何想到这些命令的:
How I came up with those commands:
- 从我在回购中使用的有效命令开始,无需重播
- 从Wiki复制粘贴硬盘和网络部件: https://wiki.qemu .org/Features/record-replay
树中文档说没有网络支持,但是Wiki和git log表示它们是从v2.9.0开始添加的,因此与Wiki相比,我认为这些文档已经过时了.
The in-tree docs say there is no networking support, but the wiki and git log says they were added as of v2.9.0, so I think the docs are just outdated compared to the wiki.
使用该设置,引导重播进行得很远,但挂起消息:
Using that setup, the boot replay progresses quite far, but hangs at the message:
[ 31.692427] NET: Registered protocol family 17
在初始记录中,下一条消息应该是:
In the initial record, the next message would have been:
[ 31.777326] sd 1:0:0:0: [sda] Attached SCSI disk
所以我怀疑这是一个块设备问题.
so I'm suspicious that it is a block device matter.
但是时间戳是相同的,所以我相信到目前为止,记录和重放都可以正常工作.
The timestamps are however identical, so I'm confident that the record and replay has worked so far.
如果用于网络,我只使用:
If for the networking I use just:
-net none
然后记录本身挂在:
[ 19.669685] ALSA device list:
[ 19.670756] No soundcards found.
如果有人想针对它尝试QEMU补丁,只需在/qemu/
内检出您的补丁并运行:
If anyone wants to try a QEMU patch against it, just checkout to your patch inside /qemu/
and run:
./build -t host-qemu-reconfigure
要重建.
推荐答案
您的命令行看起来还不错,但不幸的是,此版本中的QEMU已损坏,但记录/重播. 我希望它将在最近的几周内解决.
Your command line looks ok, but unfortunately record/replay is QEMU is broken in this release. I hope that it will be fixed in the nearest weeks.
这篇关于如何将QEMU的确定性记录和重放功能用于Linux内核引导?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!