From nobody Wed May 1 17:14:18 2024 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=1629459064; cv=none; d=zohomail.com; s=zohoarc; b=S5yyqGJXQbVCHgXZVn4W/S2+gyG4S7YEeDIhfG90aTwlunN9cfrXEsnqGyYem2VfZSvPiM5ta1f81aGSPev1OAkLxzaAIHFo3Yj/F2SkJNXEEFZ8mrRu2KDuU44xi1b9R0M7q8y/zqED2FQByqfGHIENWpVCMJvYxi11Iv6nWwk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629459064; 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=pR/gp8YkFwaukXgypFOYHZU6Mej1iA6nYUOJWQTdKJU=; b=MATPb7eaSmeg6vZZBRiSmPA6nFYYqCo7O6EWNdrjR2i9H0+4ZeDxBDD+hHdADMYBGsoY57cpUu7XDol2Ru01OygKK0e8SxTGyRLCELOD/wTQQPAAGyHLQeOnFolkKc5+irrWMuB6LG13dLAQXMumU+zEFTnG+JPSQ3L631Kp8n4= 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 1629459064893468.3289009078229; Fri, 20 Aug 2021 04:31:04 -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-455-KnDZfoAGMeqNvuRoqBByvQ-1; Fri, 20 Aug 2021 07:30:52 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9237D8015C7; Fri, 20 Aug 2021 11:30:47 +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 4544C369A; Fri, 20 Aug 2021 11:30:47 +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 ABA91181A0F9; Fri, 20 Aug 2021 11:30:46 +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 17KBThf5003779 for ; Fri, 20 Aug 2021 07:29:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id AD8DA18A66; Fri, 20 Aug 2021 11:29:43 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36FD85D9FC for ; Fri, 20 Aug 2021 11:29:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629459063; 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=pR/gp8YkFwaukXgypFOYHZU6Mej1iA6nYUOJWQTdKJU=; b=h/FrH9B5Vcw/+06fYwfT4Fg83czHC/gzBBS+KzNKZI05jeF6S6ztCcrfb+m6tQxYOEMnwJ dIpcW1xmox3LHvcAUHp3FF/8McBOHfQYaBIiKomO97mDEI0FpvMGCzfkPI8bJUbxHzgaqW SrsiUeAJN+JGUHoCmsnyNqwUTEAEFvM= X-MC-Unique: KnDZfoAGMeqNvuRoqBByvQ-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 1/4] api: add virInterfaceDefineFlags Date: Fri, 20 Aug 2021 13:28:49 +0200 Message-Id: <22ea728f472f329c4fdaa4d9b07576e376dfc1ed.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.11 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: 1629459066835100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova --- include/libvirt/libvirt-interface.h | 4 ++++ src/libvirt-interface.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-interface.h b/include/libvirt/libvirt-= interface.h index 7591c6c7fb..803cb33ffe 100644 --- a/include/libvirt/libvirt-interface.h +++ b/include/libvirt/libvirt-interface.h @@ -79,6 +79,10 @@ typedef enum { VIR_INTERFACE_XML_INACTIVE =3D 1 << 0 /* dump inactive interface infor= mation */ } virInterfaceXMLFlags; =20 +typedef enum { + VIR_INTERFACE_DEFINE_VALIDATE =3D 1 << 0, /* Validate the XML document= against schema */ +} virInterfaceDefineFlags; + char * virInterfaceGetXMLDesc (virInterfacePtr iface, unsigned int flags); virInterfacePtr virInterfaceDefineXML (virConnectPtr conn, diff --git a/src/libvirt-interface.c b/src/libvirt-interface.c index 5eb5980483..2af86291d3 100644 --- a/src/libvirt-interface.c +++ b/src/libvirt-interface.c @@ -437,7 +437,7 @@ virInterfaceGetXMLDesc(virInterfacePtr iface, unsigned = int flags) * virInterfaceDefineXML: * @conn: pointer to the hypervisor connection * @xml: the XML description for the interface, preferably in UTF-8 - * @flags: extra flags; not used yet, so callers should always pass 0 + * @flags: bitwise-OR of virInterfaceDefineFlags * * Define an inactive persistent physical host interface or modify an exis= ting * persistent one from the XML description. --=20 2.31.1 From nobody Wed May 1 17:14:18 2024 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=1629459342; cv=none; d=zohomail.com; s=zohoarc; b=krBP9OEWQS9jettZ979HU2LzQ0nsIfOUe5ecliKvABappXjznJoR12Bef0jR6KVvub1foJsfhUF7yQ61fpF3oO3UX7ckqJVeggWco0LhCeM5HWpgsQ/Wtzrm3zPO6vCtqiC91lw58lzLuFgksSace0ZcWQDOc+KD8f5s4feiKJA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629459342; 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=hjkDcuX3mZLWKstnbaR0AdaNuPnqfNvzJJZGdVZ+8y8=; b=hekylsyTNptRE92H4ygurM6vAbQyGx0PnZKASpucd+Ty8AKz8yRRNqxHS2QNWoS0a0zxTJTMILEGMkSgSV1kQACgqWbANk6UXJi0doUXjmFbCyzgfbumUnw7QL5ZpwrqIVMt2aRMwzKcLxznJi/II/p74T3Xp26sr88jQLEo/hQ= 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 1629459342568801.8675515402788; Fri, 20 Aug 2021 04:35:42 -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-56-aO37ndS7N4mw7zREvcL9EQ-1; Fri, 20 Aug 2021 07:35:38 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 97C8F18C8C00; Fri, 20 Aug 2021 11:35:33 +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 7238E369A; Fri, 20 Aug 2021 11:35:32 +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 14F45181A1CE; Fri, 20 Aug 2021 11:35:31 +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 17KBTieu003785 for ; Fri, 20 Aug 2021 07:29:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7CF4618A66; Fri, 20 Aug 2021 11:29:44 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05F395D9FC for ; Fri, 20 Aug 2021 11:29:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629459340; 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=hjkDcuX3mZLWKstnbaR0AdaNuPnqfNvzJJZGdVZ+8y8=; b=P9Tmb9VlXLALqAEHFoL6xXiDtyA8f9iChEhnC8/2O05yNlWYPI/Fj7+INK/fZAtBNH/lc4 dg6cYEpVGCgX17XlBhYBgjGZQiVWjlCiipsFSllU9yCQXXWGGQymGh5bhItP2R5tWvQi6u MJFm/1HizBsmEsnIWhnR9EARDwpGWa4= X-MC-Unique: aO37ndS7N4mw7zREvcL9EQ-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 2/4] conf: add validation and propagate flags into virInterfaceDefParse() Date: Fri, 20 Aug 2021 13:28:50 +0200 Message-Id: <496c26549975ff332d3b7b907027784699098c4b.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.11 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: 1629459344032100001 Content-Type: text/plain; charset="utf-8" We need to know if validation flag is present in order to validate given XML against schema in virXMLParse(). Signed-off-by: Kristina Hanicova --- src/conf/interface_conf.c | 14 ++++++++------ src/conf/interface_conf.h | 3 ++- src/conf/virinterfaceobj.c | 2 +- src/interface/interface_backend_netcf.c | 4 ++-- src/test/test_driver.c | 2 +- tests/interfacexml2xmltest.c | 2 +- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index c371a252a8..464ff26856 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -685,7 +685,6 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr lnk; =20 - /* check @type */ tmp =3D virXPathString("string(./@type)", ctxt); if (tmp =3D=3D NULL) { @@ -819,12 +818,14 @@ virInterfaceDefParseNode(xmlDocPtr xml, =20 static virInterfaceDef * virInterfaceDefParse(const char *xmlStr, - const char *filename) + const char *filename, + unsigned int flags) { g_autoptr(xmlDoc) xml =3D NULL; virInterfaceDef *def =3D NULL; =20 - if ((xml =3D virXMLParse(filename, xmlStr, _("(interface_definition)")= , NULL, false))) { + if ((xml =3D virXMLParse(filename, xmlStr, _("(interface_definition)")= , "interface.rng", + flags & VIR_INTERFACE_DEFINE_VALIDATE))) { def =3D virInterfaceDefParseNode(xml, xmlDocGetRootElement(xml)); } =20 @@ -833,16 +834,17 @@ virInterfaceDefParse(const char *xmlStr, =20 =20 virInterfaceDef * -virInterfaceDefParseString(const char *xmlStr) +virInterfaceDefParseString(const char *xmlStr, + unsigned int flags) { - return virInterfaceDefParse(xmlStr, NULL); + return virInterfaceDefParse(xmlStr, NULL, flags); } =20 =20 virInterfaceDef * virInterfaceDefParseFile(const char *filename) { - return virInterfaceDefParse(NULL, filename); + return virInterfaceDefParse(NULL, filename, 0); } =20 =20 diff --git a/src/conf/interface_conf.h b/src/conf/interface_conf.h index f5e802736b..ea92e0fb31 100644 --- a/src/conf/interface_conf.h +++ b/src/conf/interface_conf.h @@ -155,7 +155,8 @@ void virInterfaceDefFree(virInterfaceDef *def); =20 virInterfaceDef * -virInterfaceDefParseString(const char *xmlStr); +virInterfaceDefParseString(const char *xmlStr, + unsigned int flags); =20 virInterfaceDef * virInterfaceDefParseFile(const char *filename); diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c index a73208f1fc..9439bb3d0b 100644 --- a/src/conf/virinterfaceobj.c +++ b/src/conf/virinterfaceobj.c @@ -373,7 +373,7 @@ virInterfaceObjListCloneCb(void *payload, if (!(xml =3D virInterfaceDefFormat(srcObj->def))) goto error; =20 - if (!(backup =3D virInterfaceDefParseString(xml))) + if (!(backup =3D virInterfaceDefParseString(xml, 0))) goto error; VIR_FREE(xml); =20 diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interf= ace_backend_netcf.c index 416e0af36f..9f93cdd657 100644 --- a/src/interface/interface_backend_netcf.c +++ b/src/interface/interface_backend_netcf.c @@ -862,7 +862,7 @@ static char *netcfInterfaceGetXMLDesc(virInterfacePtr i= finfo, goto cleanup; } =20 - ifacedef =3D virInterfaceDefParseString(xmlstr); + ifacedef =3D virInterfaceDefParseString(xmlstr, 0); if (!ifacedef) { /* error was already reported */ goto cleanup; @@ -898,7 +898,7 @@ static virInterfacePtr netcfInterfaceDefineXML(virConne= ctPtr conn, =20 virObjectLock(driver); =20 - ifacedef =3D virInterfaceDefParseString(xml); + ifacedef =3D virInterfaceDefParseString(xml, 0); if (!ifacedef) { /* error was already reported */ goto cleanup; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 10a1767542..450510ee54 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -6159,7 +6159,7 @@ testInterfaceDefineXML(virConnectPtr conn, virCheckFlags(0, NULL); =20 virObjectLock(privconn); - if ((def =3D virInterfaceDefParseString(xmlStr)) =3D=3D NULL) + if ((def =3D virInterfaceDefParseString(xmlStr, 0)) =3D=3D NULL) goto cleanup; =20 if ((obj =3D virInterfaceObjListAssignDef(privconn->ifaces, def)) =3D= =3D NULL) diff --git a/tests/interfacexml2xmltest.c b/tests/interfacexml2xmltest.c index 07d179e3a3..3785467f84 100644 --- a/tests/interfacexml2xmltest.c +++ b/tests/interfacexml2xmltest.c @@ -24,7 +24,7 @@ testCompareXMLToXMLFiles(const char *xml) if (virTestLoadFile(xml, &xmlData) < 0) goto fail; =20 - if (!(dev =3D virInterfaceDefParseString(xmlData))) + if (!(dev =3D virInterfaceDefParseString(xmlData, 0))) goto fail; =20 if (!(actual =3D virInterfaceDefFormat(dev))) --=20 2.31.1 From nobody Wed May 1 17:14:18 2024 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=1629459345; cv=none; d=zohomail.com; s=zohoarc; b=Rw7VN1BrQZ4OmvqpaVBSQQLLuhTal8t5y7O+27+/ou3ElNNfxSXAehMwI2csXlcykAKYYcJINqap29e1HtMrA9xvPPiPBARkLK5rG70FE55bAyuOiDN0DWno6fkh06CoRaArxUEpMpN2wI7Jrs4uLZNWnacVZqeVAIO89zf8Q2s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629459345; 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=URA2KUNNzoSY1jzNnDt4VyIae+KF68HMAEbxXhb5NZA=; b=he9cZHiwQb7w5Ycc1ji1ipOi9MI/KEkqVzAOdXO4Oiy9ZK3kIykr1lj4Sja6Cdjuo3ghlnHiWPX9JHDLcGmfmX/wEj2Qfhv+mJ51YeB3Ntvi9bnkSBQYehOdxg9Qj79LOPLLcS+ZfWbnHkb4MYeav0/eJElGFw5//O5tyL/Balc= 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 162945934585421.40768801311731; Fri, 20 Aug 2021 04:35:45 -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-428-wCILC6urOqqOe-4V4F0Baw-1; Fri, 20 Aug 2021 07:35:42 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8F8552E78; Fri, 20 Aug 2021 11:35:37 +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 696E95C1D0; Fri, 20 Aug 2021 11:35:37 +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 288B94BB7C; Fri, 20 Aug 2021 11:35:37 +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 17KBTjCj003798 for ; Fri, 20 Aug 2021 07:29:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4B96E18A66; Fri, 20 Aug 2021 11:29:45 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id C92415D9FC for ; Fri, 20 Aug 2021 11:29:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629459344; 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=URA2KUNNzoSY1jzNnDt4VyIae+KF68HMAEbxXhb5NZA=; b=RilZGhkMV5I4x9nj5IM7TIxbOavOHo7q3dspI91mbQMeNbg5bHto162exeHi/OZXC4NuuV c56/nIFbXq/goNUd2s8/hxGUzqSaTkkASUyt4eBzmamICju+G/OBFBk+RaPwqcJFvnnIGb 1Wrl8/+dy67X7RosqIl83PuoKrz2MSs= X-MC-Unique: wCILC6urOqqOe-4V4F0Baw-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 3/4] src: allow validation flag in interface define Date: Fri, 20 Aug 2021 13:28:51 +0200 Message-Id: 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.16 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: 1629459346294100001 Content-Type: text/plain; charset="utf-8" We need to validate the XML against schema if option 'validate' was passed to the 'iface-define' virsh command. For that we need to allow validation flag and propagate flags to parse function. Signed-off-by: Kristina Hanicova --- src/interface/interface_backend_netcf.c | 4 ++-- src/test/test_driver.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interf= ace_backend_netcf.c index 9f93cdd657..78fd4f9bc7 100644 --- a/src/interface/interface_backend_netcf.c +++ b/src/interface/interface_backend_netcf.c @@ -894,11 +894,11 @@ static virInterfacePtr netcfInterfaceDefineXML(virCon= nectPtr conn, virInterfaceDef *ifacedef =3D NULL; virInterfacePtr ret =3D NULL; =20 - virCheckFlags(0, NULL); + virCheckFlags(VIR_INTERFACE_DEFINE_VALIDATE, NULL); =20 virObjectLock(driver); =20 - ifacedef =3D virInterfaceDefParseString(xml, 0); + ifacedef =3D virInterfaceDefParseString(xml, flags); if (!ifacedef) { /* error was already reported */ goto cleanup; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 450510ee54..67db02b25d 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -6156,10 +6156,10 @@ testInterfaceDefineXML(virConnectPtr conn, virInterfaceDef *objdef; virInterfacePtr ret =3D NULL; =20 - virCheckFlags(0, NULL); + virCheckFlags(VIR_INTERFACE_DEFINE_VALIDATE, NULL); =20 virObjectLock(privconn); - if ((def =3D virInterfaceDefParseString(xmlStr, 0)) =3D=3D NULL) + if ((def =3D virInterfaceDefParseString(xmlStr, flags)) =3D=3D NULL) goto cleanup; =20 if ((obj =3D virInterfaceObjListAssignDef(privconn->ifaces, def)) =3D= =3D NULL) --=20 2.31.1 From nobody Wed May 1 17:14:18 2024 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