[虚拟化/云][全栈demo] 为qemu增加一个PCI的watchdog外设(四)

时间:2022-09-21 11:06:47

通过前面的操作,我们已经可以创建一个带有我们自己的PCI的watchdog外设qemu 虚拟机了。

目的:

1. 了解我们的外设情况。

2. 为在guest中开发我们自己的linux PCI驱动程序做准备。

查看我们的watchdog设备

考虑到ubuntu对于 spice的支持不好。我们采用VNC显示。

-vnc 127.0.0.1:21 -vga cirrus -chardev stdio,id=mon0 -mon chardev=mon0,mode=readline

启动qemu

$ sudo x86_64-softmmu/qemu-system-x86_64 -enable-kvm -m 1024 -smp 1,sockets=1,cores=1,threads=1 -device cstl-watchdog -device virtio-blk-pci,scsi=off,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -drive file=/home/shhfeng/iso/image/ubuntu.12.04.img,if=none,id=drive-virtio-disk0,format=qcow2,cache=none  -net bridge,br=virbr2,helper=/home/shhfeng/qemu/debug/qemu-bridge-helper -net nic,model=virtio  -vnc 127.0.0.1:21 -vga cirrus -chardev stdio,id=mon0 -mon chardev=mon0,mode=readline

在qemu的monitor中查看watchdog的信息:

(qemu) info qtree

 (qemu) info qtree
