This patch completes the series of refactorings aimed at decoupling the
generic vhost layer from specific network backends.
The final remaining dependency was in vhost_net_save_acked_features,
which contained a hardcoded check for the vhost-user client type.
This commit applies the now-established callback pattern, introducing a
save_acked_features function pointer to NetClientInfo and
converting 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>
---
hw/net/vhost_net-stub.c | 1 -
hw/net/vhost_net.c | 7 ++-----
include/net/net.h | 2 ++
include/net/vhost-user.h | 16 ----------------
net/vhost-user-stub.c | 1 -
net/vhost-user.c | 4 ++--
6 files changed, 6 insertions(+), 25 deletions(-)
delete mode 100644 include/net/vhost-user.h
diff --git a/hw/net/vhost_net-stub.c b/hw/net/vhost_net-stub.c
index 72df6d757e4d..dab9943172da 100644
--- a/hw/net/vhost_net-stub.c
+++ b/hw/net/vhost_net-stub.c
@@ -13,7 +13,6 @@
#include "qemu/osdep.h"
#include "net/net.h"
#include "net/tap.h"
-#include "net/vhost-user.h"
#include "hw/virtio/virtio-net.h"
#include "net/vhost_net.h"
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 4ed28a6d4186..756af26db207 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -16,7 +16,6 @@
#include "qemu/osdep.h"
#include "net/net.h"
#include "net/tap.h"
-#include "net/vhost-user.h"
#include "net/vhost-vdpa.h"
#include "standard-headers/linux/vhost_types.h"
@@ -152,11 +151,9 @@ uint64_t vhost_net_get_acked_features(VHostNetState *net)
void vhost_net_save_acked_features(NetClientState *nc)
{
-#ifdef CONFIG_VHOST_NET_USER
- if (nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
- vhost_user_save_acked_features(nc);
+ if (nc->info->save_acked_features) {
+ nc->info->save_acked_features(nc);
}
-#endif
}
static void vhost_net_disable_notifiers_nvhosts(VirtIODevice *dev,
diff --git a/include/net/net.h b/include/net/net.h
index ed9febd378b6..5ef86cd6c384 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -70,6 +70,7 @@ typedef bool (NetCheckPeerType)(NetClientState *, ObjectClass *, Error **);
typedef bool (IsVHostUser)(NetClientState *);
typedef struct vhost_net *(GetVHostNet)(NetClientState *nc);
typedef uint64_t (GetAckedFeatures)(NetClientState *nc);
+typedef void (SaveAcketFeatures)(NetClientState *nc);
typedef struct NetClientInfo {
NetClientDriver type;
@@ -98,6 +99,7 @@ typedef struct NetClientInfo {
IsVHostUser *is_vhost_user;
GetVHostNet *get_vhost_net;
GetAckedFeatures *get_acked_features;
+ SaveAcketFeatures *save_acked_features;
} NetClientInfo;
struct NetClientState {
diff --git a/include/net/vhost-user.h b/include/net/vhost-user.h
deleted file mode 100644
index a4d0ce4b8dd1..000000000000
--- a/include/net/vhost-user.h
+++ /dev/null
@@ -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 */
diff --git a/net/vhost-user-stub.c b/net/vhost-user-stub.c
index 52ab4e13f12a..283dee87db2d 100644
--- a/net/vhost-user-stub.c
+++ b/net/vhost-user-stub.c
@@ -11,7 +11,6 @@
#include "qemu/osdep.h"
#include "clients.h"
#include "net/vhost_net.h"
-#include "net/vhost-user.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
diff --git a/net/vhost-user.c b/net/vhost-user.c
index 45c952b1e76d..5b9f08163fc5 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -11,7 +11,6 @@
#include "qemu/osdep.h"
#include "clients.h"
#include "net/vhost_net.h"
-#include "net/vhost-user.h"
#include "hw/virtio/vhost-user.h"
#include "chardev/char-fe.h"
#include "qapi/error.h"
@@ -46,7 +45,7 @@ static uint64_t vhost_user_get_acked_features(NetClientState *nc)
return s->acked_features;
}
-void vhost_user_save_acked_features(NetClientState *nc)
+static void vhost_user_save_acked_features(NetClientState *nc)
{
NetVhostUserState *s;
@@ -241,6 +240,7 @@ static NetClientInfo net_vhost_user_info = {
.is_vhost_user = vhost_user_is_vhost_user,
.get_vhost_net = vhost_user_get_vhost_net,
.get_acked_features = vhost_user_get_acked_features,
+ .save_acked_features = vhost_user_save_acked_features,
};
static gboolean net_vhost_user_watch(void *do_not_use, GIOCondition cond,
--
2.49.0