On Tue, 15 Jul 2025 at 05:42, Jason Wang <jasow...@redhat.com> wrote:
>
> From: Laurent Vivier <lviv...@redhat.com>
>
> This commit introduces support for passt as a new network backend.
> passt is an unprivileged, user-mode networking solution that provides
> connectivity for virtual machines by launching an external helper process.
>
> The implementation reuses the generic stream data handling logic. It
> launches the passt binary using GSubprocess, passing it a file
> descriptor from a socketpair() for communication. QEMU connects to
> the other end of the socket pair to establish the network data stream.
>
> The PID of the passt daemon is tracked via a temporary file to
> ensure it is terminated when QEMU exits.

Hi; Coverity points out some potential issues with this code:

> +static void net_passt_cleanup(NetClientState *nc)
> +{
> +    NetPasstState *s = DO_UPCAST(NetPasstState, data.nc, nc);
> +
> +    kill(s->pid, SIGTERM);

CID 1612369: we don't check the return value from kill().

> +    g_remove(s->pidfile);
> +    g_free(s->pidfile);
> +    g_ptr_array_free(s->args, TRUE);
> +}
> +
> +static ssize_t net_passt_receive(NetClientState *nc, const uint8_t *buf,
> +                                  size_t size)
> +{
> +    NetStreamData *d = DO_UPCAST(NetStreamData, nc, nc);
> +
> +    return net_stream_data_receive(d, buf, size);
> +}
> +
> +static gboolean net_passt_send(QIOChannel *ioc, GIOCondition condition,
> +                                gpointer data)
> +{
> +    if (net_stream_data_send(ioc, condition, data) == G_SOURCE_REMOVE) {
> +        NetPasstState *s = DO_UPCAST(NetPasstState, data, data);
> +        Error *error;

CID 1612368: you forgot to initialize error to NULL.

> +
> +        /* we need to restart passt */
> +        kill(s->pid, SIGTERM);

Another kill() without checking for failure.

> +        if (net_passt_stream_start(s, &error) == -1) {
> +            error_report_err(error);
> +        }
> +
> +        return G_SOURCE_REMOVE;
> +    }
> +
> +    return G_SOURCE_CONTINUE;
> +}

thanks
-- PMM

Reply via email to