qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: qemu-devel@nongnu.org,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Stefan Weil" <sw@weilnetz.de>,
	"Stefano Garzarella" <sgarzare@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Dr. David Alan Gilbert" <dave@treblig.org>,
	"Eric Blake" <eblake@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [PATCH v2 09/10] net: Add passt network backend
Date: Tue, 1 Jul 2025 15:00:42 +0200	[thread overview]
Message-ID: <48ce7ba4-882e-4e6b-801a-135d489ae7f0@redhat.com> (raw)
In-Reply-To: <CACGkMEvcC7jv9LN5bP61E0OgSBENswotm+3fq8NAg3wBC9vUEQ@mail.gmail.com>

On 01/07/2025 03:46, Jason Wang wrote:
> On Wed, Jun 18, 2025 at 11:58 PM Laurent Vivier <lvivier@redhat.com> wrote:
>>
>> 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.
>>
>> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
>> ---
>>   hmp-commands.hx   |   3 +
>>   meson.build       |   6 +
>>   meson_options.txt |   2 +
>>   net/clients.h     |   4 +
>>   net/hub.c         |   3 +
>>   net/meson.build   |   3 +
>>   net/net.c         |   4 +
>>   net/passt.c       | 434 ++++++++++++++++++++++++++++++++++++++++++++++
>>   qapi/net.json     | 124 +++++++++++++
>>   qemu-options.hx   |  18 ++
>>   10 files changed, 601 insertions(+)
>>   create mode 100644 net/passt.c
>>
...
>> +static int net_passt_start_daemon(NetPasstState *s, int sock, Error **errp)
>> +{
>> +    g_autoptr(GSubprocess) daemon = NULL;
>> +    g_autofree gchar *contents = NULL;
>> +    g_autoptr(GError) error = NULL;
>> +    GSubprocessLauncher *launcher;
>> +
>> +    qemu_set_info_str(&s->data.nc, "launching passt");
>> +
>> +    launcher = g_subprocess_launcher_new(G_SUBPROCESS_FLAGS_NONE);
>> +    g_subprocess_launcher_take_fd(launcher, sock, 3);
>> +
>> +    daemon =  g_subprocess_launcher_spawnv(launcher,
>> +                                           (const gchar *const *)s->args->pdata,
>> +                                           &error);
> 
> I wonder if such launching is a must or at least we should allow
> accepting fd from the management layer (e.g in the case that execve()
> is restricted)?

In this case, the user should use the existing interface: externally start passt and use 
"-netdev vhost-user" or '-netdev stream'. It's already managed by libvirt. I think this is 
a case we shouldn't manage here.

>> +    g_object_unref(launcher);
>> +
>> +    if (!daemon) {
>> +        error_setg(errp, "Error creating daemon: %s", error->message);
>> +        return -1;
>> +    }
>> +
>> +    if (!g_subprocess_wait(daemon, NULL, &error)) {
>> +        error_setg(errp, "Error waiting for daemon: %s", error->message);
>> +        return -1;
>> +    }
>> +
>> +    if (g_subprocess_get_if_exited(daemon) &&
>> +        g_subprocess_get_exit_status(daemon)) {
>> +        return -1;
>> +    }
>> +
>> +    if (!g_file_get_contents(s->pidfile, &contents, NULL, &error)) {
>> +        error_setg(errp, "Cannot read passt pid: %s", error->message);
>> +        return -1;
>> +    }
>> +
>> +    s->pid = (pid_t)g_ascii_strtoll(contents, NULL, 10);
>> +    if (s->pid <= 0) {
>> +        error_setg(errp, "File '%s' did not contain a valid PID.", s->pidfile);
>> +        return -1;
>> +    }
>> +
>> +    return 0;
>> +}
>> +
> 
> ...
> 
>> +    if (net_passt_stream_start(s, errp) == -1) {
>> +        qemu_del_net_client(nc);
>> +        return -1;
>> +    }
>> +
>> +    return 0;
>> +}
>> diff --git a/qapi/net.json b/qapi/net.json
>> index 97ea1839813b..76d7654414f7 100644
>> --- a/qapi/net.json
>> +++ b/qapi/net.json
>> @@ -112,6 +112,125 @@
>>     'data': {
>>       'str': 'str' } }
>>
>> +##
>> +# @NetDevPasstOptions:
>> +#
>> +# Unprivileged user-mode network connectivity using passt
>> +#
>> +# @path: path to passt binary
>> +#
>> +# @quiet: don't print informational messages
>> +#
>> +# @debug: be verbose
>> +#
>> +# @trace: extra verbose
>> +#
>> +# @vhost-user: enable vhost-user
>> +#
>> +# @pcap-file: log traffic to pcap file
>> +#
>> +# @mtu: assign MTU via DHCP/NDP
>> +#
>> +# @address: IPv4 or IPv6 address
>> +#
>> +# @netmask: IPv4 mask
>> +#
>> +# @mac: source MAC address
>> +#
>> +# @gateway: IPv4 or IPv6 address as gateway
>> +#
>> +# @interface: interface for addresses and routes
>> +#
>> +# @outbound: bind to address as outbound source
>> +#
>> +# @outbound-if4: bind to outbound interface for IPv4
>> +#
>> +# @outbound-if6: bind to outbound interface for IPv6
>> +#
>> +# @dns: IPv4 or IPv6 address as DNS
>> +#
>> +# @search: search domains
>> +#
>> +# @fqdn: FQDN to configure client with
>> +#
>> +# @dhcp-dns: enable/disable DNS list in DHCP/DHCPv6/NDP
>> +#
>> +# @dhcp-search: enable/disable list in DHCP/DHCPv6/NDP
>> +#
>> +# @map-host-loopback: addresse to refer to host
>> +#
>> +# @map-guest-addr: addr to translate to guest's address
>> +#
>> +# @dns-forward: forward DNS queries sent to
>> +#
>> +# @dns-host: host nameserver to direct queries to
>> +#
>> +# @tcp: enable/disable TCP
>> +#
>> +# @udp: enable/disable UDP
>> +#
>> +# @icmp: enable/disable ICMP
>> +#
>> +# @dhcp: enable/disable DHCP
>> +#
>> +# @ndp: enable/disable NDP
>> +#
>> +# @dhcpv6: enable/disable DHCPv6
>> +#
>> +# @ra: enable/disable route advertisements
>> +#
>> +# @freebind: bind to any address for forwarding
>> +#
>> +# @ipv4: enable/disable IPv4
>> +#
>> +# @ipv6: enable/disable IPv6
>> +#
>> +# @tcp-ports: TCP ports to forward
>> +#
>> +# @udp-ports: UDP ports to forward
>> +#
>> +# Since: 10.1
>> +##
>> +{ 'struct': 'NetDevPasstOptions',
>> +  'data': {
>> +    '*path':               'str',
>> +    '*quiet':              'bool',
>> +    '*debug':              'bool',
>> +    '*trace':              'bool',
>> +    '*vhost-user':         'bool',
>> +    '*pcap-file':          'str',
>> +    '*mtu':                'int',
>> +    '*address':            'str',
>> +    '*netmask':            'str',
>> +    '*mac':                'str',
>> +    '*gateway':            'str',
>> +    '*interface':          'str',
>> +    '*outbound':           'str',
>> +    '*outbound-if4':       'str',
>> +    '*outbound-if6':       'str',
>> +    '*dns':                'str',
>> +    '*search':             ['String'],
>> +    '*fqdn':               'str',
>> +    '*dhcp-dns':           'bool',
>> +    '*dhcp-search':        'bool',
>> +    '*map-host-loopback':  'str',
>> +    '*map-guest-addr':     'str',
>> +    '*dns-forward':        'str',
>> +    '*dns-host':           'str',
>> +    '*tcp':                'bool',
>> +    '*udp':                'bool',
>> +    '*icmp':               'bool',
>> +    '*dhcp':               'bool',
>> +    '*ndp':                'bool',
>> +    '*dhcpv6':             'bool',
>> +    '*ra':                 'bool',
>> +    '*freebind':           'bool',
>> +    '*ipv4':               'bool',
>> +    '*ipv6':               'bool',
>> +    '*tcp-ports':          ['String'],
>> +    '*udp-ports':          ['String'] },
>> +    'if': 'CONFIG_PASST' }
> 
> I would like to know the plan to support migration and its
> compatibility for passt.

