aboutsummaryrefslogtreecommitdiff
path: root/include/hw/virtio/vhost-user-base.h
blob: 51d0968b893aacda692a409fbde236c20b685ff9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * Vhost-user generic virtio device
 *
 * Copyright (c) 2023 Linaro Ltd
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#ifndef QEMU_VHOST_USER_BASE_H
#define QEMU_VHOST_USER_BASE_H

#include "hw/virtio/vhost.h"
#include "hw/virtio/vhost-user.h"

#define TYPE_VHOST_USER_BASE "vhost-user-base"

OBJECT_DECLARE_TYPE(VHostUserBase, VHostUserBaseClass, VHOST_USER_BASE)

struct VHostUserBase {
    VirtIODevice parent_obj;

    /* Properties */
    CharBackend chardev;
    uint16_t virtio_id;
    uint32_t num_vqs;
    uint32_t vq_size; /* can't exceed VIRTIO_QUEUE_MAX */
    uint32_t config_size;
    /* State tracking */
    VhostUserState vhost_user;
    struct vhost_virtqueue *vhost_vq;
    struct vhost_dev vhost_dev;
    GPtrArray *vqs;
    bool connected;
};

/*
 * Needed so we can use the base realize after specialisation
 * tweaks
 */
struct VHostUserBaseClass {
    VirtioDeviceClass parent_class;

    DeviceRealize parent_realize;
};


#define TYPE_VHOST_USER_DEVICE "vhost-user-device"

#endif /* QEMU_VHOST_USER_BASE_H */