From nobody Mon Feb 9 00:01:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1568386367; cv=none; d=zoho.com; s=zohoarc; b=gw9nouPkXFwe1a2hZ4cjEJVbJfpfaVoELUqSDGpWJwtp7K6pnHIcUoVFstUN7qpyoKTrDLjozUCty3s4rb2PlWIViY8HfjszSCMPnZp0kC/p+ntN7e3MJVZrC0elTWRxzu/I0BDizDnZyvUOht0gO/wgv1rOvvroqiptIsF4ol0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568386367; 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:ARC-Authentication-Results; bh=1YtP/RaJV4IE+7/a1Xszn7mR8u3y0FPAKPqHn4zbuTc=; b=WGh2FTrMmA1ti7ynZxqgh8TOoNIztO7CeiIQaZXY50TUkEF/PKL4NTcgcPSyPQxmPYrDP3CjX0sSOdrqfyMA576XNc77Gc7ZnbtAwJxpUfevTIdX65bFX2AIdP8wqMwj2K8P7y2z9n1t0ixOyG5pimy+ZHcUxX2hAaacDUBpJiU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568386367578992.5210685907149; Fri, 13 Sep 2019 07:52:47 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CC9043086218; Fri, 13 Sep 2019 14:52:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A66454502; Fri, 13 Sep 2019 14:52:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6529A24F33; Fri, 13 Sep 2019 14:52:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8DEqdoT003082 for ; Fri, 13 Sep 2019 10:52:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 782E65D9E1; Fri, 13 Sep 2019 14:52:39 +0000 (UTC) Received: from vhost2.laine.org (ovpn-118-98.phx2.redhat.com [10.3.118.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3872A5D9E5 for ; Fri, 13 Sep 2019 14:52:39 +0000 (UTC) From: Laine Stump To: libvir-list@redhat.com Date: Fri, 13 Sep 2019 10:52:30 -0400 Message-Id: <20190913145231.774-3-laine@redhat.com> In-Reply-To: <20190913145231.774-1-laine@redhat.com> References: <20190913145231.774-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/3] qemu: move runtime netdev validation into a separate function X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 13 Sep 2019 14:52:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The same validation should be done for both static network devices and hotplugged devices, but they are currently inconsistent. Move all the relevant validation from qemuBuildInterfaceCommandLine() into the new function qemuDomainValidateActualNetDef() and call the latter from the former. Signed-off-by: Laine Stump --- src/qemu/qemu_command.c | 52 +-------------------------- src/qemu/qemu_domain.c | 80 +++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 4 +++ 3 files changed, 85 insertions(+), 51 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f795f2e987..2acae3bf33 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8352,50 +8352,8 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr drive= r, if (!bootindex) bootindex =3D net->info.bootIndex; =20 - /* Currently nothing besides TAP devices supports multiqueue. */ - if (net->driver.virtio.queues > 0 && - !(actualType =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK || - actualType =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE || - actualType =3D=3D VIR_DOMAIN_NET_TYPE_DIRECT || - actualType =3D=3D VIR_DOMAIN_NET_TYPE_ETHERNET || - actualType =3D=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Multiqueue network is not supported for: %s"), - virDomainNetTypeToString(actualType)); + if (qemuDomainValidateActualNetDef(net, qemuCaps) < 0) return -1; - } - - /* and only TAP devices support nwfilter rules */ - if (net->filter) { - virNetDevVPortProfilePtr vport =3D virDomainNetGetActualVirtPortPr= ofile(net); - if (!(actualType =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK || - actualType =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE || - actualType =3D=3D VIR_DOMAIN_NET_TYPE_ETHERNET)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("filterref is not supported for " - "network interfaces of type %s"), - virDomainNetTypeToString(actualType)); - return -1; - } - if (vport && vport->virtPortType !=3D VIR_NETDEV_VPORT_PROFILE_NON= E) { - /* currently none of the defined virtualport types support ipt= ables */ - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("filterref is not supported for " - "network interfaces with virtualport type %s"= ), - virNetDevVPortTypeToString(vport->virtPortType)= ); - return -1; - } - } - - if (net->backend.tap && - !(actualType =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK || - actualType =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE || - actualType =3D=3D VIR_DOMAIN_NET_TYPE_ETHERNET)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Custom tap device path is not supported for: %s"= ), - virDomainNetTypeToString(actualType)); - return -1; - } =20 switch (actualType) { case VIR_DOMAIN_NET_TYPE_NETWORK: @@ -8458,14 +8416,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr drive= r, case VIR_DOMAIN_NET_TYPE_VHOSTUSER: requireNicdev =3D true; =20 - if (net->driver.virtio.queues > 1 && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VHOSTUSER_MULTIQUEUE)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("multi-queue is not supported for vhost-user " - "with this QEMU binary")); - goto cleanup; - } - if (qemuInterfaceVhostuserConnect(driver, logManager, secManager, cmd, def, net, qemuCaps, &charde= v) < 0) goto cleanup; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index bd247628cb..ebbe1a85db 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5300,6 +5300,86 @@ qemuDomainWatchdogDefValidate(const virDomainWatchdo= gDef *dev, } =20 =20 + +int +qemuDomainValidateActualNetDef(const virDomainNetDef *net, + virQEMUCapsPtr qemuCaps) +{ + /* + * Validations that can only be properly checked at runtime (after + * an has been resolved to its actual + * type. + * + * (In its current form this function can still be called before + * the actual type has been resolved (e.g. at domain definition + * time), but only if the validations would SUCCEED for + * type=3D'network'.) + */ + virDomainNetType actualType =3D virDomainNetGetActualType(net); + + /* Only tap/macvtap devices support multiqueue. */ + if (net->driver.virtio.queues > 1) { + + if (!(actualType =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK || + actualType =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE || + actualType =3D=3D VIR_DOMAIN_NET_TYPE_DIRECT || + actualType =3D=3D VIR_DOMAIN_NET_TYPE_ETHERNET || + actualType =3D=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("multiqueue network is not supported for: %s"= ), + virDomainNetTypeToString(actualType)); + return -1; + } + + if (actualType =3D=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER && + qemuCaps && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VHOSTUSER_MULT= IQUEUE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("multiqueue network is not supported for vhos= t-user " + "with this QEMU binary")); + return -1; + } + } + + /* + * Only standard tap devices support nwfilter rules, and even then only + * when *not* connected to an OVS bridge or midonet (indicated by havi= ng + * a element in the config) + */ + if (net->filter) { + virNetDevVPortProfilePtr vport =3D virDomainNetGetActualVirtPortPr= ofile(net); + if (!(actualType =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK || + actualType =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE || + actualType =3D=3D VIR_DOMAIN_NET_TYPE_ETHERNET)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("filterref is not supported for " + "network interfaces of type %s"), + virDomainNetTypeToString(actualType)); + return -1; + } + if (vport && vport->virtPortType !=3D VIR_NETDEV_VPORT_PROFILE_NON= E) { + /* currently none of the defined virtualport types support ipt= ables */ + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("filterref is not supported for " + "network interfaces with virtualport type %s"= ), + virNetDevVPortTypeToString(vport->virtPortType)= ); + return -1; + } + } + + if (net->backend.tap && + !(actualType =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK || + actualType =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE || + actualType =3D=3D VIR_DOMAIN_NET_TYPE_ETHERNET)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Custom tap device path is not supported for: %s"= ), + virDomainNetTypeToString(actualType)); + return -1; + } + + return 0; + } + + static int qemuDomainDeviceDefValidateNetwork(const virDomainNetDef *net) { diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 3e87e75c3a..f53ea146e1 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1215,3 +1215,7 @@ qemuDomainNVRAMPathGenerate(virQEMUDriverConfigPtr cf= g, =20 virDomainEventSuspendedDetailType qemuDomainPausedReasonToSuspendedEvent(virDomainPausedReason reason); + +int +qemuDomainValidateActualNetDef(const virDomainNetDef *net, + virQEMUCapsPtr qemuCaps); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list