From nobody Sun Feb 8 21:48:10 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=1629976956; cv=none; d=zohomail.com; s=zohoarc; b=A+X7eJkHQBwgOxE6tvq+s25YzpWTbBvQCEJLp6iLv9BPedYiy4K4dK5ujcHVj9VnoWelJv4Ude3hbp678tpjxrh/DddQbosnUbbfIuCQ7OBEndmbd9tGOqXd7EsyX4YaYzJ46qz+r1bod5v5EstWwqLaDNE4wGf6hFxl20uenFY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629976956; 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=+gz/h29JKIK9ZXZXDRRZLy3DWPw2efB6BIBFqII2LLc=; b=mryKnDziheTZbWrWQiHx+3otQO5zA1aI8oCXwZfn3JTh3xVfAMKJqMZuHPkax9DGScK5DT3vVDbdFY6QDPmbxHvdskSNCw7DTPQB5iijQeQEfmRz4pwBzIiZTlWx3o/vt68/w1hTeu+ss+AZBAKTTvfFs/9vq5shNDbNhcS1jN0= 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 1629976956008980.662930757045; Thu, 26 Aug 2021 04:22:36 -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-204-Af8RushPMcildR_qjm2A0A-1; Thu, 26 Aug 2021 07:22:33 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 632C3CC621; Thu, 26 Aug 2021 11:22:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F35FE1002388; Thu, 26 Aug 2021 11:22:27 +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 C322F181A2A9; Thu, 26 Aug 2021 11:22:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17QBM4Rj005589 for ; Thu, 26 Aug 2021 07:22:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1522719C59; Thu, 26 Aug 2021 11:22:04 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9026419D9F for ; Thu, 26 Aug 2021 11:22:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629976955; 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=+gz/h29JKIK9ZXZXDRRZLy3DWPw2efB6BIBFqII2LLc=; b=UlVC12n16AxaSTyAWNVJG2ccYwz0/oi3LyPktSEd+uXQfFpJJMEXB9qr2A1FK0q/dLXRfu vxu/3j6Riw2jdcZ8MC2kCfuxxyyKtQR3/CjIlXN4SohHk09auEy8cKZCdWZi7E9vlVXSPI mQnMZwNhAOWzUHA+3OMFy/RYPT2Yd+o= X-MC-Unique: Af8RushPMcildR_qjm2A0A-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 6/6] virsh: add support for '--validate' option in create network Date: Thu, 26 Aug 2021 13:21:44 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.84 on 10.5.11.22 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: 1629976957011100002 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 2204bed3bb..b05b25c555 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -5162,13 +5162,15 @@ net-create =20 :: =20 - net-create file + net-create file [--validate] =20 Create a transient (temporary) virtual network from an XML *file* and instantiate (start) the network. See the documentation at `https://libvirt.org/formatnetwork.html `__ to get a description of the XML network format used by libvirt. =20 +Optionally, the format of the input XML file can be validated against an +internal RNG schema with *--validate*. =20 net-define ---------- diff --git a/tools/virsh-network.c b/tools/virsh-network.c index badbcd0a92..eff9d153c4 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -197,6 +197,10 @@ static const vshCmdInfo info_network_create[] =3D { =20 static const vshCmdOptDef opts_network_create[] =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 @@ -207,15 +211,22 @@ cmdNetworkCreate(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_CREATE_VALIDATE; + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; =20 - network =3D virNetworkCreateXML(priv->conn, buffer); + if (flags) + network =3D virNetworkCreateXMLFlags(priv->conn, buffer, flags); + else + network =3D virNetworkCreateXML(priv->conn, buffer); =20 if (network !=3D NULL) { vshPrintExtra(ctl, _("Network %s created from %s\n"), --=20 2.31.1