bus: main-system-bus
type System
dev: hpet, id ""
gpio-in
gpio-out
timers = (0x3)
msi = false
hpet-intcap = (0x4)
irq
mmio 00000000fed00000/
dev: kvm-ioapic, id ""
gpio-in
gsi_base = ()
irq
mmio 00000000fec00000/
dev: i440FX-pcihost, id ""
pci-hole64-size = ( EiB)
short_root_bus = ()
irq
bus: pci.
type PCI
dev: cstl-watchdog, id ""
expiration-ticks = (0xa)
addr = 05.0
romfile = ""
rombar = (0x1)
multifunction = false
command_serr_enable = true
class Class , addr :05.0, pci id 1af4: (sub 1af4:)
bar : i/o at 0xc070 [0xc07f]
dev: virtio-blk-pci, id "virtio-disk0"
class = ()
ioeventfd = true
vectors = (0x2)
indirect_desc = true
event_idx = true
drive = "drive-virtio-disk0"
logical_block_size = (0x200)
physical_block_size = (0x200)
min_io_size = ()
opt_io_size = ()
bootindex = (0x2)
discard_granularity = (0xffffffff)
cyls = ()
heads = ()
secs = ()
serial = ""
config-wce = true
scsi = false
x-iothread = ""
addr = 04.0
romfile = ""
rombar = (0x1)
multifunction = false
command_serr_enable = true
class SCSI controller, addr :04.0, pci id 1af4: (sub 1af4:)
bar : i/o at 0xc000 [0xc03f]
bar : mem at 0xfebd2000 [0xfebd2fff]
bus: virtio-bus
type virtio-pci-bus
dev: virtio-blk-device, id ""
drive = "drive-virtio-disk0"
logical_block_size = (0x200)
physical_block_size = (0x200)
min_io_size = ()
opt_io_size = ()
bootindex = (0x2)
discard_granularity = (0xffffffff)
cyls = (0x3fff)
heads = (0x10)
secs = (0x3f)
serial = ""
config-wce = true
scsi = false
x-iothread = ""
dev: PIIX4_PM, id ""
smb_io_base = (0xb100)
disable_s3 = ()
disable_s4 = ()
s4_val = (0x2)
acpi-pci-hotplug-with-bridge-support = true
addr = 01.3
romfile = ""
rombar = (0x1)
multifunction = false
command_serr_enable = true
class Bridge, addr :01.3, pci id : (sub 1af4:)
bus: i2c
type i2c-bus
dev: smbus-eeprom, id ""
address = (0x57)
dev: smbus-eeprom, id ""
address = (0x56)
dev: smbus-eeprom, id ""
address = (0x55)
dev: smbus-eeprom, id ""
address = (0x54)
dev: smbus-eeprom, id ""
address = (0x53)
dev: smbus-eeprom, id ""
address = (0x52)
dev: smbus-eeprom, id ""
address = (0x51)
dev: smbus-eeprom, id ""
address = (0x50)
dev: piix3-ide, id ""
addr = 01.1
romfile = ""
rombar = (0x1)
multifunction = false
command_serr_enable = true
class IDE controller, addr :01.1, pci id : (sub 1af4:)
bar : i/o at 0xc060 [0xc06f]
bus: ide.
type IDE
dev: ide-cd, id "ide0-1-0"
drive = "drive-ide0-1-0"
logical_block_size = (0x200)
physical_block_size = (0x200)
min_io_size = ()
opt_io_size = ()
bootindex = (0x1)
discard_granularity = (0x200)
ver = "1.7.90"
wwn = ()
serial = "QM00003"
model = ""
unit = ()
bus: ide.
type IDE
dev: virtio-net-pci, id ""
ioeventfd = false
vectors = (0x3)
indirect_desc = true
event_idx = true
any_layout = true
csum = false
guest_csum = false
gso = true
guest_tso4 = false
guest_tso6 = false
guest_ecn = false
guest_ufo = false
host_tso4 = false
host_tso6 = false
host_ecn = false
host_ufo = false
mrg_rxbuf = true
status = true
ctrl_vq = true
ctrl_rx = true
ctrl_vlan = true
ctrl_rx_extra = true
ctrl_mac_addr = true
ctrl_guest_offloads = true
mq = false
mac = "52:54:00:12:34:56"
vlan =
netdev = "hub0port1"
bootindex = - (0xffffffffffffffff)
x-txtimer = (0x249f0)
x-txburst = (0x100)
tx = ""
addr = 03.0
romfile = "efi-virtio.rom"
rombar = (0x1)
multifunction = false
command_serr_enable = true
class Ethernet controller, addr :03.0, pci id 1af4: (sub 1af4:)
bar : i/o at 0xc040 [0xc05f]
bar : mem at 0xfebd1000 [0xfebd1fff]
bar : mem at 0xffffffffffffffff [0x3fffe]
bus: virtio-bus
type virtio-pci-bus
dev: virtio-net-device, id ""
mac = "52:54:00:12:34:56"
vlan =
netdev = "hub0port1"
bootindex = - (0xffffffffffffffff)
x-txtimer = (0x249f0)
x-txburst = (0x100)
tx = ""
dev: cirrus-vga, id ""
vgamem_mb = (0x8)
addr = 02.0
romfile = "vgabios-cirrus.bin"
rombar = (0x1)
multifunction = false
command_serr_enable = true
class VGA controller, addr :02.0, pci id :00b8 (sub 1af4:)
bar : mem at 0xfc000000 [0xfdffffff]
bar : mem at 0xfebd0000 [0xfebd0fff]
bar : mem at 0xffffffffffffffff [0xfffe]
dev: PIIX3, id ""
addr = 01.0
romfile = ""
rombar = (0x1)
multifunction = true
command_serr_enable = true
class ISA bridge, addr :01.0, pci id : (sub 1af4:)
bus: isa.
type ISA
dev: isa-fdc, id ""
iobase = (0x3f0)
irq = (0x6)
dma = (0x2)
driveA = "floppy0"
driveB = ""
bootindexA = - (0xffffffffffffffff)
bootindexB = - (0xffffffffffffffff)
check_media_rate = true
isa irq
dev: port92, id ""
dev: vmmouse, id ""
dev: vmport, id ""
dev: i8042, id ""
isa irqs ,
dev: isa-parallel, id ""
index = ()
iobase = (0x378)
irq = (0x7)
chardev = "parallel0"
isa irq
dev: isa-serial, id ""
index = ()
iobase = (0x3f8)
irq = (0x4)
chardev = "serial0"
wakeup = ()
isa irq
dev: isa-pcspk, id ""
iobase = (0x61)
dev: kvm-pit, id ""
gpio-in
iobase = (0x40)
lost_tick_policy = "delay"
dev: mc146818rtc, id ""
base_year = ()
lost_tick_policy = "discard"
dev: kvm-i8259, id ""
iobase = (0xa0)
elcr_addr = (0x4d1)
elcr_mask = (0xde)
master = false
dev: kvm-i8259, id ""
iobase = (0x20)
elcr_addr = (0x4d0)
elcr_mask = (0xf8)
master = true
dev: i440FX, id ""
addr = 00.0
romfile = ""
rombar = (0x1)
multifunction = false
command_serr_enable = true
class Host bridge, addr :00.0, pci id : (sub 1af4:)
dev: fw_cfg, id ""
ctl_iobase = (0x510)
data_iobase = (0x511)
irq
mmio ffffffffffffffff/
mmio ffffffffffffffff/
dev: kvmclock, id ""
irq
dev: kvmvapic, id ""
irq
dev: icc-bridge, id ""
irq
mmio 00000000fee00000/
bus: icc
type icc-bus
dev: kvm-apic, id ""
id = ()
vapic = true
dev: qemu64-x86_64-cpu, id ""
pmu = false
hv-spinlocks = - (0xffffffffffffffff)
hv-relaxed = false
hv-vapic = false
hv-time = false
check = false
enforce = false

