vdev_factory

Data structure used for creating new vdev instances

Synopsis:

#include <qvm/vdev-core.h>
struct vdev_factory {
    struct vdev_factory* next;
    int (*control)(vdev_t *vdev, unsigned ctrl, const char *arg);
    enum vdev_ref_status (*vread)(vdev_t *vdev, unsigned cookie, 
        const struct qvm_state_block *vopnd,
        const struct qvm_state_block *oopnd,
        struct guest_cpu *gcp);
    enum vdev_ref_status (*vwrite)(vdev_t *vdev, unsigned cookie, 
        const struct qvm_state_block *vopnd,
        const struct qvm_state_block *oopnd,
        struct guest_cpu *gcp);
    int (*pulse)(vdev_t *vdev, int8_t code);
    void (*timer)(vdev_t *vdev, void *data,
        const struct guest_timer_data *tdp, struct guest_cpu *gcp);
    const struct vdev_pic_functions* pic;
    const char *const * option_list;
    const char* name;
    unsigned factory_flags;
    unsigned acc_sizes;
    unsigned extra_space;
    unsigned safety;
} ;

Data:

struct vdev_factory* next

A pointer to next entry in a linked list of structures Initialized by qvm.

int (*control)(vdev_t *vdev, unsigned ctrl, const char *arg)

Required function to perform various operations on the vdev (see VDEV_CTRL_* macros)

enum vdev_ref_status (*vread)(vdev_t *vdev, unsigned cookie, const struct qvm_state_block *vopnd, const struct qvm_state_block *oopnd, struct guest_cpu *gcp)

Optional function to handle a read from the vdev. If you don't handle this request, behavior is as specified by the unsupported option in the VM configuration (see the unsupported option in the QHS 2.0 User's Guide).

enum vdev_ref_status (*vwrite)(vdev_t *vdev, unsigned cookie, const struct qvm_state_block *vopnd, const struct qvm_state_block *oopnd, struct guest_cpu *gcp)

Optional function to handle a write to the vdev. If you don't handle this request, behavior is as specified by the unsupported option in the VM configuration (see the unsupported option in the QHS 2.0 User's Guide).

int (*pulse)(vdev_t *vdev, int8_t code)

Optional function to handle a pulse delivery for the vdev. Optional: if you send pulse to yourself, you need this vdev, or you'll get a crash.

void (*timer)(vdev_t *vdev, void *data, const struct guest_timer_data *tdp, struct guest_cpu *gcp)

Optional function to handle a timer or trigger notification for the vdev. If you use guest_timer_notify(), you need this, or you'll get a crash.

const struct vdev_pic_functions* pic

PIC-specific operations. See vdev_pic_functions.

const char *const * option_list

A pointer to an array of vdev-specific options (Optional: VDEV_CTRL_FIRST_OPTIDX).

const char* name

The name of the vdev type. If NULL, the name is filled in with the name of the shared object the factory is in. This should typically be NULL. The qvm process adds the vdev- prefix and the .so suffix.

unsigned factory_flags

Bit set of vdev_factory_flags values to control parsing and creation of the device. See above.

unsigned acc_sizes

Bit set of (1u << byte_size) values for a list of allowed access sizes.

unsigned extra_space

The number of additional bytes to allocate in the vdev_s structure for the device-specific state. A pointer to that space is stored in the vdev_s structure's v_device member.

unsigned safety

Specify if this is the safety version of the vdev; if this is the safety version, you should use VDEV_SAFETY_SELECTED.

Library:

Provided by qvm; no external library is required.

Description:

You can provide NULL to optional functions.

The only time you manipulate the pointer to this function is when you pass it to vdev_register_factory.