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>
		
			
				
	
	
		
			53 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/*
 | 
						|
 * Parent class for vhost-vsock devices
 | 
						|
 *
 | 
						|
 * Copyright 2015-2020 Red Hat, Inc.
 | 
						|
 *
 | 
						|
 * This work is licensed under the terms of the GNU GPL, version 2 or
 | 
						|
 * (at your option) any later version.  See the COPYING file in the
 | 
						|
 * top-level directory.
 | 
						|
 */
 | 
						|
 | 
						|
#ifndef _QEMU_VHOST_VSOCK_COMMON_H
 | 
						|
#define _QEMU_VHOST_VSOCK_COMMON_H
 | 
						|
 | 
						|
#include "hw/virtio/virtio.h"
 | 
						|
#include "hw/virtio/vhost.h"
 | 
						|
#include "qom/object.h"
 | 
						|
 | 
						|
#define TYPE_VHOST_VSOCK_COMMON "vhost-vsock-common"
 | 
						|
OBJECT_DECLARE_SIMPLE_TYPE(VHostVSockCommon, VHOST_VSOCK_COMMON)
 | 
						|
 | 
						|
enum {
 | 
						|
    VHOST_VSOCK_SAVEVM_VERSION = 0,
 | 
						|
 | 
						|
    VHOST_VSOCK_QUEUE_SIZE = 128,
 | 
						|
};
 | 
						|
 | 
						|
struct VHostVSockCommon {
 | 
						|
    VirtIODevice parent;
 | 
						|
 | 
						|
    struct vhost_virtqueue vhost_vqs[2];
 | 
						|
    struct vhost_dev vhost_dev;
 | 
						|
 | 
						|
    VirtQueue *event_vq;
 | 
						|
    VirtQueue *recv_vq;
 | 
						|
    VirtQueue *trans_vq;
 | 
						|
 | 
						|
    QEMUTimer *post_load_timer;
 | 
						|
 | 
						|
    /* features */
 | 
						|
    OnOffAuto seqpacket;
 | 
						|
};
 | 
						|
 | 
						|
int vhost_vsock_common_start(VirtIODevice *vdev);
 | 
						|
void vhost_vsock_common_stop(VirtIODevice *vdev);
 | 
						|
int vhost_vsock_common_pre_save(void *opaque);
 | 
						|
int vhost_vsock_common_post_load(void *opaque, int version_id);
 | 
						|
void vhost_vsock_common_realize(VirtIODevice *vdev, const char *name);
 | 
						|
void vhost_vsock_common_unrealize(VirtIODevice *vdev);
 | 
						|
uint64_t vhost_vsock_common_get_features(VirtIODevice *vdev, uint64_t features,
 | 
						|
                                         Error **errp);
 | 
						|
 | 
						|
#endif /* _QEMU_VHOST_VSOCK_COMMON_H */
 |