Skip to contentSkip to conversation

virtio: Introduce virtio-testdev

PATCH In review Andrew Jones 2 participants 3 messages Jan 29, 2014 – Jan 30, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 virtio: Introduce virtio-testdev

This is a virtio version of hw/misc/debugexit and should evolve into a virtio version of pc-testdev. pc-testdev uses the PC's ISA bus, whereas this testdev can be plugged into a virtio-mmio transport, which is needed for kvm-unit-tests/arm. virtio-testdev uses the virtio device config space as a communication channel, and implements an RTAS-like protocol through it allowing guests to execute commands. Only three commands are currently implemented;
1) VERSION: for version compatibility checks
2) CLEAR: set all the config space back to zero
3) EXIT: exit() from qemu with a status code

---
v3: Convert to QOM realize
v2:
- No real functional changes, just added some comments and changed register bank accesses to use byte offsets, allowing the driver implementation to better mirror this device's implementation.

---
 hw/virtio/Makefile.objs    |   1 +
 hw/virtio/virtio-testdev.c | 154 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 155 insertions(+)
 create mode 100644 hw/virtio/virtio-testdev.c
hw/virtio/Makefile.objs +1 -0
index 1ba53d9cc316c..b63fea4a175f0 100644
@@ -3,6 +3,7 @@ common-obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o
 common-obj-y += virtio-bus.o
 common-obj-y += virtio-mmio.o
 common-obj-$(CONFIG_VIRTIO_BLK_DATA_PLANE) += dataplane/
+common-obj-y += virtio-testdev.o
 
 obj-y += virtio.o virtio-balloon.o 
 obj-$(CONFIG_LINUX) += vhost.o
hw/virtio/virtio-testdev.c new file +154 -0

154 lines not on this page · raw message

Signature · 1 line
1.8.1.4
#1 lore raw
Quoted 11 lines · Andrew Jones

This is a virtio version of hw/misc/debugexit and should evolve into a virtio version of pc-testdev. pc-testdev uses the PC's ISA bus, whereas this testdev can be plugged into a virtio-mmio transport, which is needed for kvm-unit-tests/arm. virtio-testdev uses the virtio device config space as a communication channel, and implements an RTAS-like protocol through it allowing guests to execute commands. Only three commands are currently implemented;
1) VERSION: for version compatibility checks
2) CLEAR: set all the config space back to zero
3) EXIT: exit() from qemu with a status code

hw/virtio/virtio-testdev.c line 117

Quoted 5 lines
hw/virtio/virtio-testdev.c new file +5 -0
+static uint32_t virtio_testdev_get_features(VirtIODevice *vdev, uint32_t f)
+{
+    return f;
+}
+

Is this meant to be a stub currently?

Mike

Signature · 1 line
Mike Day | "Endurance is a Virtue"
#2 lore raw
Quoted 14 lines · Mike Day
Quoted 10 lines · Andrew Jones

This is a virtio version of hw/misc/debugexit and should evolve into a virtio version of pc-testdev. pc-testdev uses the PC's ISA bus, whereas this testdev can be plugged into a virtio-mmio transport, which is needed for kvm-unit-tests/arm. virtio-testdev uses the virtio device config space as a communication channel, and implements an RTAS-like protocol through it allowing guests to execute commands. Only three commands are currently implemented;
1) VERSION: for version compatibility checks
2) CLEAR: set all the config space back to zero
3) EXIT: exit() from qemu with a status code

Quoted 8 lines

hw/virtio/virtio-testdev.c line 117

Quoted 5 lines
hw/virtio/virtio-testdev.c new file +5 -0
+static uint32_t virtio_testdev_get_features(VirtIODevice *vdev, uint32_t f)
+{
+    return f;
+}
+

Is this meant to be a stub currently?

Something like that. *_get_features() must be supplied by all virtio devices. Just returning the requested features, f, rather than zero, is how virtio-rng does it. So I went that way too.

drew