From nobody Mon Feb 9 02:07:58 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=1629459348; cv=none; d=zohomail.com; s=zohoarc; b=G43+gnliljyQFf0vrdqZO9UPWtn+xolgQRGawjCgp904hnYpsCnK/NMsyQ9gp5tD80yCLSMmo9mu0oqmDbX5bVdPzXJG2ehXgDwD+8qYmD52DASI9yYjgllVYtb9/CWG6LB3mpcbl2j4IOxaUpxCO5EgfgUYpfch0JQ36SgwMwQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629459348; 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=ScI6fBHCtmuayhHjhtWS/yk3Fo2AeE8C8WdTXyCvA5w=; b=Oi7Juh1S8F++A6eQfOmGNYk1DUorqH40yDbc9DCIMSw36Q+jLu7OdkC3TKSRLadhEMRlEcrcf9LA8PAdKQqh9X7cZS2oCPVEEgOIkoXBV5H21IW6bKkWYn459pVn+jO0caGGZEfyiJPLe3+bK6nN1Z+WIWzYBZr7ABiQbSuoczQ= 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 1629459348669651.224244124207; Fri, 20 Aug 2021 04:35:48 -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-471-3-Z_enRFNg-ZKVOyuall8A-1; Fri, 20 Aug 2021 07:35:46 -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 E3C3A8799ED; Fri, 20 Aug 2021 11:35:40 +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 C4F8813AC8; Fri, 20 Aug 2021 11:35:40 +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 8FE924A7CA; Fri, 20 Aug 2021 11:35:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17KBTkFw003805 for ; Fri, 20 Aug 2021 07:29:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1A7AD18A66; Fri, 20 Aug 2021 11:29:46 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9871F5D9FC for ; Fri, 20 Aug 2021 11:29:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629459347; 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=ScI6fBHCtmuayhHjhtWS/yk3Fo2AeE8C8WdTXyCvA5w=; b=PhAnRudksYfPkrZ3gT4XeZY7v0soCQXXvNC2eN1EDofS2/Q8Ikqr5UZXotZj4xD/pONhao 7VtEodTovonnM+WyytR5hdHnLYPowUYao3CQ7O+v7j0+P28Sc8lEE54UioVe+Tdgt36Wp4 01Bo6xNUJ6dCe1k3zs2hG86S9yIjsws= X-MC-Unique: 3-Z_enRFNg-ZKVOyuall8A-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 4/4] virsh: add support for '--validate' option in define interface Date: Fri, 20 Aug 2021 13:28:52 +0200 Message-Id: <2f5fee95869207b8c8033c4c0736336f97cddeb1.1629458772.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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: 1629459350463100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova --- docs/manpages/virsh.rst | 5 +++-- tools/virsh-interface.c | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 3eb310d02e..da812ca5b7 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -5523,10 +5523,11 @@ iface-define =20 :: =20 - iface-define file + iface-define file [--validate] =20 Define an inactive persistent physical host interface or modify an existing -persistent one from the XML *file*. +persistent 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 iface-destroy diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index 07d5f50be3..46af45c97b 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -523,6 +523,10 @@ static const vshCmdInfo info_interface_define[] =3D { =20 static const vshCmdOptDef opts_interface_define[] =3D { VIRSH_COMMON_OPT_FILE(N_("file containing an XML interface description= ")), + {.name =3D "validate", + .type =3D VSH_OT_BOOL, + .help =3D N_("validate the XML against the schema") + }, {.name =3D NULL} }; =20 @@ -533,15 +537,19 @@ cmdInterfaceDefine(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_INTERFACE_DEFINE_VALIDATE; + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; =20 - iface =3D virInterfaceDefineXML(priv->conn, buffer, 0); + iface =3D virInterfaceDefineXML(priv->conn, buffer, flags); =20 if (iface !=3D NULL) { vshPrintExtra(ctl, _("Interface %s defined from %s\n"), --=20 2.31.1