From nobody Thu Apr 3 11:52:27 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1741629805; cv=none; d=zohomail.com; s=zohoarc; b=krnGX/ZIfQ0+xPnB/jwiW3z3IiLbnGKfwJZXOemV38l9E/TVd/q0ZHxboGuvKj42mY65y3g2hUZI6vHuSYChDrEqmeMZpDTteVpNZWb1x2zPT/kYsjVFAAym8I1n0EEZiEW7F9QZYSwKX1vQu6cQLGIC7XbfXyFdZjSVd/gDtkk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741629805; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+NZy2pbvXWaO3zQl4lVy+L3m8nqQQn+lkf1of1gSyyE=; b=GA2/xblxqvRkVqpGi2FuN34e2vzFkE6XTEjMLqjVHcmaD8QDKQ6qwK8jHnb4zXz1VwCRnQKudtucbyTVb39rOgTNCECiJSfzGdCTPt+PTTq2MupWuE0NuSmiduRFpmF9MSF2NMT5IBJbkHnzgbVuuTlhxRapkIvbVTim0ywpJNE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17416298048904.1321656983128605; Mon, 10 Mar 2025 11:03:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1trhSo-0006oJ-H9; Mon, 10 Mar 2025 14:02:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1trhSZ-0006kd-RB for qemu-devel@nongnu.org; Mon, 10 Mar 2025 14:02:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1trhSX-00005h-Tr for qemu-devel@nongnu.org; Mon, 10 Mar 2025 14:02:39 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-137-Nn3ykrbtMHSWySDuCBBwLQ-1; Mon, 10 Mar 2025 14:02:28 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1F24E1955BD2; Mon, 10 Mar 2025 18:02:27 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.45.224.138]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B194A1956094; Mon, 10 Mar 2025 18:02:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741629753; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=+NZy2pbvXWaO3zQl4lVy+L3m8nqQQn+lkf1of1gSyyE=; b=JRvAgLiecdbRQjTCIKyMMrptc28QVgOek1rgYVDzhSfQm5XV7CC8rsFshiuMoqNgqVnROH pxcuGAFag1v2XFUse4VDPr6+2MmSl8Qn6YwdgBtpn2b2aMLXYcf45cuqXjm0KCAHITql1O dGe3nI4140K+73pM2MaR9BpsEQIZQLk= X-MC-Unique: Nn3ykrbtMHSWySDuCBBwLQ-1 X-Mimecast-MFC-AGG-ID: Nn3ykrbtMHSWySDuCBBwLQ_1741629748 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Markus Armbruster , Stefano Brivio , David Gibson , Laurent Vivier Subject: [PATCH] docs: Explain how to use passt Date: Mon, 10 Mar 2025 19:00:50 +0100 Message-ID: <20250310180050.112682-1-lvivier@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=lvivier@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_OTHER_BAD_TLD=0.47, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1741629807388019000 Content-Type: text/plain; charset="utf-8" Add a chapter to explain how to use passt(1) instead of '-net user'. passt(1) can be connected to QEMU using UNIX socket or vhost-user. With vhost-user, migration of the VM is allowed and internal state of passt(1) is transfered from one side to the other Bug: https://gitlab.com/qemu-project/qemu/-/issues/2827 Signed-off-by: Laurent Vivier --- docs/system/devices/net.rst | 93 +++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/docs/system/devices/net.rst b/docs/system/devices/net.rst index 2ab516d4b097..5f70b1039198 100644 --- a/docs/system/devices/net.rst +++ b/docs/system/devices/net.rst @@ -77,6 +77,99 @@ When using the ``'-netdev user,hostfwd=3D...'`` option, = TCP or UDP connections can be redirected from the host to the guest. It allows for example to redirect X11, telnet or SSH connections. =20 +Using passt as the user mode network stack +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`passt(1)`_ can be used as a simple replacement for SLIRP (``-net user``). +`passt(1)`_ doesn't require any capability or privilege. `passt(1)`_ has +better performance than ``-net user``, full IPv6 support and better securi= ty +as it's a daemon that is not executed in QEMU context. + +`passt(1)`_ can be connected to QEMU either by using a socket +(``-netdev stream``) or using the vhost-user interface (``-netdev vhost-us= er``). +See `passt web site`_ and `passt(1)`_ for more details on passt. + +.. _passt web site: https://passt.top/ +.. _passt(1): https://passt.top/builds/latest/web/passt.1.html + +To use socket based passt interface: +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Start `passt(1)`_ as a daemon:: + + passt + +It will print the path of the UNIX domain socket QEMU can connect to. +Then you can connect your QEMU instance to `passt(1)`_: + +.. parsed-literal:: + |qemu_system| [...OPTIONS...] -device virtio-net-pci,netdev=3Dnetdev0 -= netdev stream,id=3Dnetdev0,server=3Doff,addr.type=3Dunix,addr.path=3D/tmp/p= asst_1.socket + +Where ``/tmp/passt_1.socket`` is the UNIX socket created by `passt(1)`_ to +communicate with QEMU. + +To use vhost-based interface: +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Start passt with ``--vhost-user``:: + + passt --vhost-user + +Then to connect QEMU: + +.. parsed-literal:: + |qemu_system| [...OPTIONS...] -m $RAMSIZE -chardev socket,id=3Dchr0,pat= h=3D/tmp/passt_1.socket -netdev vhost-user,id=3Dnetdev0,chardev=3Dchr0 -dev= ice virtio-net,netdev=3Dnetdev0 -object memory-backend-memfd,id=3Dmemfd0,sh= are=3Don,size=3D$RAMSIZE -numa node,memdev=3Dmemfd0 + +Where ``$RAMSIZE`` is the memory size of your VM ``-m`` and ``-object memo= ry-backend-memfd,size=3D`` must match. + +Migration of passt: +^^^^^^^^^^^^^^^^^^^ + +When `passt(1)`_ is connected to QEMU using the vhost-user interface it can +be migrated with QEMU and the network connections are not interrupted. + +As `passt(1)`_ runs with no privileges, it relies on passt-repair to save = and +load TCP connections state, using the TCP_REPAIR socket option. +The passt-repair helper needs to have the CAP_NET_ADMIN capability, or run= as root. If passt-repair is not available, TCP connections will not be pre= served. + +Example of migration of a guest on the same host +________________________________________________ + +Before being able to run passt-repair, the CAP_NET_ADMIN capability must b= e set +on the file, run as root:: + + setcat cap_net_admin+eip ./passt-repair + +Start `passt(1)`_ for the source side:: + + passt + +Start passt-repair:: + + passt-repair /tmp/passt_1.socket.repair + +Start source side QEMU with a monitor to be able to send the migrate comma= nd: + +.. parsed-literal:: + |qemu_system| [...OPTIONS...] [...VHOST USER OPTIONS...] -monitor stdio + +Start `passt(1)`_ for the destination side:: + + passt + +Start passt-repair:: + + passt-repair /tmp/passt_2.socket.repair + +Start QEMU with the ``-incoming`` parameter: + +.. parsed-literal:: + |qemu_system| [...OPTIONS...] [...VHOST USER OPTIONS...] -incoming tcp:= localhost:4444 + +Then in the source guest monitor the migration can be started:: + + (qemu) migrate tcp:localhost:4444 + Hubs ~~~~ =20 --=20 2.48.1