[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v10 0/8] hmp,qmp: Add commands to introspect virtio devices
From: |
Jonah Palmer |
Subject: |
[PATCH v10 0/8] hmp,qmp: Add commands to introspect virtio devices |
Date: |
Mon, 6 Dec 2021 07:43:18 -0500 |
This series introduces new QMP/HMP commands to dump the status of a
virtio device at different levels.
[Jonah: Rebasing previous patchset from Nov. 10 (v9). Original patches
are by Laurent Vivier from May 2020.
Rebase from v9 to v10 includes reformatting virtio.json examples and
command structures for better consistency. Also removed all enums from
virtio.json and replaced their purpose with string literals.
Removed @ndescs from VirtioQueueElement, as the number of descriptors
can be inferred from the length of the @descs chain.
Lastly, removed the examples in hmp-commands-info.hx to fix 'inconsistent
literal block quoting' warning from Sphinx.]
1. List available virtio devices in the machine
HMP Form:
info virtio
Example:
(qemu) info virtio
/machine/peripheral/vsock0/virtio-backend [vhost-vsock]
/machine/peripheral/crypto0/virtio-backend [virtio-crypto]
/machine/peripheral-anon/device[2]/virtio-backend [virtio-scsi]
/machine/peripheral-anon/device[1]/virtio-backend [virtio-net]
/machine/peripheral-anon/device[0]/virtio-backend [virtio-serial]
QMP Form:
{ 'command': 'x-query-virtio',
'returns': ['VirtioInfo'],
'features': [ 'unstable' ] }
Example:
-> { "execute": "x-query-virtio" }
<- { "return": [
{
"path": "/machine/peripheral/vsock0/virtio-backend",
"name": "vhost-vsock"
},
{
"path": "/machine/peripheral/crypto0/virtio-backend",
"name": "virtio-crypto"
},
{
"path": "/machine/peripheral-anon/device[2]/virtio-backend",
"name": "virtio-scsi"
},
{
"path": "/machine/peripheral-anon/device[1]/virtio-backend",
"name": "virtio-net"
},
{
"path": "/machine/peripheral-anon/device[0]/virtio-backend",
"name": "virtio-serial"
}
]
}
2. Display status of a given virtio device
HMP Form:
info virtio-status <path>
Example:
(qemu) info virtio-status /machine/peripheral/vsock0/virtio-backend
/machine/peripheral/vsock0/virtio-backend:
device_name: vhost-vsock (vhost)
device_id: 19
vhost_started: true
bus_name: (null)
broken: false
disabled: false
disable_legacy_check: false
started: true
use_started: true
start_on_kick: false
use_guest_notifier_mask: true
vm_running: true
num_vqs: 3
queue_sel: 2
isr: 0
endianness: little
status: ACKNOWLEDGE, DRIVER, FEATURES_OK, DRIVER_OK
Guest features: EVENT_IDX, INDIRECT_DESC, VERSION_1
Host features: PROTOCOL_FEATURES, EVENT_IDX, INDIRECT_DESC,
VERSION_1, ANY_LAYOUT,
NOTIFY_ON_EMPTY
Backend features:
VHost:
nvqs: 2
vq_index: 0
max_queues: 0
n_mem_sections: 4
n_tmp_sections: 4
backend_cap: 0
log_enabled: false
log_size: 0
Features: EVENT_IDX, INDIRECT_DESC, VERSION_1,
ANY_LAYOUT, NOTIFY_ON_EMPTY
LOG_ALL
Acked features: EVENT_IDX, INDIRECT_DESC, VERSION_1
Backend features:
Protocol features:
QMP Form:
{ 'command': 'x-query-virtio-status',
'data': { 'path': 'str' },
'returns': 'VirtioStatus',
'features': [ 'unstable' ] }
Example:
-> { "execute": "x-query-virtio-status",
"arguments": { "path": "/machine/peripheral/vsock0/virtio-backend"
}
}
<- { "return": {
"device-endian": "little",
"bus-name": "",
"disable-legacy-check": false,
"name": "vhost-vsock",
"started": true,
"device-id": 19,
"vhost-dev": {
"n-tmp-sections": 4,
"n-mem-sections": 4,
"max-queues": 0,
"backend-cap": 0,
"log-size": 0,
"backend-features": {
"transports": [],
"dev-features": []
},
"nvqs": 2,
"protocol-features": {
"protocols": []
},
"vq-index": 0,
"log-enabled": false,
"acked-features": {
"transports": ["EVENT_IDX", "INDIRECT_DESC",
"VERSION_1"],
"dev-features": []
},
"features": {
"transports": ["EVENT_IDX", "INDIRECT_DESC",
"VERSION_1", "ANY_LAYOUT",
"NOTIFY_ON_EMPTY"],
"dev-features": ["LOG_ALL"]
}
},
"backend-features": {
"transports": [],
"dev-features": []
},
"start-on-kick": false,
"isr": 0,
"broken": false,
"status": {
"statuses": ["ACKNOWLEDGE", "DRIVER", "FEATURES_OK",
"DRIVER_OK"]
},
"num-vqs": 3,
"guest-features": {
"transports": ["EVENT_IDX", "INDIRECT_DESC", "VERSION_1"],
"dev-features": []
},
"host-features": {
"transports": ["PROTOCOL_FEATURES", "EVENT_IDX",
"INDIRECT_DESC", "VERSION_1",
"ANY_LAYOUT", "NOTIFY_ON_EMPTY"],
"dev-features": []
},
"use-guest-notifier-mask": true,
"vm-running": true,
"queue-sel": 2,
"disabled": false,
"vhost-started": true,
"use-started": true
}
}
3. Display status of a given virtio queue
HMP Form:
info virtio-queue-status <path> <queue>
Example:
(qemu) info virtio-queue-status
/machine/peripheral-anon/device[1]/virtio-backend 2
/machine/peripheral-anon/device[1]/virtio-backend:
device_name: virtio-net
queue_index: 2
inuse: 0
used_idx: 27
signalled_used: 27
signalled_used_valid: true
VRing:
num: 64
num_default: 64
align: 4096
desc: 0x00000001342b5000
avail: 0x00000001342b5400
used: 0x00000001342b54c0
QMP Form:
{ 'command': 'x-query-virtio-queue-status',
'data': { 'path': 'str', 'queue': 'uint16' },
'returns': 'VirtQueueStatus',
'features': [ 'unstable' ] }
Example:
-> { "execute": "x-query-virtio-queue-status",
"arguments": { "path":
"/machine/peripheral-anon/device[1]/virtio-backend",
"queue": 2 }
}
<- { "return": {
"signalled-used": 27,
"inuse": 0,
"vring-align": 4096,
"vring-desc": 5170221056,
"signalled-used-valid": true,
"vring-num-default": 64,
"vring-avail": 5170222080,
"queue-index": 2,
"vring-used": 5170222272,
"used-idx": 27,
"name": "virtio-net",
"vring-num": 64 }
}
4. Display status of a given vhost queue
HMP Form:
info virtio-vhost-queue-status <path> <queue>
Example:
(qemu) info virtio-vhost-queue-status
/machine/peripheral-anon/device[1]/virtio-backend 1
/machine/peripheral-anon/device[1]/virtio-backend:
device_name: virtio-net (vhost)
kick: 0
call: 0
VRing:
num: 256
desc: 0x00007f31c032c000
desc_phys: 0x00000001340c6000
desc_size: 4096
avail: 0x00007f31c032d000
avail_phys: 0x00000001340c7000
avail_size: 518
used: 0x00007f31c032d240
used_phys: 0x00000001340c7240
used_size: 2054
QMP Form:
{ 'command': 'x-query-virtio-vhost-queue-status',
'data': { 'path': 'str', 'queue': 'uint16' },
'returns': 'VirtVhostQueueStatus',
'features': [ 'unstable' ] }
Example:
-> { "execute": "x-query-virtio-vhost-queue-status",
"arguments": { "path":
"/machine/peripheral-anon/device[1]/virtio-backend",
"queue": 1 }
}
<- { "return": {
"avail-phys": 5168197632,
"used-phys": 5168198208,
"avail-size": 518,
"desc-size": 4096,
"used-size": 2054,
"desc": 139851654676480,
"num": 256,
"name": "virtio-net",
"call": 0,
"avail": 139851654680576,
"desc-phys": 5168193536,
"used": 139851654681152,
"kick": 0 }
}
5. Display an element of a given virtio queue
HMP Form:
info virtio-queue-element <path> <queue> [index]
Example:
Dump the information of the head element of the third queue of
virtio-scsi:
(qemu) info virtio-queue-element
/machine/peripheral-anon/device[2]/virtio-backend 2
/machine/peripheral-anon/device[2]/virtio-backend:
device_name: virtio-scsi
index: 125
desc:
descs: addr 0xa4f90f1d0653b5fc len 1862028160 (used, avail,
next)
avail:
flags: 0
idx: 2936
ring: 125
used:
flags: 0
idx: 2936
QMP Form:
{ 'command': 'x-query-virtio-queue-element',
'data': { 'path': 'str', 'queue': 'uint16', '*index': 'uint16' },
'returns': 'VirtioQueueElement',
'features': [ 'unstable' ] }
Example:
-> { "execute": "x-query-virtio-queue-element",
"arguments": { "path":
"/machine/peripheral-anon/device[2]/virtio-backend",
"queue": 2 }
}
<- { "return": {
"index": 125,
"name": "virtio-scsi",
"descs": [
{ "flags": ["used", "avail", "next"],
"len": 1862028160,
"addr": 11887549308755752444 }
],
"avail": {
"idx": 2936,
"flags": 0,
"ring": 125
},
"used": {
"idx": 2936,
"flags": 0
}
}
}
v10: rebased for upstream (Qemu 7.0)
reformat virtio.json for better consistency
removed all enums from virtio.json; replaced with string literals
removed @ndescs from VirtioQueueElement
removed examples in hmp-commands-info.hx (to fix 'inconsistent
literal block quoting' error from Sphinx)
v9: rebased for upstream (Qemu 6.3)
change QMP command prefixes from 'x-debug-virtio' to
'x-query-virtio'
add 'unstable' feature to all 'x-query-virtio' prefixed
QMP commands
fix odd indentation for qapi/virtio.json
device features support for virtio-mem
move HMP sub-commands under 'virtio' top level to 'info'
top level
v8: add assert in virtio_id_to_name() to make sure we're
not returning NULL
minor documentation additions to qapi/virtio.json
add virtio introspection support for vhost-user-rng
v7: rebased for upstream (Qemu 6.2)
add ability to map between numberic device ID and
string device ID (name) for virtio devices
add get_vhost() callback function for VirtIODevices
expose more fields of VirtIODevice
expose fields of vhost devices
decode vhost user protocol features
decode VirtIODevice configuration statuses
vhost support for displaying virtio queue statuses
vhost support for displaying vhost queue statuses
expose driver and device areas when introspecting a
virtio queue element
changed patch attribution
v6: rebased for upstream (Qemu 6.1)
add all virtio/vhost types in same order as
include/standard-headers/linux/virtio_ids.h
use QAPI_LIST_PREPEND in qmp_x_debug_query_virtio rather than open
coding
v5: rebased for upstream
add device name, used index, and relative indicies to virtio queue-status
HMP command
add device name to virtio queue-status QMP command
add new virtio device features
v4: re-send series as v3 didn't reach qemu-devel
v3: use qapi_free_VirtioInfoList() on the head of the list, not on the tail.
Prefix the QMP commands with 'x-debug-'
v2: introduce VirtioType enum
use an enum for the endianness
change field names to stick to naming convertions (s/_/-/)
add a patch to decode feature bits
don't check if the queue is empty to allow display of old elements
use enum for desc flags
manage indirect desc
decode device features in the HMP command
Jonah Palmer (2):
virtio: drop name parameter for virtio_init()
virtio: add vhost support for virtio devices
Laurent Vivier (6):
qmp: add QMP command x-query-virtio
qmp: add QMP command x-query-virtio-status
qmp: decode feature & status bits in virtio-status
qmp: add QMP commands for virtio/vhost queue-status
qmp: add QMP command x-query-virtio-queue-element
hmp: add virtio commands
hmp-commands-info.hx | 70 +++
hw/9pfs/virtio-9p-device.c | 2 +-
hw/block/vhost-user-blk.c | 9 +-
hw/block/virtio-blk.c | 31 +-
hw/char/virtio-serial-bus.c | 14 +-
hw/display/vhost-user-gpu.c | 7 +
hw/display/virtio-gpu-base.c | 20 +-
hw/input/vhost-user-input.c | 7 +
hw/input/virtio-input.c | 13 +-
hw/net/virtio-net.c | 58 +-
hw/scsi/vhost-scsi.c | 8 +
hw/scsi/virtio-scsi.c | 20 +-
hw/virtio/meson.build | 2 +
hw/virtio/vhost-user-fs.c | 20 +-
hw/virtio/vhost-user-i2c.c | 7 +-
hw/virtio/vhost-user-rng.c | 9 +-
hw/virtio/vhost-user-vsock.c | 2 +-
hw/virtio/vhost-vsock-common.c | 22 +-
hw/virtio/vhost-vsock.c | 2 +-
hw/virtio/vhost.c | 4 +-
hw/virtio/virtio-balloon.c | 17 +-
hw/virtio/virtio-crypto.c | 22 +-
hw/virtio/virtio-iommu.c | 17 +-
hw/virtio/virtio-mem.c | 14 +-
hw/virtio/virtio-pmem.c | 3 +-
hw/virtio/virtio-rng.c | 2 +-
hw/virtio/virtio-stub.c | 42 ++
hw/virtio/virtio.c | 683 +++++++++++++++++++++-
include/hw/virtio/vhost-vsock-common.h | 2 +-
include/hw/virtio/vhost.h | 3 +
include/hw/virtio/virtio-gpu.h | 3 +-
include/hw/virtio/virtio.h | 26 +-
include/monitor/hmp.h | 5 +
include/standard-headers/linux/virtio_ids.h | 1 +
monitor/hmp-cmds.c | 311 +++++++++++
qapi/meson.build | 1 +
qapi/qapi-schema.json | 1 +
qapi/virtio.json | 839 ++++++++++++++++++++++++++++
tests/qtest/qmp-cmd-test.c | 1 +
39 files changed, 2275 insertions(+), 45 deletions(-)
create mode 100644 hw/virtio/virtio-stub.c
create mode 100644 qapi/virtio.json
--
1.8.3.1
- [PATCH v10 0/8] hmp,qmp: Add commands to introspect virtio devices,
Jonah Palmer <=
- [PATCH v10 4/8] qmp: add QMP command x-query-virtio-status, Jonah Palmer, 2021/12/06
- [PATCH v10 3/8] qmp: add QMP command x-query-virtio, Jonah Palmer, 2021/12/06
- [PATCH v10 1/8] virtio: drop name parameter for virtio_init(), Jonah Palmer, 2021/12/06
- [PATCH v10 2/8] virtio: add vhost support for virtio devices, Jonah Palmer, 2021/12/06
- [PATCH v10 7/8] qmp: add QMP command x-query-virtio-queue-element, Jonah Palmer, 2021/12/06
- [PATCH v10 6/8] qmp: add QMP commands for virtio/vhost queue-status, Jonah Palmer, 2021/12/06