From nobody Sun Feb 8 18:10:45 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=1629461137; cv=none; d=zohomail.com; s=zohoarc; b=MsWrlqUzgS4G8a0STNzpVLPcT2gVKmbZc9MuCH5PqtoQWgigateqYgHUMeczECJZgggNCpkX5js4+NFh7yhXMr2/jHLDtAro+sxgC8xyeK3suT9j6Uk8/qO8Vkt+DfUgR5lC9LTS/kESLHjVvVBxNSx7YMHM1v/ImIxrji2WlUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629461137; 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=Nb0/0cKfL/lfYHM7KucA2Z91Mra98E9+fljASo7RraE=; b=iCz5EFE9ZaDlT5jrYEudciQbbWETWa1n+ikLTYN6oZeqE5pWYu+IbJD0ZjlfgDOG2FtfpjDUuQA8Cd4zdW4fzcNuzUYLDFq+MkIx4I89jwa0dB/G6IKzRSyg2ktI7mslPZBY2c4rgYhz9Dg0WmJNvmrZpHnudiXHJlThdM/gL6U= 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 1629461137421835.3059614373924; Fri, 20 Aug 2021 05:05:37 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-588-1Zf5AgrMMw2XLW501t4t3A-1; Fri, 20 Aug 2021 08:05:34 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4401B802935; Fri, 20 Aug 2021 12:05:29 +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 1F2546A907; Fri, 20 Aug 2021 12:05:29 +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 E098E4A7CA; Fri, 20 Aug 2021 12:05:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17KBveQO007864 for ; Fri, 20 Aug 2021 07:57:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id C04E76EF4F; Fri, 20 Aug 2021 11:57:40 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AD4A1B49E for ; Fri, 20 Aug 2021 11:57:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629461136; 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=Nb0/0cKfL/lfYHM7KucA2Z91Mra98E9+fljASo7RraE=; b=FvgtILXaYGrvrnRuOxLyS3wsZrBMwAFjsPu4b7SN6LLL8anYf/clAubAbC4rbBQiMNRSUL s+d0uUCKBdu+7CnIDCL2UezEIYwcz6mnkFE7c9Y1FQawk4+YMyoAUoWWaBVZc+9pvWBOui iGaEi6y+ucjSjJw/RGwx/f5Ai2BMh1k= X-MC-Unique: 1Zf5AgrMMw2XLW501t4t3A-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 6/6] virsh: add support for '--validate' option in define nwfilter Date: Fri, 20 Aug 2021 13:57:10 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: 1629461138182100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova --- docs/manpages/virsh.rst | 5 ++++- tools/virsh-nwfilter.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 3eb310d02e..0326a7d015 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -7483,7 +7483,7 @@ nwfilter-define =20 :: =20 - nwfilter-define xmlfile + nwfilter-define xmlfile [--validate] =20 Make a new network filter known to libvirt. If a network filter with the same name already exists, it will be replaced with the new XML. @@ -7492,6 +7492,9 @@ its network traffic rules adapted. If for any reason = the network traffic filtering rules cannot be instantiated by any of the running virtual machines, then the new XML will be rejected. =20 +Optionally, the format of the input XML file can be validated against an +internal RNG schema with *--validate*. + =20 nwfilter-undefine ----------------- diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index f38f33798d..e062aa1649 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -81,6 +81,10 @@ static const vshCmdInfo info_nwfilter_define[] =3D { static const vshCmdOptDef opts_nwfilter_define[] =3D { VIRSH_COMMON_OPT_FILE(N_("file containing an XML network " "filter description")), + {.name =3D "validate", + .type =3D VSH_OT_BOOL, + .help =3D N_("validate the XML against the schema") + }, {.name =3D NULL} }; =20 @@ -91,15 +95,22 @@ cmdNWFilterDefine(vshControl *ctl, const vshCmd *cmd) const char *from =3D NULL; bool ret =3D true; g_autofree char *buffer =3D NULL; + unsigned int flags =3D 0; virshControl *priv =3D ctl->privData; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) return false; =20 + if (vshCommandOptBool(cmd, "validate")) + flags |=3D VIR_NWFILTER_DEFINE_VALIDATE; + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; =20 - nwfilter =3D virNWFilterDefineXML(priv->conn, buffer); + if (flags) + nwfilter =3D virNWFilterDefineXMLFlags(priv->conn, buffer, flags); + else + nwfilter =3D virNWFilterDefineXML(priv->conn, buffer); =20 if (nwfilter !=3D NULL) { vshPrintExtra(ctl, _("Network filter %s defined from %s\n"), --=20 2.31.1