From nobody Sun Feb 8 23:26:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1663577826; cv=none; d=zohomail.com; s=zohoarc; b=awN1aeSW2zhjE9Pc37r8J/YERqWemXgDuNfimgZKMFyJYsHfIfczLVwyqx9R+xTX/bPzAE9Q/AVWG3/96D49n2nz7KY0O1FEonwKhZKZLG0i+o7BhBco+2bUKnU7gH79U9wxMBxtpXB3QoS2mdFiRl/HeHI0jX1ROypmfrc1qSg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577826; 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=/n7Rdj8v+hi8QQGVZwQ5cMtNFCBWbEfkG9Ggn01BOTk=; b=neRB50M0hq/HrlF5lAFV+YFaOqNAcVUmi/DEDWsGshyKehdk9wkB8ETZarbCeZKqcYOXit1ZCzaKE56hgSJNadnB/QYDIM6pL2p/EIQTsOITIcS0nOrU3KG993a8SUXW0U240zN92pfNu0Vd8aELSrkplAfKWbtcXRysa2sTiSs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1663577826537751.916822500287; Mon, 19 Sep 2022 01:57:06 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-601-kGa-J_H8OWCGbO6-uAb4xQ-1; Mon, 19 Sep 2022 04:55:55 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9DFFE882838; Mon, 19 Sep 2022 08:55:52 +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 7C90B140EBF3; Mon, 19 Sep 2022 08:55:52 +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 4316419465B6; Mon, 19 Sep 2022 08:55:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 879A51946586 for ; Mon, 19 Sep 2022 08:55:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7CEC940C6EC2; Mon, 19 Sep 2022 08:55:51 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED34940C6EC4 for ; Mon, 19 Sep 2022 08:55:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577825; 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=/n7Rdj8v+hi8QQGVZwQ5cMtNFCBWbEfkG9Ggn01BOTk=; b=CsBwQcP2RwjIOcY9mXFeNGg6xnitbRUrbmJEIktPMUs6C6Eu9eOHTltEYlMi7km+x3dBjr bH+osC7OwSAfszgUauKkjwuBKuTmC1Seh6XV/m+Pj7dsASZx03tB5Bk8OYoleN0PNEKfKK T8GRg3TdgZvDVbFDmTxxevbjoGEktzo= X-MC-Unique: kGa-J_H8OWCGbO6-uAb4xQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 30/37] conf: domain: Move prue validation code from virDomainNetDefParseXML to virDomainNetDefValidate Date: Mon, 19 Sep 2022 10:55:15 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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 3.1 on 10.11.54.7 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: 1663577827745100007 Content-Type: text/plain; charset="utf-8" The moved code is pure validation of semantics of the definition and not actual parsed values. Move it to the validation code. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 38 -------------------------------------- src/conf/domain_validate.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3850684707..648ce18a3f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9344,44 +9344,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, return NULL; } - switch (def->type) { - case VIR_DOMAIN_NET_TYPE_NETWORK: - break; - - case VIR_DOMAIN_NET_TYPE_VHOSTUSER: - if (!virDomainNetIsVirtioModel(def)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Wrong or no 'type' attribute " - "specified with . " - "vhostuser requires the virtio-net* frontend"= )); - return NULL; - } - - if (def->data.vhostuser->data.nix.listen && - def->data.vhostuser->data.nix.reconnect.enabled =3D=3D VIR_TRI= STATE_BOOL_YES) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("'reconnect' attribute unsupported 'server' m= ode for ")); - return NULL; - } - break; - - case VIR_DOMAIN_NET_TYPE_VDPA: - case VIR_DOMAIN_NET_TYPE_BRIDGE: - case VIR_DOMAIN_NET_TYPE_CLIENT: - case VIR_DOMAIN_NET_TYPE_SERVER: - case VIR_DOMAIN_NET_TYPE_MCAST: - case VIR_DOMAIN_NET_TYPE_UDP: - case VIR_DOMAIN_NET_TYPE_INTERNAL: - case VIR_DOMAIN_NET_TYPE_DIRECT: - case VIR_DOMAIN_NET_TYPE_HOSTDEV: - case VIR_DOMAIN_NET_TYPE_VDS: - case VIR_DOMAIN_NET_TYPE_ETHERNET: - case VIR_DOMAIN_NET_TYPE_USER: - case VIR_DOMAIN_NET_TYPE_NULL: - case VIR_DOMAIN_NET_TYPE_LAST: - break; - } - if (virDomainNetIPInfoParseXML(_("guest interface"), node, ctxt, &def->guestIP) < 0) return NULL; diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 6ecf6d1c11..81f6d5dbd5 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -2134,6 +2134,40 @@ virDomainNetDefValidate(const virDomainNetDef *net) return -1; } + switch (net->type) { + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: + if (!virDomainNetIsVirtioModel(net)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Wrong or no 'type' attribute specifi= ed with . vhostuser requires the virtio-net*= frontend")); + return -1; + } + + if (net->data.vhostuser->data.nix.listen && + net->data.vhostuser->data.nix.reconnect.enabled =3D=3D VIR_TRI= STATE_BOOL_YES) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'reconnect' attribute unsupported 'server' m= ode for ")); + return -1; + } + break; + + case VIR_DOMAIN_NET_TYPE_NETWORK: + case VIR_DOMAIN_NET_TYPE_VDPA: + case VIR_DOMAIN_NET_TYPE_BRIDGE: + case VIR_DOMAIN_NET_TYPE_CLIENT: + case VIR_DOMAIN_NET_TYPE_SERVER: + case VIR_DOMAIN_NET_TYPE_MCAST: + case VIR_DOMAIN_NET_TYPE_UDP: + case VIR_DOMAIN_NET_TYPE_INTERNAL: + case VIR_DOMAIN_NET_TYPE_DIRECT: + case VIR_DOMAIN_NET_TYPE_HOSTDEV: + case VIR_DOMAIN_NET_TYPE_VDS: + case VIR_DOMAIN_NET_TYPE_ETHERNET: + case VIR_DOMAIN_NET_TYPE_USER: + case VIR_DOMAIN_NET_TYPE_NULL: + case VIR_DOMAIN_NET_TYPE_LAST: + break; + } + return 0; } --=20 2.37.1