mirror of
https://github.com/qemu/qemu.git
synced 2026-02-04 02:24:38 +00:00
net: Add save_acked_features callback to vhost_net
This commit introduces a save_acked_features function pointer to vhost_net and converts the vhost_net function into a generic dispatcher. The vhost-user backend provides the callback, making its function static. With this change, no other module has a direct dependency on the vhost-user implementation. This cleanup allows for the complete removal of the net/vhost-user.h header file. Signed-off-by: Laurent Vivier <lvivier@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
committed by
Jason Wang
parent
bd38794a11
commit
1652f1b335
@@ -13,7 +13,6 @@
|
|||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "net/net.h"
|
#include "net/net.h"
|
||||||
#include "net/tap.h"
|
#include "net/tap.h"
|
||||||
#include "net/vhost-user.h"
|
|
||||||
|
|
||||||
#include "hw/virtio/virtio-net.h"
|
#include "hw/virtio/virtio-net.h"
|
||||||
#include "net/vhost_net.h"
|
#include "net/vhost_net.h"
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "net/net.h"
|
#include "net/net.h"
|
||||||
#include "net/tap.h"
|
#include "net/tap.h"
|
||||||
#include "net/vhost-user.h"
|
|
||||||
#include "net/vhost-vdpa.h"
|
#include "net/vhost-vdpa.h"
|
||||||
|
|
||||||
#include "standard-headers/linux/vhost_types.h"
|
#include "standard-headers/linux/vhost_types.h"
|
||||||
@@ -70,11 +69,11 @@ uint64_t vhost_net_get_acked_features(VHostNetState *net)
|
|||||||
|
|
||||||
void vhost_net_save_acked_features(NetClientState *nc)
|
void vhost_net_save_acked_features(NetClientState *nc)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_VHOST_NET_USER
|
struct vhost_net *net = get_vhost_net(nc);
|
||||||
if (nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
|
|
||||||
vhost_user_save_acked_features(nc);
|
if (net && net->save_acked_features) {
|
||||||
|
net->save_acked_features(nc);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vhost_net_disable_notifiers_nvhosts(VirtIODevice *dev,
|
static void vhost_net_disable_notifiers_nvhosts(VirtIODevice *dev,
|
||||||
@@ -245,6 +244,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
|
|||||||
net->nc = options->net_backend;
|
net->nc = options->net_backend;
|
||||||
net->dev.nvqs = options->nvqs;
|
net->dev.nvqs = options->nvqs;
|
||||||
net->feature_bits = options->feature_bits;
|
net->feature_bits = options->feature_bits;
|
||||||
|
net->save_acked_features = options->save_acked_features;
|
||||||
|
|
||||||
net->dev.max_queues = 1;
|
net->dev.max_queues = 1;
|
||||||
net->dev.vqs = net->vqs;
|
net->dev.vqs = net->vqs;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef VHOST_H
|
#ifndef VHOST_H
|
||||||
#define VHOST_H
|
#define VHOST_H
|
||||||
|
|
||||||
|
#include "net/vhost_net.h"
|
||||||
#include "hw/virtio/vhost-backend.h"
|
#include "hw/virtio/vhost-backend.h"
|
||||||
#include "hw/virtio/virtio.h"
|
#include "hw/virtio/virtio.h"
|
||||||
#include "system/memory.h"
|
#include "system/memory.h"
|
||||||
@@ -144,6 +145,7 @@ struct vhost_net {
|
|||||||
struct vhost_virtqueue vqs[2];
|
struct vhost_virtqueue vqs[2];
|
||||||
int backend;
|
int backend;
|
||||||
const int *feature_bits;
|
const int *feature_bits;
|
||||||
|
SaveAcketFeatures *save_acked_features;
|
||||||
NetClientState *nc;
|
NetClientState *nc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
/*
|
|
||||||
* vhost-user.h
|
|
||||||
*
|
|
||||||
* Copyright (c) 2013 Virtual Open Systems Sarl.
|
|
||||||
*
|
|
||||||
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
||||||
* See the COPYING file in the top-level directory.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef VHOST_USER_H
|
|
||||||
#define VHOST_USER_H
|
|
||||||
|
|
||||||
void vhost_user_save_acked_features(NetClientState *nc);
|
|
||||||
|
|
||||||
#endif /* VHOST_USER_H */
|
|
||||||
@@ -8,6 +8,7 @@ struct vhost_net;
|
|||||||
typedef struct vhost_net VHostNetState;
|
typedef struct vhost_net VHostNetState;
|
||||||
|
|
||||||
typedef uint64_t (GetAckedFeatures)(NetClientState *nc);
|
typedef uint64_t (GetAckedFeatures)(NetClientState *nc);
|
||||||
|
typedef void (SaveAcketFeatures)(NetClientState *nc);
|
||||||
|
|
||||||
typedef struct VhostNetOptions {
|
typedef struct VhostNetOptions {
|
||||||
VhostBackendType backend_type;
|
VhostBackendType backend_type;
|
||||||
@@ -16,6 +17,7 @@ typedef struct VhostNetOptions {
|
|||||||
unsigned int nvqs;
|
unsigned int nvqs;
|
||||||
const int *feature_bits;
|
const int *feature_bits;
|
||||||
GetAckedFeatures *get_acked_features;
|
GetAckedFeatures *get_acked_features;
|
||||||
|
SaveAcketFeatures *save_acked_features;
|
||||||
void *opaque;
|
void *opaque;
|
||||||
} VhostNetOptions;
|
} VhostNetOptions;
|
||||||
|
|
||||||
|
|||||||
@@ -745,6 +745,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
|
|||||||
options.nvqs = 2;
|
options.nvqs = 2;
|
||||||
options.feature_bits = kernel_feature_bits;
|
options.feature_bits = kernel_feature_bits;
|
||||||
options.get_acked_features = NULL;
|
options.get_acked_features = NULL;
|
||||||
|
options.save_acked_features = NULL;
|
||||||
|
|
||||||
s->vhost_net = vhost_net_init(&options);
|
s->vhost_net = vhost_net_init(&options);
|
||||||
if (!s->vhost_net) {
|
if (!s->vhost_net) {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "clients.h"
|
#include "clients.h"
|
||||||
#include "net/vhost_net.h"
|
#include "net/vhost_net.h"
|
||||||
#include "net/vhost-user.h"
|
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "clients.h"
|
#include "clients.h"
|
||||||
#include "net/vhost_net.h"
|
#include "net/vhost_net.h"
|
||||||
#include "net/vhost-user.h"
|
|
||||||
#include "hw/virtio/vhost.h"
|
#include "hw/virtio/vhost.h"
|
||||||
#include "hw/virtio/vhost-user.h"
|
#include "hw/virtio/vhost-user.h"
|
||||||
#include "standard-headers/linux/virtio_net.h"
|
#include "standard-headers/linux/virtio_net.h"
|
||||||
@@ -88,7 +87,7 @@ static uint64_t vhost_user_get_acked_features(NetClientState *nc)
|
|||||||
return s->acked_features;
|
return s->acked_features;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vhost_user_save_acked_features(NetClientState *nc)
|
static void vhost_user_save_acked_features(NetClientState *nc)
|
||||||
{
|
{
|
||||||
NetVhostUserState *s;
|
NetVhostUserState *s;
|
||||||
|
|
||||||
@@ -140,6 +139,7 @@ static int vhost_user_start(int queues, NetClientState *ncs[],
|
|||||||
options.nvqs = 2;
|
options.nvqs = 2;
|
||||||
options.feature_bits = user_feature_bits;
|
options.feature_bits = user_feature_bits;
|
||||||
options.get_acked_features = vhost_user_get_acked_features;
|
options.get_acked_features = vhost_user_get_acked_features;
|
||||||
|
options.save_acked_features = vhost_user_save_acked_features;
|
||||||
|
|
||||||
net = vhost_net_init(&options);
|
net = vhost_net_init(&options);
|
||||||
if (!net) {
|
if (!net) {
|
||||||
|
|||||||
@@ -203,6 +203,7 @@ static int vhost_vdpa_add(NetClientState *ncs, void *be,
|
|||||||
options.nvqs = nvqs;
|
options.nvqs = nvqs;
|
||||||
options.feature_bits = vdpa_feature_bits;
|
options.feature_bits = vdpa_feature_bits;
|
||||||
options.get_acked_features = NULL;
|
options.get_acked_features = NULL;
|
||||||
|
options.save_acked_features = NULL;
|
||||||
|
|
||||||
net = vhost_net_init(&options);
|
net = vhost_net_init(&options);
|
||||||
if (!net) {
|
if (!net) {
|
||||||
|
|||||||
Reference in New Issue
Block a user