summary refs log tree commit diff stats
path: root/hw/net/vhost_net.c
diff options
context:
space:
mode:
authorLaurent Vivier <lvivier@redhat.com>2025-07-09 10:24:23 +0200
committerJason Wang <jasowang@redhat.com>2025-07-14 13:27:09 +0800
commitba5acc5d6e0bc9ab86619c92cb76493aa197d7a2 (patch)
tree76b6de340e1e03227643eee9ecd3a436883b6d05 /hw/net/vhost_net.c
parent33b78a30a3e8e1cf16ef423bf2e78caf3d560985 (diff)
downloadfocaccia-qemu-ba5acc5d6e0bc9ab86619c92cb76493aa197d7a2.tar.gz
focaccia-qemu-ba5acc5d6e0bc9ab86619c92cb76493aa197d7a2.zip
net: Add is_vhost_user flag to vhost_net struct
Introduce a boolean is_vhost_user field to the vhost_net
structure. This flag is initialized during vhost_net_init based
on whether the backend is vhost-user.

This refactoring simplifies checks for vhost-user specific behavior,
replacing direct comparisons of 'net->nc->info->type' with the new
flag. It improves readability and encapsulates the backend type
information directly within the vhost_net instance.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'hw/net/vhost_net.c')
-rw-r--r--hw/net/vhost_net.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 74d2e3ed90..540492b37d 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -246,6 +246,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
     net->feature_bits = options->feature_bits;
     net->save_acked_features = options->save_acked_features;
     net->max_tx_queue_size = options->max_tx_queue_size;
+    net->is_vhost_user = options->is_vhost_user;
 
     net->dev.max_queues = 1;
     net->dev.vqs = net->vqs;
@@ -440,7 +441,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
          * because vhost user doesn't interrupt masking/unmasking
          * properly.
          */
-        if (net->nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
+        if (net->is_vhost_user) {
             dev->use_guest_notifier_mask = false;
         }
      }