mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
vhost-vsock: handle common features in vhost-vsock-common
virtio-vsock features, like VIRTIO_VSOCK_F_SEQPACKET, can be handled by vhost-vsock-common parent class. In this way, we can reuse the same code for all virtio-vsock backends (i.e. vhost-vsock, vhost-user-vsock). Let's move `seqpacket` property to vhost-vsock-common class, add vhost_vsock_common_get_features() used by children, and disable `seqpacket` for vhost-user-vsock device for machine types < 6.2. The behavior of vhost-vsock device doesn't change; vhost-user-vsock device now supports `seqpacket` property. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Message-Id: <20210921161642.206461-3-sgarzare@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
d6a9378f47
commit
46ce017167
6 changed files with 43 additions and 28 deletions
|
@ -18,6 +18,30 @@
|
|||
#include "qemu/iov.h"
|
||||
#include "monitor/monitor.h"
|
||||
|
||||
const int feature_bits[] = {
|
||||
VIRTIO_VSOCK_F_SEQPACKET,
|
||||
VHOST_INVALID_FEATURE_BIT
|
||||
};
|
||||
|
||||
uint64_t vhost_vsock_common_get_features(VirtIODevice *vdev, uint64_t features,
|
||||
Error **errp)
|
||||
{
|
||||
VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev);
|
||||
|
||||
if (vvc->seqpacket != ON_OFF_AUTO_OFF) {
|
||||
virtio_add_feature(&features, VIRTIO_VSOCK_F_SEQPACKET);
|
||||
}
|
||||
|
||||
features = vhost_get_features(&vvc->vhost_dev, feature_bits, features);
|
||||
|
||||
if (vvc->seqpacket == ON_OFF_AUTO_ON &&
|
||||
!virtio_has_feature(features, VIRTIO_VSOCK_F_SEQPACKET)) {
|
||||
error_setg(errp, "vhost-vsock backend doesn't support seqpacket");
|
||||
}
|
||||
|
||||
return features;
|
||||
}
|
||||
|
||||
int vhost_vsock_common_start(VirtIODevice *vdev)
|
||||
{
|
||||
VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev);
|
||||
|
@ -231,11 +255,18 @@ void vhost_vsock_common_unrealize(VirtIODevice *vdev)
|
|||
virtio_cleanup(vdev);
|
||||
}
|
||||
|
||||
static Property vhost_vsock_common_properties[] = {
|
||||
DEFINE_PROP_ON_OFF_AUTO("seqpacket", VHostVSockCommon, seqpacket,
|
||||
ON_OFF_AUTO_AUTO),
|
||||
DEFINE_PROP_END_OF_LIST(),
|
||||
};
|
||||
|
||||
static void vhost_vsock_common_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
|
||||
|
||||
device_class_set_props(dc, vhost_vsock_common_properties);
|
||||
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
|
||||
vdc->guest_notifier_mask = vhost_vsock_common_guest_notifier_mask;
|
||||
vdc->guest_notifier_pending = vhost_vsock_common_guest_notifier_pending;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue