From nobody Mon Feb 9 12:11:31 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=1631704081; cv=none; d=zohomail.com; s=zohoarc; b=Gb8yrtwkrXqPKG96TBChR26ZKvt0JKqMYp/m19zlI45ceitXmFRHgFlgkYYx+44uOwFRoAMdbxlmvmCTqvNOu/AV3w3ReN3zGGPU3ETbg9k5O4r6fal3I03Ok4vmfX93W1KDysi7pYrPruBQZfJWex0Z6zofE5dtMpYkl/cIjQY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631704081; 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=wj2wj3NyxUMKvWPpe2/cFgiby9FW6hYEMcCJAJHjNIE=; b=i1CwbElQk2FGgQUjtj3HXZ1DxO0Lc1yzIzr2RRRP0+L1o/boLzHqNJQAO7XNW4RcvYakVR0HaspR9+pTh+wMhGF2F0TZVrU8nSYUTYWz0OadqborlACCXSVIyGPzJz8KajugT33g6ylCIuYHOtmkN6Eies36boddpxpLID/YKYw= 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 163170408147789.83494793773696; Wed, 15 Sep 2021 04:08:01 -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-28-dAXnbi1pOOyBQSXeXzbgKQ-1; Wed, 15 Sep 2021 07:07:58 -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 08BAB100CCC8; Wed, 15 Sep 2021 11:07:50 +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 DED065D9F4; Wed, 15 Sep 2021 11:07:49 +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 AF8851806D02; Wed, 15 Sep 2021 11:07:49 +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 18FB7lTj029053 for ; Wed, 15 Sep 2021 07:07:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4534710023AE; Wed, 15 Sep 2021 11:07:47 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.43.2.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id C45371001281 for ; Wed, 15 Sep 2021 11:07:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631704080; 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=wj2wj3NyxUMKvWPpe2/cFgiby9FW6hYEMcCJAJHjNIE=; b=H3NpwYPX7o+1C/RH2LXUOicj8u7yQ8VZvmDf3uG60+cBeDj5qxOJBeeV+3y9tsdRO32QnS goMmh67P3s3CDDchRcr+h/0EHCc7x6N8DscSGOOXPolnj8JUX8nuoIyuJL4kBN1Ov3g9R7 fxNGpATQKBraNVcrlNRA/X2OcSJjAq4= X-MC-Unique: dAXnbi1pOOyBQSXeXzbgKQ-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 5/5] virsh: add support for '--validate' option in create network Date: Wed, 15 Sep 2021 13:07:31 +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: 1631704082867100003 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 ce98283ae3..48d6ab54df 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -5189,13 +5189,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 a8f7f46905..37c19b663b 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