修改版本為1.7.1
目前在
hw/virtio
新增 virtio-mydevice.h, virtio-mydevice.c
include/hw/virtio/virtio-mydevice.h
新增
typedef struct VirtIOmydevice {
VirtIODevice parent_obj;
//VirtQueue *ivq, *dvq, *svq;
VirtQueue *vq[2]; //new
uint32_t num_pages;
uint32_t actual;
uint64_t stats[VIRTIO_MYDEVICE_S_NR];
VirtQueueElement stats_vq_elem;
size_t stats_vq_offset;
QEMUTimer *stats_timer;
int64_t stats_last_update;
int64_t stats_poll_interval;
int status; //new
} VirtIOmydevice;
hw/virtio/virtio-mydevice.c
的
virtio_mydevice_device_init() 裡面去add virtio queue:
s->vq[0] = virtio_add_queue(vdev, 1024, virtio_mydevice_handle_output);
s->vq[1] = virtio_add_queue(vdev, 1024, virtio_mydevice_handle_output);
然後在virtio_mydevice_handle_output裡面去
virtqueue_pop,
virtqueue_push