QEMU源码中一些有用的脚本

QMP/qom-list

QEMU Monitor Protocol (QMP ) 是一个允许应用程序与QEMU 's Monitor通信的协议。qom-list是QMP下的一个脚本,这个命令会列出在device model中一个给定路径的设备的所有属性。参数是在device model中的路径,返回的是DevicePropertyInfo中所有属性。使用qom-list需要增加一个配置文件:

[chardev "qmp"]
  backend = "socket"
  path = "path to the QMP unix socket"
  server = "on"
  wait = "off"
[mon "qmp"]
  mode = "control"
  chardev = "qmp"

运行qemu:

# qemu [...] -readconfig qemu-qmp.conf

或者在启动的时候添加参数like me:

/home/hacker/qemu71/bin/qemu-system-i386 -s -kernel $1 -initrd $2 -usb -hda ./linux-0.2.img -append root=/dev/sda -boot c -monitor stdio -qmp unix:/tmp/server.sock,server,nowait

qemu run之后,可以使用qom-list查看properties了:

hacker@hacker:~/qemu7$ QMP/qom-list -s /tmp/server.sock /
vga/
i440fx/
peripheral/
peripheral-anon/
hacker@hacker:~/qemu7$ QMP/qom-list -s /tmp/server.sock /i440fx
piix3/
pmc/
@mmio/
type
hacker@hacker:~/qemu7$ QMP/qom-list -s /tmp/server.sock /i440fx/piix3/
command_serr_enable
legacy-command_serr_enable
multifunction
legacy-multifunction
rombar
romfile
legacy-romfile
addr
legacy-addr
pit/
rtc/
hpet/
type


 

scripts/checkpatch.pl


checkpatch.pl可以检查是否有不符和coding style的代码,最近的patch series我没留意coding style,结果被各种maintainer鄙视啦:

hacker@hacker:~/qemu7$ ./scripts/checkpatch.pl ~/patch/0001.patch 
ERROR: do not use C99 // comments
#141: FILE: hw/i440fx.c:77:
+    //    printf("ISA mapping %08x-0x%08x: %d\n", start, end, r);

ERROR: space required before the open parenthesis '('
#142: FILE: hw/i440fx.c:78:
+    switch(r) {

ERROR: space required before the open parenthesis '('
#175: FILE: hw/i440fx.c:111:
+    for(i = 0; i < 12; i++) {

ERROR: "foo* bar" should be "foo *bar"
#211: FILE: hw/i440fx.c:147:
+static int i440fx_pmc_load_old(QEMUFile* f, void *opaque, int version_id)

WARNING: braces {} are necessary for all arms of this statement
#217: FILE: hw/i440fx.c:153:
+    if (ret < 0)
[...]

ERROR: space prohibited before open square bracket '['
#246: FILE: hw/i440fx.c:182:
+    .fields      = (VMStateField []) {

WARNING: braces {} are necessary for all arms of this statement
#436: FILE: hw/i440fx.c:372:
+    if (ram_size > 255)
[...]

ERROR: open brace '{' following struct go on the same line
#562: FILE: hw/i440fx.h:61:
+typedef struct I440FXState
+{

ERROR: do not use C99 // comments
#685: FILE: hw/piix3.c:100:
+    pci_conf[0x04] = 0x07; // master, memory and I/O

ERROR: do not use C99 // comments
#688: FILE: hw/piix3.c:103:
+    pci_conf[0x07] = 0x02; // PCI_status_devsel_medium

ERROR: space prohibited before open square bracket '['
#745: FILE: hw/piix3.c:160:
+    .fields      = (VMStateField []) {

WARNING: line over 80 characters
#792: FILE: hw/piix3.c:207:
+	qdev_connect_gpio_out(DEVICE(&s->pit), 0, isa_get_irq(ISA_DEVICE(&s->pit), 0));

ERROR: code indent should never use tabs
#792: FILE: hw/piix3.c:207:
+^Iqdev_connect_gpio_out(DEVICE(&s->pit), 0, isa_get_irq(ISA_DEVICE(&s->pit), 0));$

WARNING: line over 80 characters
#828: FILE: hw/piix3.c:243:
+    k->device_id    = PCI_DEVICE_ID_INTEL_82371SB_0; // 82371SB PIIX3 PCI-to-ISA bridge (Step A1)

ERROR: do not use C99 // comments
#828: FILE: hw/piix3.c:243:
+    k->device_id    = PCI_DEVICE_ID_INTEL_82371SB_0; // 82371SB PIIX3 PCI-to-ISA bridge (Step A1)

total: 11 errors, 4 warnings, 870 lines checked

/home/hacker/patch/0001.patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.


scripts/get_maintainer.pl


get_maintainer.pl这个脚本可以查看你做的patch应该发给哪个maintainer:

hacker@hacker:~/qemu7$ ./scripts/get_maintainer.pl ~/patch/0001.patch 
"Michael S. Tsirkin" <mst@redhat.com> (supporter:PCI)
Blue Swirl <blauwirbel@gmail.com> (commit_signer:31/154=20%)
Alexander Graf <agraf@suse.de> (commit_signer:23/154=15%)
"Edgar E. Iglesias" <edgar.iglesias@gmail.com> (commit_signer:22/154=14%)
Peter Maydell <peter.maydell@linaro.org> (commit_signer:21/154=14%)
Jan Kiszka <jan.kiszka@siemens.com> (commit_signer:15/154=10%)

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值