mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:10 +00:00
vhost: move protocol_features to vhost_user
As comment says: it's only for vhost-user. So, let's move it to corresponding vhost backend realization. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20260420200339.708640-5-vsementsov@yandex-team.ru>
This commit is contained in:
committed by
Michael S. Tsirkin
parent
be9ecc9df0
commit
f9a8f58126
@@ -60,7 +60,6 @@ cryptodev_vhost_init(
|
||||
|
||||
crypto->cc = options->cc;
|
||||
|
||||
crypto->dev.protocol_features = 0;
|
||||
crypto->backend = -1;
|
||||
|
||||
/* vhost-user needs vq_index to initiate a specific queue pair */
|
||||
|
||||
@@ -572,10 +572,8 @@ static bool vhost_user_blk_inflight_needed(void *opaque)
|
||||
{
|
||||
struct VHostUserBlk *s = opaque;
|
||||
|
||||
bool inflight_migration = virtio_has_feature(s->dev.protocol_features,
|
||||
VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT);
|
||||
|
||||
return inflight_migration;
|
||||
return vhost_user_has_protocol_feature(
|
||||
&s->dev, VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT);
|
||||
}
|
||||
|
||||
static const VMStateDescription vmstate_vhost_user_blk_inflight = {
|
||||
|
||||
@@ -265,9 +265,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
|
||||
goto fail;
|
||||
}
|
||||
net->backend = r;
|
||||
net->dev.protocol_features = 0;
|
||||
} else {
|
||||
net->dev.protocol_features = 0;
|
||||
net->backend = -1;
|
||||
|
||||
/* vhost-user needs vq_index to initiate a specific queue pair */
|
||||
|
||||
@@ -94,6 +94,7 @@ system_virtio_ss.add_all(when: 'CONFIG_VIRTIO_PCI', if_true: virtio_pci_ss)
|
||||
|
||||
system_ss.add_all(when: 'CONFIG_VIRTIO', if_true: system_virtio_ss)
|
||||
stub_ss.add(files('vhost-stub.c'))
|
||||
stub_ss.add(files('vhost-user-stub.c'))
|
||||
stub_ss.add(files('virtio-stub.c'))
|
||||
stub_ss.add(files('virtio-md-stubs.c'))
|
||||
|
||||
|
||||
6
hw/virtio/vhost-user-stub.c
Normal file
6
hw/virtio/vhost-user-stub.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/virtio/vhost-user.h"
|
||||
|
||||
void vhost_user_qmp_status(struct vhost_dev *dev, VirtioStatus *status)
|
||||
{
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "qapi/error.h"
|
||||
#include "hw/virtio/virtio-dmabuf.h"
|
||||
#include "hw/virtio/virtio-qmp.h"
|
||||
#include "hw/virtio/vhost.h"
|
||||
#include "hw/virtio/virtio-crypto.h"
|
||||
#include "hw/virtio/vhost-user.h"
|
||||
@@ -259,6 +260,14 @@ struct vhost_user {
|
||||
/* Our current regions */
|
||||
int num_shadow_regions;
|
||||
struct vhost_memory_region shadow_regions[VHOST_USER_MAX_RAM_SLOTS];
|
||||
|
||||
/**
|
||||
* @protocol_features: the vhost-user protocol feature set by
|
||||
* VHOST_USER_SET_PROTOCOL_FEATURES. Protocol features are only
|
||||
* negotiated if VHOST_USER_F_PROTOCOL_FEATURES has been offered
|
||||
* by the backend (see @features).
|
||||
*/
|
||||
uint64_t protocol_features;
|
||||
};
|
||||
|
||||
struct scrub_regions {
|
||||
@@ -267,10 +276,13 @@ struct scrub_regions {
|
||||
int fd_idx;
|
||||
};
|
||||
|
||||
static bool vhost_user_has_protocol_feature(struct vhost_dev *dev,
|
||||
uint64_t feature)
|
||||
bool vhost_user_has_protocol_feature(struct vhost_dev *dev, uint64_t feature)
|
||||
{
|
||||
return virtio_has_feature(dev->protocol_features, feature);
|
||||
struct vhost_user *u = dev->opaque;
|
||||
|
||||
assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER);
|
||||
|
||||
return virtio_has_feature(u->protocol_features, feature);
|
||||
}
|
||||
|
||||
static int vhost_user_read_header(struct vhost_dev *dev, VhostUserMsg *msg)
|
||||
@@ -1338,8 +1350,8 @@ static int vhost_set_vring_file(struct vhost_dev *dev,
|
||||
int ret;
|
||||
int fds[VHOST_USER_MAX_RAM_SLOTS];
|
||||
size_t fd_num = 0;
|
||||
bool reply_supported = virtio_has_feature(dev->protocol_features,
|
||||
VHOST_USER_PROTOCOL_F_REPLY_ACK);
|
||||
bool reply_supported =
|
||||
vhost_user_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_REPLY_ACK);
|
||||
VhostUserMsg msg = {
|
||||
.hdr.request = request,
|
||||
.hdr.flags = VHOST_USER_VERSION,
|
||||
@@ -2239,8 +2251,8 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque,
|
||||
}
|
||||
|
||||
/* final set of protocol features */
|
||||
dev->protocol_features = protocol_features;
|
||||
err = vhost_user_set_protocol_features(dev, dev->protocol_features);
|
||||
u->protocol_features = protocol_features;
|
||||
err = vhost_user_set_protocol_features(dev, u->protocol_features);
|
||||
if (err < 0) {
|
||||
error_setg_errno(errp, EPROTO, "vhost_backend_init failed");
|
||||
return -EPROTO;
|
||||
@@ -3033,6 +3045,16 @@ static int vhost_user_check_device_state(struct vhost_dev *dev, Error **errp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vhost_user_qmp_status(struct vhost_dev *dev, VirtioStatus *status)
|
||||
{
|
||||
struct vhost_user *u = dev->opaque;
|
||||
|
||||
assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER);
|
||||
|
||||
status->vhost_dev->protocol_features =
|
||||
qmp_decode_protocols(u->protocol_features);
|
||||
}
|
||||
|
||||
const VhostOps user_ops = {
|
||||
.backend_type = VHOST_BACKEND_TYPE_USER,
|
||||
.vhost_backend_init = vhost_user_backend_init,
|
||||
|
||||
@@ -751,12 +751,14 @@ VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp)
|
||||
status->vhost_dev->acked_features =
|
||||
qmp_decode_features(vdev->device_id, hdev->acked_features_ex);
|
||||
|
||||
status->vhost_dev->protocol_features =
|
||||
qmp_decode_protocols(hdev->protocol_features);
|
||||
status->vhost_dev->max_queues = hdev->max_queues;
|
||||
status->vhost_dev->backend_cap = hdev->backend_cap;
|
||||
status->vhost_dev->log_enabled = hdev->log_enabled;
|
||||
status->vhost_dev->log_size = hdev->log_size;
|
||||
|
||||
if (hdev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER) {
|
||||
vhost_user_qmp_status(hdev, status);
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "chardev/char-fe.h"
|
||||
#include "hw/virtio/virtio.h"
|
||||
#include "qapi/qapi-types-virtio.h"
|
||||
|
||||
enum VhostUserProtocolFeature {
|
||||
VHOST_USER_PROTOCOL_F_MQ = 0,
|
||||
@@ -113,4 +114,7 @@ void vhost_user_async_close(DeviceState *d,
|
||||
CharFrontend *chardev, struct vhost_dev *vhost,
|
||||
vu_async_close_fn cb);
|
||||
|
||||
void vhost_user_qmp_status(struct vhost_dev *dev, VirtioStatus *status);
|
||||
bool vhost_user_has_protocol_feature(struct vhost_dev *dev, uint64_t feature);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -104,14 +104,6 @@ struct vhost_dev {
|
||||
VIRTIO_DECLARE_FEATURES(features);
|
||||
VIRTIO_DECLARE_FEATURES(acked_features);
|
||||
|
||||
/**
|
||||
* @protocol_features: is the vhost-user only feature set by
|
||||
* VHOST_USER_SET_PROTOCOL_FEATURES. Protocol features are only
|
||||
* negotiated if VHOST_USER_F_PROTOCOL_FEATURES has been offered
|
||||
* by the backend (see @features).
|
||||
*/
|
||||
uint64_t protocol_features;
|
||||
|
||||
uint64_t max_queues;
|
||||
uint64_t backend_cap;
|
||||
/* @started: is the vhost device started? */
|
||||
|
||||
Reference in New Issue
Block a user