How to list all devices emulated in a QEMU virtual machine?

10,387

Solution 1

info qtree

This awesome QEMU monitor command shows a nice tree view of how all the QEMU devices are placed.

You can get a QEMU monitor prompt either via:

  • Ctrl + A C on -nographic
  • Ctrl + Alt + ?, where ? is either 1, 2, 3, etc. in a graphic QEMU window
  • -monitor telnet::45454,server,nowait and then connect to it with telnet 45454

Then for example, I can see my network device as:

  dev: rtl8139, id ""                                                                                                                                                                                           
    mac = "52:54:00:12:34:56"                                                                                                                                                                                   
    vlan = <null>                                                                                                                                                                                               
    netdev = "net0"                                                                                                                                                                                             
    addr = 03.0                                                                                                                                                                                                 
    romfile = "efi-rtl8139.rom"                                                                                                                                                                                 
    rombar = 1 (0x1)                                                                                                                                                                                            
    multifunction = false                                                                                                                                                                                       
    command_serr_enable = true                                                                                                                                                                                  
    x-pcie-lnksta-dllla = true                                                                                                                                                                                  
    x-pcie-extcap-init = true                                                                                                                                                                                   
    class Ethernet controller, addr 00:03.0, pci id 10ec:8139 (sub 1af4:1100)                                                                                                                                   
    bar 0: i/o at 0xc000 [0xc0ff]                                                                                                                                                                               
    bar 1: mem at 0xfeb51000 [0xfeb510ff]                                                                                                                                                                       
    bar 6: mem at 0xffffffffffffffff [0x3fffe] 

and my storage device as:

    bus: virtio-bus
      type virtio-pci-bus
      dev: virtio-blk-device, id ""
        drive = "virtio0"
        logical_block_size = 512 (0x200)
        physical_block_size = 512 (0x200)
        min_io_size = 0 (0x0)
        opt_io_size = 0 (0x0)
        discard_granularity = 4294967295 (0xffffffff)
        write-cache = "auto"
        share-rw = false
        rerror = "auto"
        werror = "auto"
        cyls = 1040 (0x410)
        heads = 16 (0x10)
        secs = 63 (0x3f)
        serial = ""
        config-wce = true
        scsi = false
        request-merging = true
        num-queues = 1 (0x1)
        queue-size = 128 (0x80)
        iothread = ""
        indirect_desc = true
        event_idx = true
        notify_on_empty = true
        any_layout = true
        iommu_platform = false

and other PCI devices as:

  dev: edu, id ""
    addr = 06.0
    romfile = ""
    rombar = 1 (0x1)
    multifunction = false
    command_serr_enable = true
    x-pcie-lnksta-dllla = true
    x-pcie-extcap-init = true
    class Class 00ff, addr 00:06.0, pci id 1234:11e8 (sub 1af4:1100)
    bar 0: mem at 0xfea00000 [0xfeafffff]

Tested in QEMU v2.12.

Solution 2

If you have access to the guest, why not use something like 'lspci'. If you're trying to get this from the host, you'd need to figure out what defaults qemu is using. This is going to vary based on what version you're using.

I'd suggest you use libvirt instead of manually launching qemu. This would give you better APIs to the guests, and actually give you this information in a sane fashion (you could simply use virsh dumpxml to dump a configuration of the guest, including all attached hardware devices).

Share:
10,387
kumar
Author by

kumar

Fellow being :)

Updated on September 18, 2022

Comments

  • kumar
    kumar almost 2 years

    I have created a VM with the below command in qemu with KVM enabled.

    qemu-kvm -m 1024 -enable-kvm -hda /var/lib/libvirt/images/fedora.img
    

    I would like to know the exact devices that are emulated for this VM, including storage and network (I can see a network interface enabled inside VM using ifconfig).