summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorHyman Huang(黄勇) <huangy81@chinatelecom.cn>2022-12-21 21:06:38 +0800
committerMichael S. Tsirkin <mst@redhat.com>2023-01-08 01:54:22 -0500
commit937b7d96e43943b808f0ca51fddf5c263209c535 (patch)
tree14e9dde55473a8838dd557c547727f931f3f983d /net
parent5795702a850ae858662fafa105dc9fa87466b5f7 (diff)
downloadqemu-937b7d96e43943b808f0ca51fddf5c263209c535.tar.gz
vhost-user: Refactor vhost acked features saving
Abstract vhost acked features saving into vhost_user_save_acked_features, export it as util function. Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn> Signed-off-by: Guoyi Tu <tugy@chinatelecom.cn> Message-Id: <50dc9b09b0635e3052551efcc1046c2a85332fcb.1671627406.git.huangy81@chinatelecom.cn> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'net')
-rw-r--r--net/vhost-user.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/net/vhost-user.c b/net/vhost-user.c
index 3a6b90da86..f5cb095d5c 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -45,10 +45,23 @@ uint64_t vhost_user_get_acked_features(NetClientState *nc)
return s->acked_features;
}
-static void vhost_user_stop(int queues, NetClientState *ncs[])
+void vhost_user_save_acked_features(NetClientState *nc)
{
NetVhostUserState *s;
+
+ s = DO_UPCAST(NetVhostUserState, nc, nc);
+ if (s->vhost_net) {
+ uint64_t features = vhost_net_get_acked_features(s->vhost_net);
+ if (features) {
+ s->acked_features = features;
+ }
+ }
+}
+
+static void vhost_user_stop(int queues, NetClientState *ncs[])
+{
int i;
+ NetVhostUserState *s;
for (i = 0; i < queues; i++) {
assert(ncs[i]->info->type == NET_CLIENT_DRIVER_VHOST_USER);
@@ -56,11 +69,7 @@ static void vhost_user_stop(int queues, NetClientState *ncs[])
s = DO_UPCAST(NetVhostUserState, nc, ncs[i]);
if (s->vhost_net) {
- /* save acked features */
- uint64_t features = vhost_net_get_acked_features(s->vhost_net);
- if (features) {
- s->acked_features = features;
- }
+ vhost_user_save_acked_features(ncs[i]);
vhost_net_cleanup(s->vhost_net);
}
}