On Fri, Nov 24, 2017 at 01:25:42PM +0530, P J P wrote: > From: Prasad J Pandit <p...@fedoraproject.org> > > An uninitialised VirtQueue object or one with Vring.align field > set to zero(0) could lead to arithmetic exceptions. Add a unit > test to validate it. > > Signed-off-by: Prasad J Pandit <p...@fedoraproject.org> > --- > tests/virtio-blk-test.c | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c > index e6fb9bac87..d00ceb0501 100644 > --- a/tests/virtio-blk-test.c > +++ b/tests/virtio-blk-test.c > @@ -674,6 +674,26 @@ static void pci_hotplug(void) > qtest_shutdown(qs); > } > > +static void test_vring_align(void)
It's important to include a doc comment so the purpose of the test is clear: /* * Check that setting the vring addr on a non-existent virtqueue does * not crash. */ I think the _align name is confusing since the vring alignment is not directly affected by this test case. Please call it test_nonexistent_virtqueue() instead. > +{ > + QPCIBar bar0; > + QOSState *qs; > + QPCIDevice *dev; > + > + qs = pci_test_start(); > + dev = qpci_device_find(qs->pcibus, QPCI_DEVFN(4, 0)); > + g_assert(dev != NULL); > + > + qpci_device_enable(dev); > + bar0 = qpci_iomap(dev, 0, NULL); > + > + qpci_io_writeb(dev, bar0, VIRTIO_PCI_QUEUE_SEL, 2); > + qpci_io_writel(dev, bar0, VIRTIO_PCI_QUEUE_PFN, 1); > + > + g_free(dev); > + qtest_shutdown(qs); > +}
signature.asc
Description: PGP signature