On Fri, 14 Feb 2025 08:26:25 +0100
Laurent Vivier <[email protected]> wrote:
> 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 ChardevInfo
> (label, filename and frontend_open).
>
> 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": 1739517243, "microseconds": 115081 },
> "event": "NETDEV_VHOST_USER_DISCONNECTED",
> "data": { "netdev-id": "netdev0" } }
>
> [automatic reconnection with reconnect-ms]
>
> { "timestamp": { "seconds": 1739517290, "microseconds": 343777 },
> "event": "NETDEV_VHOST_USER_CONNECTED",
> "data": { "netdev-id": "netdev0",
> "info": { "frontend-open": true,
> "filename": "unix:",
> "label": "chr0" } } }
>
> Signed-off-by: Laurent Vivier <[email protected]>
Tested-by: Stefano Brivio <[email protected]>
...with libvirt's branch from:
https://gitlab.com/lainestump/libvirt/-/tree/network-passt+vhostuser
simply wiring NETDEV_VHOST_USER_DISCONNECTED to the event handler
qemuMonitorJSONHandleNetdevStreamDisconnected(), that is, the handler
for NETDEV_STREAM_DISCONNECTED. I terminate passt, and it restarts.
--
Stefano