+/*
+ * Check that setting the vring addr on a non-existent virtqueue does
+ * not crash.
+ */
+static void test_nonexistent_virtqueue(void)
+{
+ 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);
+}
+