Linux 内核问题调试手段——QEMU 专题

VM 启动后没有输出?莫慌~ 一般而言,在运行 qemu-system-xxx 启动虚拟机后,我们希望在主机的当前终端上看到内核的启动日志,并在虚拟机启动后用该终端直接操作虚拟机。然而有时,当前终端在运行了 qemu-system-xxx 后却毫无动静。此时,在确认内核可以正常启动的前提下,要去确认几件事情: 当前终端对 QEMU 虚拟机而言是什么设备; 当前内核使用的 /dev/console 指向了哪个设备。 先找到一个可用的虚拟机终端(比如通过 VNC 连接的方式),然后向 /dev/{console,tty{,S}{0,1,...}} 等物理终端设备文件逐个尝试输入一些内容,看看哪个文件能让主机的当前终端有输出1。确定了是哪 …

"Tricks and Craft" in Bash Scripting

Process Input Line by Line 1#!/bin/bash 2input="path/to/file" 3while IFS= read -r line 4do 5 # process each read-in line 6 echo "$line" 7done < "$input" # NORICE HERE Pay attention to the < part following done on the last line. It redirects the $input file to stdin of read process, making …

Vim: List All Matching Lines

1. vimgrep (Error List) 1:vimgrep pattern % To open the list of matches in a buffer: 1:copen On the list, navigate normally, and use <Enter> to select a match. 2. lvim (Location List) 1:lvim pattern % To open the list 1:lopen Navigation is similar with vimgrep. 3. Global Search1 1:g/regular-expression/p Note that …