As I said, the goal of this series is to be able to use '-nic passt' as we can use '-nic 
user'. '-nic user' supports migration but TCP connections are lost.

With this series '-nic passt' supports migration but TCP connections are lost.

But we can improve '-nic passt' because we can migrate TCP connections too, for that we 
need to launch passt-repair and to use vhost-user, if we really want to do this it can be 
added (with a 'migration=on' parameter?)... but it's also already managed by '-netdev 
vhost-user' and passt started manually or by libvirt.

Thanks,
Laurent



  reply	other threads:[~2025-07-01 13:01 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-18 15:57 [PATCH v2 00/10] net: Add passt netdev backend Laurent Vivier
2025-06-18 15:57 ` [PATCH v2 01/10] net: Refactor stream logic for reuse in '-net passt' Laurent Vivier
2025-06-18 15:57 ` [PATCH v2 02/10] net: Define net_client_set_link() Laurent Vivier
2025-06-18 15:57 ` [PATCH v2 03/10] net: Introduce helper to identify vhost-user clients Laurent Vivier
2025-07-01  1:36   ` Jason Wang
2025-06-18 15:57 ` [PATCH v2 04/10] net: Add get_vhost_net callback to NetClientInfo Laurent Vivier
2025-06-18 15:57 ` [PATCH v2 05/10] net: Consolidate vhost feature bits into NetClientInfo Laurent Vivier
2025-07-01  1:39   ` Jason Wang
2025-06-18 15:57 ` [PATCH v2 06/10] net: Add get_acked_features callback to NetClientInfo Laurent Vivier
2025-06-18 15:57 ` [PATCH v2 07/10] net: Add save_acked_features " Laurent Vivier
2025-06-18 15:57 ` [PATCH v2 08/10] net: Allow network backends to advertise max TX queue size Laurent Vivier
2025-06-18 15:57 ` [PATCH v2 09/10] net: Add passt network backend Laurent Vivier
2025-06-24  8:16   ` Markus Armbruster
2025-06-24  8:37     ` Laurent Vivier
2025-06-24 11:55       ` Markus Armbruster
2025-06-24 12:03         ` Daniel P. Berrangé
2025-06-24 12:47           ` Laurent Vivier
2025-06-25  6:57             ` Markus Armbruster
2025-06-30 14:22               ` Stefano Brivio
2025-07-01  1:46   ` Jason Wang
2025-07-01 13:00     ` Laurent Vivier [this message]
2025-07-03 10:27       ` Stefano Brivio
2025-06-18 15:57 ` [PATCH v2 10/10] net/passt: Implement vhost-user backend support Laurent Vivier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48ce7ba4-882e-4e6b-801a-135d489ae7f0@redhat.com \
    --to=lvivier@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=dave@treblig.org \
    --cc=eblake@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sgarzare@redhat.com \
    --cc=sw@weilnetz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).