138 lines
4.2 KiB
Diff
138 lines
4.2 KiB
Diff
From 5285f9d3377d8d8c1872c1f75a6583e42c97686e Mon Sep 17 00:00:00 2001
|
|
From: Laurent Vivier <lvivier@redhat.com>
|
|
Date: Mon, 17 Feb 2025 10:25:50 +0100
|
|
Subject: [PATCH 1/2] net: vhost-user: add QAPI events to report connection
|
|
state
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
RH-Author: Laurent Vivier <lvivier@redhat.com>
|
|
RH-MergeRequest: 432: net: vhost-user: add QAPI events to report connection state
|
|
RH-Jira: RHEL-80622
|
|
RH-Acked-by: Cindy Lu <lulu@redhat.com>
|
|
RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
|
|
RH-Acked-by: Jason Wang <jasowang@redhat.com>
|
|
RH-Commit: [1/1] f8459679e558339d4fa45ed88ed71dc5d5ef459d
|
|
|
|
JIRA: https://issues.redhat.com/browse/RHEL-80622
|
|
|
|
The netdev reports NETDEV_VHOST_USER_CONNECTED event when
|
|
the chardev is connected, and NETDEV_VHOST_USER_DISCONNECTED
|
|
when it is disconnected.
|
|
|
|
The NETDEV_VHOST_USER_CONNECTED event includes the chardev id.
|
|
|
|
This allows a system manager like libvirt to detect when the server
|
|
fails.
|
|
|
|
For instance with passt:
|
|
|
|
{ 'execute': 'qmp_capabilities' }
|
|
{ "return": { } }
|
|
|
|
[killing passt here]
|
|
|
|
{ "timestamp": { "seconds": 1739538634, "microseconds": 920450 },
|
|
"event": "NETDEV_VHOST_USER_DISCONNECTED",
|
|
"data": { "netdev-id": "netdev0" } }
|
|
|
|
[automatic reconnection with reconnect-ms]
|
|
|
|
{ "timestamp": { "seconds": 1739538638, "microseconds": 354181 },
|
|
"event": "NETDEV_VHOST_USER_CONNECTED",
|
|
"data": { "netdev-id": "netdev0", "chardev-id": "chr0" } }
|
|
|
|
Tested-by: Stefano Brivio <sbrivio@redhat.com>
|
|
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
|
|
Message-Id: <20250217092550.1172055-1-lvivier@redhat.com>
|
|
Acked-by: Markus Armbruster <armbru@redhat.com>
|
|
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
(cherry picked from commit 02fd9f8aeeb184276b283ae2f404bc3acf1e7b7a)
|
|
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
|
|
---
|
|
net/vhost-user.c | 3 +++
|
|
qapi/net.json | 40 ++++++++++++++++++++++++++++++++++++++++
|
|
2 files changed, 43 insertions(+)
|
|
|
|
diff --git a/net/vhost-user.c b/net/vhost-user.c
|
|
index 12555518e8..0b235e50c6 100644
|
|
--- a/net/vhost-user.c
|
|
+++ b/net/vhost-user.c
|
|
@@ -16,6 +16,7 @@
|
|
#include "chardev/char-fe.h"
|
|
#include "qapi/error.h"
|
|
#include "qapi/qapi-commands-net.h"
|
|
+#include "qapi/qapi-events-net.h"
|
|
#include "qemu/config-file.h"
|
|
#include "qemu/error-report.h"
|
|
#include "qemu/option.h"
|
|
@@ -271,6 +272,7 @@ static void chr_closed_bh(void *opaque)
|
|
if (err) {
|
|
error_report_err(err);
|
|
}
|
|
+ qapi_event_send_netdev_vhost_user_disconnected(name);
|
|
}
|
|
|
|
static void net_vhost_user_event(void *opaque, QEMUChrEvent event)
|
|
@@ -300,6 +302,7 @@ static void net_vhost_user_event(void *opaque, QEMUChrEvent event)
|
|
net_vhost_user_watch, s);
|
|
qmp_set_link(name, true, &err);
|
|
s->started = true;
|
|
+ qapi_event_send_netdev_vhost_user_connected(name, chr->label);
|
|
break;
|
|
case CHR_EVENT_CLOSED:
|
|
/* a close event may happen during a read/write, but vhost
|
|
diff --git a/qapi/net.json b/qapi/net.json
|
|
index 87fc0d0b28..7bd1eaa1ba 100644
|
|
--- a/qapi/net.json
|
|
+++ b/qapi/net.json
|
|
@@ -1020,3 +1020,43 @@
|
|
##
|
|
{ 'event': 'NETDEV_STREAM_DISCONNECTED',
|
|
'data': { 'netdev-id': 'str' } }
|
|
+
|
|
+##
|
|
+# @NETDEV_VHOST_USER_CONNECTED:
|
|
+#
|
|
+# Emitted when the vhost-user chardev is connected
|
|
+#
|
|
+# @netdev-id: QEMU netdev id that is connected
|
|
+#
|
|
+# @chardev-id: The character device id used by the QEMU netdev
|
|
+#
|
|
+# Since: 10.0
|
|
+#
|
|
+# .. qmp-example::
|
|
+#
|
|
+# <- { "timestamp": {"seconds": 1739538638, "microseconds": 354181 },
|
|
+# "event": "NETDEV_VHOST_USER_CONNECTED",
|
|
+# "data": { "netdev-id": "netdev0", "chardev-id": "chr0" } }
|
|
+#
|
|
+##
|
|
+{ 'event': 'NETDEV_VHOST_USER_CONNECTED',
|
|
+ 'data': { 'netdev-id': 'str', 'chardev-id': 'str' } }
|
|
+
|
|
+##
|
|
+# @NETDEV_VHOST_USER_DISCONNECTED:
|
|
+#
|
|
+# Emitted when the vhost-user chardev is disconnected
|
|
+#
|
|
+# @netdev-id: QEMU netdev id that is disconnected
|
|
+#
|
|
+# Since: 10.0
|
|
+#
|
|
+# .. qmp-example::
|
|
+#
|
|
+# <- { "timestamp": { "seconds": 1739538634, "microseconds": 920450 },
|
|
+# "event": "NETDEV_VHOST_USER_DISCONNECTED",
|
|
+# "data": { "netdev-id": "netdev0" } }
|
|
+#
|
|
+##
|
|
+{ 'event': 'NETDEV_VHOST_USER_DISCONNECTED',
|
|
+ 'data': { 'netdev-id': 'str' } }
|
|
--
|
|
2.48.1
|
|
|