Designing a vdev

Before you begin writing a vdev, you should decide what you need the vdev to do.

The questions below are to offer general guidance. See the rest of this guide and the source code examples to gain a better understanding of how these questions are answered in practice.

What, exactly, do I need my vdev to do?

Does the vdev need to initiate actions without prompting from a guest or hardware (e.g., a watchdog), or does it just need to assemble itself and wait for the guest or the hardware to ask it to do something (e.g., handle hardware device I/O)?

What kind of vdev do I need?

Will my vdev emulate a device for which a physical hardware device already exists, or will it implement functionality that is only possible (and perhaps only relevant) in a hypervisor system?

The answer to this question determines the answers to many of the other questions you need to answer.

If my vdev will be a para-virtualized vdev, should I use a standard such as VirtIO?

QNX hypervisors include a number of para-virtualized vdevs that implement VirtIO, including virtio-entropy described in this guide.

What resources, if any, will my vdev need in the hypervisor host?

Will my vdev need a driver or utility in the hypervisor host to access a resource such as a hardware device?

What interface will my vdev present to the guest?

If the vdev will be an emulation vdev, then it is likely that the guest already has a driver to interface with the hardware device. In this case, you will probably want to write your vdev so that your guest can use the driver already in its inventory.

If the vdev will be a para-virtualized device, then what resources will I have to write and add to my guest so that it can use the vdev? That is, what drivers do I need to write for my guest to be able to use my vdev?

What type of device will the vdev present to the guest (e.g., MMIO, PCI)?

If the vdev is an emulating vdev, you should consider designing it so that to the guest it is indistinguishable from the hardware device it is emulating. This way, the guest can use the drivers already in its inventory to interface with your vdev.

What memory mappings does the vdev require?

For example, are there specific physical addresses where the guest will expect the find the vdev?

What registers will the vdev present to the guest?

Remember, you are designing a device that to the guest looks like hardware. The guest will, therefore, expect to interact with your vdev like it interacts with hardware: reading and writing registers, for example.

What interrupts will the vdev use?

If the vdev is an emulating vdev, what sorts of interrupts does the guest expect from it: interrupts on an interrupt line, MSIs, etc.

How will my vdev be discovered by the guest?

For instance, which of the following will a guest use to discover my vdev:

Or, will I explicitly specify my vdev's location in memory and interrupts from within the guest?