[RFC v2] net/vhost-user.c : enforce link up

Vincent Jardin posted 1 patch 7 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20231015155147.25952-1-vincent.jardin@ekinops.com
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Jason Wang <jasowang@redhat.com>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>
net/vhost-user.c | 4 ++++
qapi/net.json    | 1 +
2 files changed, 5 insertions(+)
[RFC v2] net/vhost-user.c : enforce link up
Posted by Vincent Jardin 7 months ago
Do never set the link down when the vhost-user socket is disconnected.

XXX: currently, it cannot work. It is a reply commit to the former
one that was a RFC on virtio-net. Don't use it.
I do not understand how to get NetdevVhostUserOptions yet.

Signed-off-by: Vincent Jardin <vincent.jardin@ekinops.com>
---
 net/vhost-user.c | 4 ++++
 qapi/net.json    | 1 +
 2 files changed, 5 insertions(+)

diff --git a/net/vhost-user.c b/net/vhost-user.c
index 12555518e8..a30cce9a78 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -251,6 +251,7 @@ static void chr_closed_bh(void *opaque)
     NetVhostUserState *s;
     Error *err = NULL;
     int queues, i;
+    const NetdevVhostUserOptions *vhost_user_opts = NULL;
 
     queues = qemu_find_net_clients_except(name, ncs,
                                           NET_CLIENT_DRIVER_NIC,
@@ -263,6 +264,9 @@ static void chr_closed_bh(void *opaque)
         vhost_user_save_acked_features(ncs[i]);
     }
 
+    /* TODO how to get vhost_user_opts ? from the name ? or from ncs ? */
+
+    if (vhost_user_opts->has_linkup && !vhost_user_opts->linkup)
     qmp_set_link(name, false, &err);
 
     qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, net_vhost_user_event,
diff --git a/qapi/net.json b/qapi/net.json
index 8095b68fa8..c170f1b7b2 100644
--- a/qapi/net.json
+++ b/qapi/net.json
@@ -480,6 +480,7 @@
   'data': {
     'chardev':        'str',
     '*vhostforce':    'bool',
+    '*linkup':        'bool',
     '*queues':        'int' } }
 
 ##
-- 
2.34.1