From nobody Mon Feb 9 02:17:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196110; cv=none; d=zohomail.com; s=zohoarc; b=WHTGe/sM3jZSCmjQTSoQ4mdcUZ/WliyQMjh/nkgTj32cZ5fnBzboKSL80awPn8dfx7tM2E9dDgNhd7y1SlczQC80Xex7vNXhVBykoXD5lZMA+K1lVzdXF+ALA2UvG5xJ6NWDMQuZHp9wSMetEbjs++P9atEfUfxDKMcBXP/GOaA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196110; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pEKeZGdc0swyXSxLETMJwTlWAyf3GDYaHcDZKHpZsyQ=; b=d+LQWeW0Yl7MVr45bYOE5TT+WI2JmZ2LH07wnKz7+uOqqYuNJW3yYgybsCVh/exu1eHCux+xyFODIVqQ+QygQ3W8NZtmM15CMvxxAvdAU22YZt/9bRfzTjFiSzKWbGuZMi6uoTgI0bXjlYklpiKWnnx9gqr5S4m9BH0LxyAFSK0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 165219611087074.99133793658348; Tue, 10 May 2022 08:21:50 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-257-OC3Cv5u_MgG4ltm1icyC_A-1; Tue, 10 May 2022 11:21:47 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5ECF81D33860; Tue, 10 May 2022 15:21:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4753854B087; Tue, 10 May 2022 15:21:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0A40A1947055; Tue, 10 May 2022 15:21:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C541A194704D for ; Tue, 10 May 2022 15:21:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 999CA2024CBB; Tue, 10 May 2022 15:21:37 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B3AA20296AC for ; Tue, 10 May 2022 15:21:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196109; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=pEKeZGdc0swyXSxLETMJwTlWAyf3GDYaHcDZKHpZsyQ=; b=I68m2fo1OZgooghVQsh1tFOKIZ69olfCeQXml+gvJWBtWDTe1imJmntrOpd7O/yEiebMzE DcI/SaLAnF8Y7uN1YrAiAiwgZ4wvDOYit2r8QrwLcvVBRuOz2JOrhJB/+hoL8sdyNpRyzR 4pDbhAnTumnjuHsbb+s/zODFjgisWCw= X-MC-Unique: OC3Cv5u_MgG4ltm1icyC_A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 18/37] qemu: Prepare netdev code for use of qemuFDPass for tapfd/vhostfd passing Date: Tue, 10 May 2022 17:19:54 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196112377100001 Content-Type: text/plain; charset="utf-8" Add alternative code paths for passing of the FDs using the new infrastructure. This way we'll be able to refactor the code incrementally. Signed-off-by: Peter Krempa --- src/qemu/qemu_command.c | 45 ++++++++++++++++++++++++++++++++++++----- src/qemu/qemu_hotplug.c | 22 ++++++++++++++++++++ 2 files changed, 62 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c412bc50e0..fc8e209976 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4223,17 +4223,41 @@ qemuBuildHostNetProps(virDomainNetDef *net, const char *vhostfd_field =3D "S:vhostfd"; g_autofree char *vhostfd_arg =3D NULL; bool vhost =3D false; + size_t nfds; + GSList *n; + + if (netpriv->tapfds) { + nfds =3D 0; + for (n =3D netpriv->tapfds; n; n =3D n->next) { + virBufferAsprintf(&buf, "%s:", qemuFDPassGetPath(n->data)); + nfds++; + } - for (i =3D 0; i < tapfdSize; i++) - virBufferAsprintf(&buf, "%s:", tapfd[i]); + if (nfds > 1) + tapfd_field =3D "s:fds"; + } else { + for (i =3D 0; i < tapfdSize; i++) + virBufferAsprintf(&buf, "%s:", tapfd[i]); - if (tapfdSize > 1) - tapfd_field =3D "s:fds"; + if (tapfdSize > 1) + tapfd_field =3D "s:fds"; + } virBufferTrim(&buf, ":"); tapfd_arg =3D virBufferContentAndReset(&buf); - if (vhostfdSize > 0) { + if (netpriv->vhostfds) { + vhost =3D true; + + nfds =3D 0; + for (n =3D netpriv->vhostfds; n; n =3D n->next) { + virBufferAsprintf(&buf, "%s:", qemuFDPassGetPath(n->data)); + nfds++; + } + + if (nfds > 1) + vhostfd_field =3D "s:vhostfds"; + } else if (vhostfdSize > 0) { vhost =3D true; for (i =3D 0; i < vhostfdSize; i++) @@ -8722,6 +8746,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, size_t i; g_autoptr(virJSONValue) hostnetprops =3D NULL; qemuDomainNetworkPrivate *netpriv =3D QEMU_DOMAIN_NETWORK_PRIVATE(net); + GSList *n; if (qemuDomainValidateActualNetDef(net, qemuCaps) < 0) return -1; @@ -8930,6 +8955,16 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, vhostfd[i] =3D -1; } + for (n =3D netpriv->tapfds; n; n =3D n->next) { + if (qemuFDPassTransferCommand(n->data, cmd) < 0) + return -1; + } + + for (n =3D netpriv->vhostfds; n; n =3D n->next) { + if (qemuFDPassTransferCommand(n->data, cmd) < 0) + return -1; + } + if (qemuFDPassTransferCommand(netpriv->vdpafd, cmd) < 0) return -1; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 525c55baf2..28868cf3d0 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1210,6 +1210,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, g_autoptr(virConnect) conn =3D NULL; virErrorPtr save_err =3D NULL; bool teardownlabel =3D false; + GSList *n; /* If appropriate, grab a physical device from the configured * network's pool of devices, or resolve bridge device name @@ -1460,6 +1461,20 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); + for (n =3D netpriv->tapfds; n; n =3D n->next) { + if (qemuFDPassTransferMonitor(n->data, priv->mon) < 0) { + qemuDomainObjExitMonitor(vm); + goto cleanup; + } + } + + for (n =3D netpriv->vhostfds; n; n =3D n->next) { + if (qemuFDPassTransferMonitor(n->data, priv->mon) < 0) { + qemuDomainObjExitMonitor(vm); + goto cleanup; + } + } + if (qemuFDPassTransferMonitor(netpriv->vdpafd, priv->mon) < 0) { qemuDomainObjExitMonitor(vm); goto cleanup; @@ -1619,6 +1634,13 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, qemuMonitorRemoveNetdev(priv->mon, netdev_name) < 0) VIR_WARN("Failed to remove network backend for netdev %s", netdev_name); + + for (n =3D netpriv->tapfds; n; n =3D n->next) + qemuFDPassTransferMonitorRollback(n->data, priv->mon); + + for (n =3D netpriv->vhostfds; n; n =3D n->next) + qemuFDPassTransferMonitorRollback(n->data, priv->mon); + qemuDomainObjExitMonitor(vm); virErrorRestore(&originalError); goto cleanup; --=20 2.35.1