From nobody Mon Feb 9 03:14:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1629982650; cv=none; d=zohomail.com; s=zohoarc; b=n91vto+lSLmGTlMC7wb3KSXrRxNDNkGkiKZASi2do8X/yI+qHTe6IasRdVPA3FX68oHr8fU7/R9wEllPiCiFRqL3dU4nEM3ysc+sunAnxVHiVC3Wbp3K2cv6nWL9sbWDRYSKK0jlOzr6NJ8mnLocaqRQFW8SvmYO21QUvTJEI2I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629982650; 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=gt4aGbLk086Pd2im0jjspOBwAVHJ9Df+XZHXGCbaw20=; b=ODoCDTDPdHCpw2plHFGItcyadMlgTYVnX0y31v5N7uH07vhwo47ZOZussSpVe0BHE9Op/l+lY9/2EG/6WjCctR4a+CzW/YPzlRtZQJje2AYIyillZhZmFeDS72/9dHgDqkuyYgWnvltCa6Mu8LrPLLc0L5DQWeT3OUndo8SoaD0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1629982650649708.7882548190261; Thu, 26 Aug 2021 05:57:30 -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-551-xJRoBbGlMgGM4UjlwasCLQ-1; Thu, 26 Aug 2021 08:57:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4D784760CC; Thu, 26 Aug 2021 12:57:23 +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 2E5BF295E5; Thu, 26 Aug 2021 12:57:23 +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 F0DE84A707; Thu, 26 Aug 2021 12:57:22 +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 17QCWm6Z017326 for ; Thu, 26 Aug 2021 08:32:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 619E160936; Thu, 26 Aug 2021 12:32:48 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id E0A5560877 for ; Thu, 26 Aug 2021 12:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629982649; 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=gt4aGbLk086Pd2im0jjspOBwAVHJ9Df+XZHXGCbaw20=; b=Qk+FncBHIW7OxcKCRdFjyOLPoSlN7Ps1fkzy60A6ln/x1iCh1y5OJQMHLZ7YcPoUv9HKkZ kjT3vqp4vtNXOGEmTKZwKHUGV47OdeAQuhO8UE/JpDbfq4IWFK+LiPUS8KBZnk6P6NguQl uNJCALcHnRECymZqOL4XXRAjadLfrYc= X-MC-Unique: xJRoBbGlMgGM4UjlwasCLQ-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 4/4] virsh: add support for '--validate' option in create nwfilter-binding Date: Thu, 26 Aug 2021 14:32:35 +0200 Message-Id: <62eadfe2ad699e58bbc802c37020699e0daa71bd.1629981057.git.khanicov@redhat.com> 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.14 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: 1629982652186100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova --- docs/manpages/virsh.rst | 5 ++++- tools/virsh-nwfilter.c | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 2204bed3bb..15ac75d487 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -7586,7 +7586,7 @@ nwfilter-binding-create =20 :: =20 - nwfilter-binding-create xmlfile + nwfilter-binding-create xmlfile [--validate] =20 Associate a network port with a network filter. The network filter backend will immediately attempt to instantiate the filter rules on the port. This @@ -7597,6 +7597,9 @@ command to define a filter for a network port and the= n starting the guest afterwards may prevent the guest from starting if it attempts to use the network port and finds a filter already defined. =20 +Optionally, the format of the input XML file can be validated against an +internal RNG schema with *--validate*. + =20 nwfilter-binding-delete ----------------------- diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index e062aa1649..77f211d031 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -503,6 +503,10 @@ static const vshCmdInfo info_nwfilter_binding_create[]= =3D { static const vshCmdOptDef opts_nwfilter_binding_create[] =3D { VIRSH_COMMON_OPT_FILE(N_("file containing an XML network " "filter binding description")), + {.name =3D "validate", + .type =3D VSH_OT_BOOL, + .help =3D N_("validate the XML against the schema") + }, {.name =3D NULL} }; =20 @@ -513,15 +517,19 @@ cmdNWFilterBindingCreate(vshControl *ctl, const vshCm= d *cmd) const char *from =3D NULL; bool ret =3D true; char *buffer; + 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_BINDING_CREATE_VALIDATE; + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; =20 - binding =3D virNWFilterBindingCreateXML(priv->conn, buffer, 0); + binding =3D virNWFilterBindingCreateXML(priv->conn, buffer, flags); VIR_FREE(buffer); =20 if (binding !=3D NULL) { --=20 2.31.1