可以找到我们的watchdog设备:

dev: cstl-watchdog, id ""
        expiration-ticks = 10 (0xa)
        addr = 05.0
        romfile = ""
        rombar = 1 (0x1)
        multifunction = false
        command_serr_enable = true
        class Class 0880, addr 00:05.0, pci id 1af4:0101 (sub 1af4:1100)
        bar 0: i/o at 0xc090 [0xc09f]
有些激动。

在guest中查看watchdog的信息。

$ lspci
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II]
00:01.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 03)
00:02.0 VGA compatible controller: Cirrus Logic GD 5446
00:03.0 Ethernet controller: Red Hat, Inc Virtio network device
00:04.0 Ethernet controller: Red Hat, Inc Virtio network device
00:05.0 System peripheral: Red Hat, Inc Device 0101 (rev 01)
00:06.0 SCSI storage controller: Red Hat, Inc Virtio block device

可以看到我们的device设备, Red Hat, Inc Device 0101 (rev 01),这个我们的代码中定义的是一致的。

static void cwd_class_init(ObjectClass *klass, void *data)
{
    DeviceClass *dc = DEVICE_CLASS(klass);
    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);

    k->init = cwd_realize;
    k->exit = cwd_unrealize;
    k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
    k->device_id = 0x0101;
    k->revision = 0x01;
    k->class_id = PCI_CLASS_SYSTEM_OTHER;
    dc->reset = cwd_reset;
    dc->vmsd = &vmstate_cwd;
    dc->props = cwd_properties;
}

在guest中,查看watchdog的配置寄存器

$ lspci -x
00:05.0 System peripheral: Red Hat, Inc Device 0101 (rev 01)
00: f4 1a 01 01 03 01 00 00 01 00 80 08 00 00 00 00
10: 91 c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00
20: 00 00 00 00 00 00 00 00 00 00 00 00 f4 1a 00 11
30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

