]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
vhost_net: add NetClientState->load() callback
authorEugenio Pérez <eperezma@redhat.com>
Tue, 23 Aug 2022 18:30:35 +0000 (20:30 +0200)
committerJason Wang <jasowang@redhat.com>
Fri, 2 Sep 2022 02:22:39 +0000 (10:22 +0800)
It allows per-net client operations right after device's successful
start. In particular, to load the device status.

Vhost-vdpa net will use it to add the CVQ buffers to restore the device
status.

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
hw/net/vhost_net.c
include/net/net.h

index 9d4b3344533ad58520a2da8ab5bdfad01f6691ab..d28f8b974bc5b8b798937795610237319f7d8c90 100644 (file)
@@ -281,6 +281,13 @@ static int vhost_net_start_one(struct vhost_net *net,
             }
         }
     }
+
+    if (net->nc->info->load) {
+        r = net->nc->info->load(net->nc);
+        if (r < 0) {
+            goto fail;
+        }
+    }
     return 0;
 fail:
     file.fd = -1;
index 476ad45b9ab6332f9bceae541adb4a3d3bac725d..81d0b21defce68e5997500208d7d1ed4acfaafc2 100644 (file)
@@ -45,6 +45,7 @@ typedef struct NICConf {
 typedef void (NetPoll)(NetClientState *, bool enable);
 typedef bool (NetCanReceive)(NetClientState *);
 typedef int (NetStart)(NetClientState *);
+typedef int (NetLoad)(NetClientState *);
 typedef void (NetStop)(NetClientState *);
 typedef ssize_t (NetReceive)(NetClientState *, const uint8_t *, size_t);
 typedef ssize_t (NetReceiveIOV)(NetClientState *, const struct iovec *, int);
@@ -74,6 +75,7 @@ typedef struct NetClientInfo {
     NetReceiveIOV *receive_iov;
     NetCanReceive *can_receive;
     NetStart *start;
+    NetLoad *load;
     NetStop *stop;
     NetCleanup *cleanup;
     LinkStatusChanged *link_status_changed;