From nobody Mon Feb 9 03:14:37 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=1629737548; cv=none; d=zohomail.com; s=zohoarc; b=lt/S4M8ByYJSVA25oknJ104BVBBtgKVa1+6CSiZdCy23xvM0js9h+pFeZbUVSOksEcTP6kQTDfldBJ1B0OkEaFwNta1Kx64FEc1u3jwE2G8x4RWg+vhtgYk3Eb89/aWwfx3b4R7/ybOtAATnm+Ehf2CTLgaGnWHasJyN5/47fnM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629737548; 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=8Xz/vmjW6DI/zL80zMSWC2oyCKxX5guyDSyY0as6XIk=; b=Pth/PJ/rCGJi+q5T6WPQ6ny4fsA0ldfEO8XPwsj2xi1aQJ/xx8W7QgymGW0qfeW6OY57K9ROXwRBaNHGBZO1yg9oXY6Afx2+2dPbPH8CEeyWJXJ9hZIsW+GlHWw3F3FkeKyAxUM04hdFBKoxDvGQ2iKN5Hg9udYNZblA1DUqJ50= 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 1629737548582812.4110698823566; Mon, 23 Aug 2021 09:52:28 -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-427--A87dsXNNHW2X9_qbFuskw-1; Mon, 23 Aug 2021 12:52:26 -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 80BBC94EE1; Mon, 23 Aug 2021 16:52:20 +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 60D435D9D3; Mon, 23 Aug 2021 16:52:20 +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 29EB34A709; Mon, 23 Aug 2021 16:52:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17NGoZ83031676 for ; Mon, 23 Aug 2021 12:50:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8325A10372E4; Mon, 23 Aug 2021 16:50:35 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A53D10372D5 for ; Mon, 23 Aug 2021 16:50:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629737547; 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=8Xz/vmjW6DI/zL80zMSWC2oyCKxX5guyDSyY0as6XIk=; b=LtDvParQ592zuTtPIPrdT1O19uvXg20psq7gIeQkmPaDZDNzISiNGLVU/geMIuxJj7pJGA ofQWZMMUp9MCqHOtpkp7K/9BPDsmSy3qgrQ6WM8XByq+E02ZMi/qNJnPI9wR1Gkb6ylq9+ pudZsmEUYlRoBgyY4XHOPnlLrjOEFRk= X-MC-Unique: -A87dsXNNHW2X9_qbFuskw-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 7/7] virsh: add support for '--validate' option in define network Date: Mon, 23 Aug 2021 18:50:14 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: 1629737548946100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova --- docs/manpages/virsh.rst | 4 +++- tools/virsh-network.c | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index e0cdabf3aa..850a862fd9 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -5177,10 +5177,12 @@ net-define =20 :: =20 - net-define file + net-define file [--validate] =20 Define an inactive persistent virtual network or modify an existing persis= tent one from the XML *file*. +Optionally, the format of the input XML file can be validated against an +internal RNG schema with *--validate*. =20 =20 net-destroy diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 0d61e20093..badbcd0a92 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -244,6 +244,10 @@ static const vshCmdInfo info_network_define[] =3D { =20 static const vshCmdOptDef opts_network_define[] =3D { VIRSH_COMMON_OPT_FILE(N_("file containing an XML network description")= ), + {.name =3D "validate", + .type =3D VSH_OT_BOOL, + .help =3D N_("validate the XML against the schema") + }, {.name =3D NULL} }; =20 @@ -254,15 +258,22 @@ cmdNetworkDefine(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_NETWORK_DEFINE_VALIDATE; + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; =20 - network =3D virNetworkDefineXML(priv->conn, buffer); + if (flags) + network =3D virNetworkDefineXMLFlags(priv->conn, buffer, flags); + else + network =3D virNetworkDefineXML(priv->conn, buffer); =20 if (network !=3D NULL) { vshPrintExtra(ctl, _("Network %s defined from %s\n"), --=20 2.31.1