[虚拟化/云][全栈demo] 为qemu增加一个PCI的watchdog外设(四)的更多相关文章

  1. [虚拟化/云][全栈demo] 为qemu增加一个PCI的watchdog外设(九)

    目的 1. 使用verilog/vhdl设计一个PCI的watchdog设备. 2. 通过systemverilog 写testbench. 很久之前研究过AC97的verilog代码.但是很久没用v ...

  2. [虚拟化/云][全栈demo] 为qemu增加一个PCI的watchdog外设(一)

    目的: 结合现在比较流行的技术,通过一个demo 展示一个全栈式设计的各种技能. 一个全栈式的工程师,应该能设计通过verilog/VHDL做logical设计.能写内核驱动,能架站. 要熟悉veri ...

  3. [虚拟化/云][全栈demo] 为qemu增加一个PCI的watchdog外设(六)

    目的: 1. 为我们自己的watchdog写一个驱动 步骤: 通过之前的介绍,我们很容易猜想到写我们基于PCI的watchdog驱动,可以分2个步骤. 1. 探测加载PCI设备 这部分代码跟我们的设备 ...

  4. [虚拟化/云][全栈demo] 为qemu增加一个PCI的watchdog外设(二)

    这篇文章的理解,需要一些专业知识了. 我们可以创建模拟自己的外设吗? 我们已经知道什么是qemu了,我们可以通过qmeu的提供的外设,DIY一个计算机了. 但是我们可能还不满足,我们可以自己制造一个外 ...

  5. [虚拟化/云][全栈demo] 为qemu增加一个PCI的watchdog外设(八)

    目的: 1. 通过网页读取watchdog的信息 2. 通过网页设置watchdog 准备工作: 1. 选择一个web框架,选用 cherrypy $ sudo apt-get install pyt ...

  6. [虚拟化/云][全栈demo] 为qemu增加一个PCI的watchdog外设(五)

    目的: 1. 了解PCI的基本知识,为完成watchdog的设备做准备. 准备知识: 简单的说,PCI 设备分3个空间. 配置空间,IO空间,内存地址空间. PCI设备厂家决定了外设是使用IO空间还是 ...

  7. [虚拟化/云][全栈demo] 为qemu增加一个PCI的watchdog外设(七)

    目标: 1. 完成最终的设备驱动,增加具体的watchdog设备操作的代码. 测试代码: 代码最终实现见cwd_demo.c 代码只实现了read与write.  没有实现ioctl. 因此,我们可以 ...

  8. [虚拟化/云][全栈demo] 为qemu增加一个PCI的watchdog外设(三)

    我们已经设计了一个基于qemu的watchdog了.下一步工作就是创建一个含有我们的watchdog的虚拟计算机器了. 准备工作: 1. 使用virt-manager或者virsh创建一个虚拟机器. ...

  9. 从零开始的全栈工程师——利用CSS3画一个正方体 ( css3 )

    transform属性 CSS3的变形(transform)属性让元素在一个坐标系统中变形.transform属性的基本语法如下: transform:none | <transform-fun ...

随机推荐

  1. JS获取各种浏览器窗口大小的方法

    常用:JS 获取浏览器窗口大小复制代码 代码如下:// 获取窗口宽度if (window.innerWidth)winWidth = window.innerWidth;else if ((docum ...

  2. &lbrack;logstash-input-file&rsqb;插件使用详解

    前篇介绍过Logstash的使用,本篇继续深入,介绍下最常用的input插件——file. 这个插件可以从指定的目录或者文件读取内容,输入到管道处理,也算是logstash的核心插件了,大多数的使用场 ...

  3. Linux软件安装为什么名字不一样

    一.说安装 1.安装 yacc :# yum install byacc 2.安装 glib: :# yum install glibc 3.安装 wireshark :# yum install w ...

  4. &lbrack;转&rsqb;Linux下的图形库介绍

    [转]Linux 下的图形库介绍 http://blog.csdn.net/gogor/article/details/5925925 在进行Linux下的图形系统编程时,我们常常会遇到以下这些概念: ...

  5. 一致性哈希&lpar;consistent hashing&rpar;算法

    文章同步发表在博主的网站朗度云,传输门:http://www.wolfbe.com/detail/201608/341.html 1.背景        我们都知道memcached服务器是不提供分布 ...

  6. &lpar;简单&rpar; FZU 1686 神龙的难题 &comma; DLX&plus;可重复覆盖。

    Description 这是个剑与魔法的世界.英雄和魔物同在,动荡和安定并存.但总的来说,库尔特王国是个安宁的国家,人民安居乐业,魔物也比较少.但是.总有一些魔物不时会进入城市附近,干扰人民的生活.就 ...

  7. C&num; Web开发中弹出对话框的函数&lbrack;转载&rsqb;

    public void Alert(string str_Message) { ClientScriptManager scriptManager =((Page)System.Web.HttpCon ...

  8. linux 下安装ftp 并远程连接

    1.确认是否已安装 ftp 1 pgrep vsftpd   #查看ftp 服务进程 无结果如下图所示 2.执行安装 1 yum install vsftpd     #安装ftp 服务 3.执行过程 ...

  9. MySQL基准测试&lpar;一&rpar;--原因,策略,思路

    MySQL基准测试(一)--原因,策略,思路 运用benchmark的原因 验证一些你认为的问题,通过基准测试和模拟数据来验证. 解决生产系统的一些异常 测试系统的当前的运行情况,通过历史的基准测试结 ...

  10. 启明星系统安装教程(如何在windows2012里配置IIS)

    (1)安装IIS 因为在windows2012里,安装数据库,IIS部分组件都需要.NET3.5,而默认windows2012安装时,并不会把此组件复制到电脑里 导致,后期要安装.NET3.5还需要安 ...