#
3008224c |
| 30-Apr-2025 |
Thomas Huth <thuth@redhat.com> |
tests/qtest/libqos: Avoid double swapping when using modern virtio
The logic in the qvirtio_read/write function is rather a headache, involving byte-swapping when the target is big endian, just to m
tests/qtest/libqos: Avoid double swapping when using modern virtio
The logic in the qvirtio_read/write function is rather a headache, involving byte-swapping when the target is big endian, just to maybe involve another byte-swapping in the qtest_read/write function immediately afterwards (on the QEMU side). Let's do it in a more obvious way here: For virtio 1.0, we know that the values have to be little endian, so let's read/write the bytes in that well known order here.
Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Tested-by: Alex Bennée <alex.bennee@linaro.org> Message-ID: <20250430132817.610903-1-thuth@redhat.com> Signed-off-by: Fabiano Rosas <farosas@suse.de>
show more ...
|
#
92cb8f8b |
| 08-Jan-2025 |
Alex Bennée <alex.bennee@linaro.org> |
tests/qtest: remove clock_steps from virtio tests
In the qtest environment time will not step forward if the system is paused (timers disabled) or we have no timer events to fire. As a result VirtIO
tests/qtest: remove clock_steps from virtio tests
In the qtest environment time will not step forward if the system is paused (timers disabled) or we have no timer events to fire. As a result VirtIO events are responded to directly and we don't need to step time forward.
We still do timeout processing to handle the fact the target QEMU may not be ready to respond right away. This will usually be due to a slow CI system or if QEMU is running under something like rr.
Future qtest patches will assert that time actually changes when a step is requested.
Reviewed-by: Fabiano Rosas <farosas@suse.de> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20250108121054.1126164-17-alex.bennee@linaro.org>
show more ...
|
#
66e41188 |
| 20-Mar-2024 |
Zheyu Ma <zheyuma97@gmail.com> |
libqos/virtio.c: Correct 'flags' reading in qvirtqueue_kick
In qvirtqueue_kick(), the 'flags' were previously being incorrectly read from vq->avail instead of the correct vq->used location. This upd
libqos/virtio.c: Correct 'flags' reading in qvirtqueue_kick
In qvirtqueue_kick(), the 'flags' were previously being incorrectly read from vq->avail instead of the correct vq->used location. This update ensures 'flags' are read from the correct location as per the virtio standard.
Signed-off-by: Zheyu Ma <zheyuma97@gmail.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-ID: <20240320090442.267525-1-zheyuma97@gmail.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
show more ...
|
#
3283843a |
| 17-Feb-2024 |
Daniel Henrique Barboza <dbarboza@ventanamicro.com> |
libqos/virtio.c: fix 'avail_event' offset in qvring_init()
In qvring_init() we're writing vq->used->avail_event at "vq->used + 2 + array_size". The struct pointed by vq->used is, from virtio_ring.h
libqos/virtio.c: fix 'avail_event' offset in qvring_init()
In qvring_init() we're writing vq->used->avail_event at "vq->used + 2 + array_size". The struct pointed by vq->used is, from virtio_ring.h Linux header):
* // A ring of used descriptor heads with free-running index. * __virtio16 used_flags; * __virtio16 used_idx; * struct vring_used_elem used[num]; * __virtio16 avail_event_idx;
So 'flags' is the word right at vq->used. 'idx' is vq->used + 2. We need to skip 'used_idx' by adding + 2 bytes, and then sum the vector size, to reach avail_event_idx. An example on how to properly access this field can be found in qvirtqueue_kick():
avail_event = qvirtio_readw(d, qts, vq->used + 4 + sizeof(struct vring_used_elem) * vq->size);
This error was detected when enabling the RISC-V 'virt' libqos machine. The 'idx' test from vhost-user-blk-test.c errors out with a timeout in qvirtio_wait_used_elem(). The timeout happens because when processing the first element, 'avail_event' is read in qvirtqueue_kick() as non-zero because we didn't initialize it properly (and the memory at that point happened to be non-zero). 'idx' is 0.
All of this makes this condition fail because "idx - avail_event" will overflow and be non-zero:
/* < 1 because we add elements to avail queue one by one */ if ((flags & VRING_USED_F_NO_NOTIFY) == 0 && (!vq->event || (uint16_t)(idx-avail_event) < 1)) { d->bus->virtqueue_kick(d, vq); }
As a result the virtqueue is never kicked and we'll timeout waiting for it.
Fixes: 1053587c3f ("libqos: Added EVENT_IDX support") Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-ID: <20240217192607.32565-3-dbarboza@ventanamicro.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
show more ...
|
#
2791490d |
| 17-Feb-2024 |
Daniel Henrique Barboza <dbarboza@ventanamicro.com> |
libqos/virtio.c: init all elems in qvring_indirect_desc_setup()
The loop isn't setting the values for the last element. Every other element is being initialized with addr = 0, flags = VRING_DESC_F_N
libqos/virtio.c: init all elems in qvring_indirect_desc_setup()
The loop isn't setting the values for the last element. Every other element is being initialized with addr = 0, flags = VRING_DESC_F_NEXT and next = i + 1. The last elem is never touched.
This became a problem when enabling a RISC-V 'virt' libqos machine in the 'indirect' test of virti-blk-test.c. The 'flags' for the last element will end up being an odd number (since we didn't touch it). Being an odd number it will be mistaken by VRING_DESC_F_NEXT, which happens to be 1.
Deep into hw/virt/virtio.c, in virtqueue_split_pop(), into virtqueue_split_read_next_desc(), a check for VRING_DESC_F_NEXT will be made to see if we're supposed to chain. The code will keep up chaining in the last element because the uninitialized value happens to be odd. We'll error out right after that because desc->next (which is also uninitialized) will be >= max. A VIRTQUEUE_READ_DESC_ERROR will be returned, with an error message like this in the stderr:
qemu-system-riscv64: Desc next is 49391
Since we never returned, we'll end up timing out at qvirtio_wait_used_elem():
ERROR:../tests/qtest/libqos/virtio.c:236:qvirtio_wait_used_elem: assertion failed: (g_get_monotonic_time() - start_time <= timeout_us)
The root cause is using uninitialized values from guest_alloc() in qvring_indirect_desc_setup(). There's no guarantee that the memory pages retrieved will be zeroed, so we can't make assumptions. In fact, commit 5b4f72f5e8 ("tests/qtest: properly initialise the vring used idx") fixed a similar problem stating "It is probably not wise to assume guest memory is zeroed anyway". I concur.
Initialize all elems in qvring_indirect_desc_setup().
Fixes: f294b029aa ("libqos: Added indirect descriptor support to virtio implementation") Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-ID: <20240217192607.32565-2-dbarboza@ventanamicro.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
show more ...
|
#
8fcfc823 |
| 02-Aug-2022 |
Alex Bennée <alex.bennee@linaro.org> |
tests/qtest: enable tests for virtio-gpio
We don't have a virtio-gpio implementation in QEMU and only support a vhost-user backend. The QEMU side of the code is minimal so it should be enough to ins
tests/qtest: enable tests for virtio-gpio
We don't have a virtio-gpio implementation in QEMU and only support a vhost-user backend. The QEMU side of the code is minimal so it should be enough to instantiate the device and pass some vhost-user messages over the control socket. To do this we hook into the existing vhost-user-test code and just add the bits required for gpio.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Cc: Viresh Kumar <viresh.kumar@linaro.org> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Eric Auger <eric.auger@redhat.com> Message-Id: <20220408155704.2777166-1-alex.bennee@linaro.org>
Message-Id: <20220802095010.3330793-23-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
show more ...
|
#
3bd869f3 |
| 02-Aug-2022 |
Alex Bennée <alex.bennee@linaro.org> |
tests/qtest: add assert to catch bad features
No device driver (which is what the qvirtio_ access functions represent) should be setting UNUSED(30) in the feature space. Although existing libqos use
tests/qtest: add assert to catch bad features
No device driver (which is what the qvirtio_ access functions represent) should be setting UNUSED(30) in the feature space. Although existing libqos users mask it out lets ensure nothing sneaks through.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20220802095010.3330793-20-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
show more ...
|
#
907b5105 |
| 30-Mar-2022 |
Marc-André Lureau <marcandre.lureau@redhat.com> |
tests: move libqtest.h back under qtest/
Since commit a2ce7dbd917 ("meson: convert tests/qtest to meson"), libqtest.h is under libqos/ directory, while libqtest.c is still in qtest/. Move back to it
tests: move libqtest.h back under qtest/
Since commit a2ce7dbd917 ("meson: convert tests/qtest to meson"), libqtest.h is under libqos/ directory, while libqtest.c is still in qtest/. Move back to its original location to avoid mixing with libqos/.
Suggested-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
show more ...
|
#
5b4f72f5 |
| 06-Apr-2022 |
Alex Bennée <alex.bennee@linaro.org> |
tests/qtest: properly initialise the vring used idx
Eric noticed while attempting to enable the vhost-user-blk-test for Aarch64 that that things didn't work unless he put in a dummy guest_malloc() a
tests/qtest: properly initialise the vring used idx
Eric noticed while attempting to enable the vhost-user-blk-test for Aarch64 that that things didn't work unless he put in a dummy guest_malloc() at the start of the test. Without it qvirtio_wait_used_elem() would assert when it reads a junk value for idx resulting in:
qvirtqueue_get_buf: idx:2401 last_idx:0 qvirtqueue_get_buf: 0x7ffcb6d3fe74, (nil) qvirtio_wait_used_elem: 3000000/0 ERROR:../../tests/qtest/libqos/virtio.c:226:qvirtio_wait_used_elem: assertion failed (got_desc_idx == desc_idx): (50331648 == 0) Bail out! ERROR:../../tests/qtest/libqos/virtio.c:226:qvirtio_wait_used_elem: assertion failed (got_desc_idx == desc_idx): (50331648 == 0)
What was actually happening is the guest_malloc() effectively pushed the allocation of the vring into the next page which just happened to have clear memory. After much tedious tracing of the code I could see that qvring_init() does attempt initialise a bunch of the vring structures but skips the vring->used.idx value. It is probably not wise to assume guest memory is zeroed anyway. Once the ring is properly initialised the hack is no longer needed to get things working.
Thanks-to: John Snow <jsnow@redhat.com> for helping debug Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20220406173356.1891500-1-alex.bennee@linaro.org> Tested-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
show more ...
|
#
a2ce7dbd |
| 04-Aug-2020 |
Paolo Bonzini <pbonzini@redhat.com> |
meson: convert tests/qtest to meson
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
#
1cf4323e |
| 10-Sep-2019 |
Thomas Huth <thuth@redhat.com> |
tests/libqos: Move the libqos files under tests/qtest/
The qos stuff belongs to qtest, so move it into that directory, too.
Message-Id: <20191218103059.11729-8-thuth@redhat.com> Reviewed-by: Paolo
tests/libqos: Move the libqos files under tests/qtest/
The qos stuff belongs to qtest, so move it into that directory, too.
Message-Id: <20191218103059.11729-8-thuth@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
show more ...
|
#
bccd82b4 |
| 23-Oct-2019 |
Stefan Hajnoczi <stefanha@redhat.com> |
libqos: access VIRTIO 1.0 vring in little-endian
VIRTIO 1.0 uses little-endian for the vring. Legacy VIRTIO uses guest endianness. Adjust the code to handle both.
Note that qvirtio_readq() is not
libqos: access VIRTIO 1.0 vring in little-endian
VIRTIO 1.0 uses little-endian for the vring. Legacy VIRTIO uses guest endianness. Adjust the code to handle both.
Note that qvirtio_readq() is not defined because it has no users. All the other accessors are really needed.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <20191023100425.12168-10-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
show more ...
|
#
c0f79698 |
| 23-Oct-2019 |
Stefan Hajnoczi <stefanha@redhat.com> |
libqos: implement VIRTIO 1.0 FEATURES_OK step
Device initialization has an extra step in VIRTIO 1.0. The FEATURES_OK status bit is set to indicate that feature negotiation has completed. The driver
libqos: implement VIRTIO 1.0 FEATURES_OK step
Device initialization has an extra step in VIRTIO 1.0. The FEATURES_OK status bit is set to indicate that feature negotiation has completed. The driver then reads the status register again to check that the device agrees with the final features.
Implement this step as part of qvirtio_set_features() instead of introducing a separate function. This way all existing code works without modifications.
The check in qvirtio_set_driver_ok() needs to be updated because FEATURES_OK will be set for VIRTIO 1.0 devices.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20191023100425.12168-9-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Thomas Huth" <thuth@redhat.com>
show more ...
|
#
56140fbb |
| 23-Oct-2019 |
Stefan Hajnoczi <stefanha@redhat.com> |
libqos: enforce Device Initialization order
According to VIRTIO 1.1 "3.1.1 Driver Requirements: Device Initialization", configuration space and virtqueues cannot be accessed before features have bee
libqos: enforce Device Initialization order
According to VIRTIO 1.1 "3.1.1 Driver Requirements: Device Initialization", configuration space and virtqueues cannot be accessed before features have been negotiated. Enforce this requirement.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20191023100425.12168-8-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com>
show more ...
|
#
a9340358 |
| 23-Oct-2019 |
Stefan Hajnoczi <stefanha@redhat.com> |
libqos: extend feature bits to 64-bit
In VIRTIO 1.0 feature bits changed from 32-bit to 64-bit. (In fact, the transports allow even more feature bits but nothing uses more than 64 bits today.)
Add
libqos: extend feature bits to 64-bit
In VIRTIO 1.0 feature bits changed from 32-bit to 64-bit. (In fact, the transports allow even more feature bits but nothing uses more than 64 bits today.)
Add 64-bit feature bit support to virtio-mmio and virtio-pci. This will be necessary for VIRTIO 1.0 support.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20191023100425.12168-4-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
show more ...
|
#
b57ebd57 |
| 03-Sep-2019 |
Thomas Huth <thuth@redhat.com> |
tests/libqos: Replace clock_step with qtest_clock_step in virtio code
Library functions should not rely on functions that require global_qtest (since they might get used in tests that deal with mult
tests/libqos: Replace clock_step with qtest_clock_step in virtio code
Library functions should not rely on functions that require global_qtest (since they might get used in tests that deal with multiple states). Commit 1999a70a05ad603d ("Make generic virtio code independent from global_qtest") already tried to clean the libqos virtio code, but I missed to replace the clock_step() function. Thus change it now to qtest_clock_step() instead. The logic of the qvirtio_wait_config_isr() function is now pushed to the virtio-mmio.c and virtio-pci.c files instead, since we can get the QTestState here easily.
Message-Id: <20190904130047.25808-4-thuth@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
show more ...
|
#
1999a70a |
| 18-May-2019 |
Thomas Huth <thuth@redhat.com> |
tests/libqos: Make generic virtio code independent from global_qtest
The libqos library functions should never depend on global_qtest, since these functions might be used in tests that track multipl
tests/libqos: Make generic virtio code independent from global_qtest
The libqos library functions should never depend on global_qtest, since these functions might be used in tests that track multiple test states. Pass around a pointer to the QTestState instead.
Message-Id: <20190814195920.32023-1-thuth@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
show more ...
|
#
8b898f59 |
| 15-May-2019 |
Thomas Huth <thuth@redhat.com> |
tests/libqos: Get rid of global_qtest dependency in qvring_init()
Library functions should not depend on global_qtest functions like writew() and writeq(), so that they can also be used in tests tha
tests/libqos: Get rid of global_qtest dependency in qvring_init()
Library functions should not depend on global_qtest functions like writew() and writeq(), so that they can also be used in tests that deal with multiple QTestStates at the same time (like migration tests).
Message-Id: <20190515174328.16361-2-thuth@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
show more ...
|
#
19e3d979 |
| 05-Oct-2018 |
Paolo Bonzini <pbonzini@redhat.com> |
tests: move virtio entirely to qos-test
The only remaining test that needs libqos-virtio-obj-y is drive_del-test, which really only needs a function. Move that function to the test and remove libqo
tests: move virtio entirely to qos-test
The only remaining test that needs libqos-virtio-obj-y is drive_del-test, which really only needs a function. Move that function to the test and remove libqos-virtio-obj-y.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
583349d1 |
| 30-Jul-2018 |
Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> |
tests/libqos: virtio-net driver and interface nodes
Add qgraph nodes for virtio-net-pci and virtio-net-device. Both nodes produce virtio-net, but virtio-net-pci receives a pci-bus and overrides virt
tests/libqos: virtio-net driver and interface nodes
Add qgraph nodes for virtio-net-pci and virtio-net-device. Both nodes produce virtio-net, but virtio-net-pci receives a pci-bus and overrides virtio-pci QOSGraphObject and its functions, while virtio-net-device receives a virtio and implements its own functions
Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
1657291a |
| 18-Jul-2018 |
Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> |
qos-test: virtio-console and virtio-serial test node
Convert tests/virtio-console-test and tests/virtio-serial-test in qgraph test node. This test consumes a virtio-serial interface and checks that
qos-test: virtio-console and virtio-serial test node
Convert tests/virtio-console-test and tests/virtio-serial-test in qgraph test node. This test consumes a virtio-serial interface and checks that its function return the expected values.
Note that this test does not allocate any virtio-console or virtio-serial structure, it's all done by the qtest walking graph mechanism
Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
d5006a45 |
| 07-Oct-2018 |
Paolo Bonzini <pbonzini@redhat.com> |
tests/libqos: remove global_qtest from virtio endianness checks
This is needed to support migration tests with qgraph.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
#
34c97748 |
| 25-Jul-2018 |
Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> |
tests/libqos: introduce virtio_start_device
This function is intended to group all the qvirtio_* functions that start the qvirtio devices. Applied in all tests using this combination of functions.
tests/libqos: introduce virtio_start_device
This function is intended to group all the qvirtio_* functions that start the qvirtio devices. Applied in all tests using this combination of functions.
Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Reviewed-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
be3a6781 |
| 01-Feb-2018 |
Greg Kurz <groug@kaod.org> |
libqos/virtio: return length written into used descriptor
When a 9p request is flushed (ie, cancelled) by the guest, the device is expected to simply mark the request as used, without sending a 9p r
libqos/virtio: return length written into used descriptor
When a 9p request is flushed (ie, cancelled) by the guest, the device is expected to simply mark the request as used, without sending a 9p reply (ie, without writing anything into the used buffer).
To be able to test this, we need access to the length written by the device into the used descriptor. This patch adds a uint32_t * argument to qvirtqueue_get_buf() and qvirtio_wait_used_elem() for this purpose.
All existing users are updated accordingly.
Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
show more ...
|
#
2f84a92e |
| 31-Aug-2017 |
Thomas Huth <thuth@redhat.com> |
tests: Enable the drive_del test also on s390x
We can use the drive_del test on s390x, too, to check that adding and deleting also works fine with the virtio-ccw bus. But we have to make sure that w
tests: Enable the drive_del test also on s390x
We can use the drive_del test on s390x, too, to check that adding and deleting also works fine with the virtio-ccw bus. But we have to make sure that we use the devices with the "-ccw" suffix instead of the "-pci" suffix for the virtio-ccw transport on s390x. Introduce a helper function called qvirtio_get_dev_type() that returns the correct string for the current architecture.
Signed-off-by: Thomas Huth <thuth@redhat.com> Message-Id: <1504190408-11143-1-git-send-email-thuth@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
show more ...
|