mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-28 12:53:53 -06:00
virtio: add vhost-user-base and a generic vhost-user-device
In theory we shouldn't need to repeat so much boilerplate to support vhost-user backends. This provides a generic vhost-user-base QOM object and a derived vhost-user-device for which the user needs to provide the few bits of information that aren't currently provided by the vhost-user protocol. This should provide a baseline implementation from which the other vhost-user stub can specialise. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20230710153522.3469097-8-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
f05356f84d
commit
eee7780973
4 changed files with 443 additions and 0 deletions
45
include/hw/virtio/vhost-user-device.h
Normal file
45
include/hw/virtio/vhost-user-device.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Vhost-user generic virtio device
|
||||
*
|
||||
* Copyright (c) 2023 Linaro Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef QEMU_VHOST_USER_DEVICE_H
|
||||
#define QEMU_VHOST_USER_DEVICE_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;
|
||||
/* Properties */
|
||||
CharBackend chardev;
|
||||
uint16_t virtio_id;
|
||||
uint32_t num_vqs;
|
||||
/* 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 {
|
||||
/*< private >*/
|
||||
VirtioDeviceClass parent_class;
|
||||
/*< public >*/
|
||||
DeviceRealize parent_realize;
|
||||
};
|
||||
|
||||
/* shared for the benefit of the derived pci class */
|
||||
#define TYPE_VHOST_USER_DEVICE "vhost-user-device"
|
||||
|
||||
#endif /* QEMU_VHOST_USER_DEVICE_H */
|
Loading…
Add table
Add a link
Reference in a new issue