From nobody Thu May 2 22:17:28 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=1629816703; cv=none; d=zohomail.com; s=zohoarc; b=HOlv7yJwqRj1U6R9azJIwm69FWBL0C6M2uyzBWQepI0VdrOm6ITBip8R9Vi+D9TQxFMZZ5bL9pPko07clNZYVVz7Oo4QcycUOXnFd1juElxAvYLblgYeJU1dJPas7zZ2D+BHnEsvhVDVLm3cSfnBvz6nalzaRCUl/Xv47aWMCCg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629816703; 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=Pj1FtH4YvX4Xq7/xsb6vGq4Wlb7s1uUy4DPJRa5BSNg=; b=Zk+YX+ZJ8tVtp9w2FoWkKFcA/Uhc3yJuBVoD1aBwPAUraioYaW0qAVgmbzy09+oWLMrRyw1ZEIOQcXjspTo5Mtoe3mwN4KOX+M168c/LbKS/3VYGTlP6y+r9IDSCsfiP/SnxIi79/E0mf7Wm8qKnQQGrS5CKXoCXSylbVTIXYX4= 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 1629816703742308.2536257685357; Tue, 24 Aug 2021 07:51:43 -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-459-CgEDK4c0Ptux2fheVgDIAQ-1; Tue, 24 Aug 2021 10:51:40 -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 5302A185302E; Tue, 24 Aug 2021 14:51:35 +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 0BA6C60BD9; Tue, 24 Aug 2021 14:51:35 +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 9F1B250038; Tue, 24 Aug 2021 14:51:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17OEpWSF007230 for ; Tue, 24 Aug 2021 10:51:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 048D060C9D; Tue, 24 Aug 2021 14:51:32 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.43.2.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 81C6660C82 for ; Tue, 24 Aug 2021 14:51:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629816702; 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=Pj1FtH4YvX4Xq7/xsb6vGq4Wlb7s1uUy4DPJRa5BSNg=; b=BgdH/78UrQN1d5oJUDGSo0ve12Ea5K0IQqJQCb1QzgN4+jmeYOdV/tiaulSyUEq6xGp85x 0sL9glUX6muIBUuvEJLAxHak8DFFkORHgYBHb2ua7iwQfcK/l3WZchKBQpd4xc5y+HbvMD t+1plXeSmxBlthVfImzE6PS7/ZpNHuM= X-MC-Unique: CgEDK4c0Ptux2fheVgDIAQ-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 1/4] api: add virStoragePoolDefineFlags Date: Tue, 24 Aug 2021 16:51:08 +0200 Message-Id: <6dbeab7350c7171cea114fd4f17623540092a5e7.1629815312.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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: 1629816705122100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova Reviewed-by: Michal Privoznik --- include/libvirt/libvirt-storage.h | 4 ++++ src/libvirt-storage.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-storage.h b/include/libvirt/libvirt-st= orage.h index 089e1e0bd1..b459fe3e8e 100644 --- a/include/libvirt/libvirt-storage.h +++ b/include/libvirt/libvirt-storage.h @@ -271,6 +271,10 @@ virStoragePoolPtr virStoragePoolLookupByVolume = (virStorageVolPtr vol); virStoragePoolPtr virStoragePoolLookupByTargetPath(virConnectPtr con= n, const char *path); =20 +typedef enum { + VIR_STORAGE_POOL_DEFINE_VALIDATE =3D 1 << 0, /* Validate the XML docum= ent against schema */ +} virStoragePoolDefineFlags; + /* * Creating/destroying pools */ diff --git a/src/libvirt-storage.c b/src/libvirt-storage.c index 2a7cdca234..5ec61c7d99 100644 --- a/src/libvirt-storage.c +++ b/src/libvirt-storage.c @@ -589,7 +589,7 @@ virStoragePoolCreateXML(virConnectPtr conn, * virStoragePoolDefineXML: * @conn: pointer to hypervisor connection * @xml: XML description for new pool - * @flags: extra flags; not used yet, so callers should always pass 0 + * @flags: bitwise-OR of virStoragePoolDefineFlags * * Define an inactive persistent storage pool or modify an existing persis= tent * one from the XML description. --=20 2.31.1 From nobody Thu May 2 22:17:28 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=1629816732; cv=none; d=zohomail.com; s=zohoarc; b=iLL+33Pls7w8ZysLMLcARBOUArHa4xz3605RINaMkqKJGQ3u8E0kI43PYNkar5SuBYPF1jruupceR9H0Cw4TaYHk8LtsB6XDXGbnj+URc0Po4pku6n9eKTmEOnfdv/i90DPXZZnJeyrBqULP8XDDKSP80KxzT2ztwMwHyB8RneE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629816732; 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=4WUQJlvKvkgw5dgfjGwrl6KRqfxE7hZ5QHYVfzgiiho=; b=RngFfem0F750T9zir7DSmVS/PPBwpxjx1F/uOAWflt2yQGErvhjeIRiffG4f/9UCN0fdRb1BBMpCqH5Ttu1QTL8T0qfD4vtA204W7JIDaSSSx5I/t3JLV/XPOnFcNMFaXH+Jw+4uRVpCyUmrCBfDDLqziN8u658TXzzoMCC/S6w= 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 1629816732289781.0936221841852; Tue, 24 Aug 2021 07:52:12 -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-459-TIc_QijVPSmvBGfhbm-t-Q-1; Tue, 24 Aug 2021 10:51:40 -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 16E3D185302B; Tue, 24 Aug 2021 14:51:35 +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 C93905DA60; Tue, 24 Aug 2021 14:51:34 +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 99FC65002D; Tue, 24 Aug 2021 14:51:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17OEpWAH007241 for ; Tue, 24 Aug 2021 10:51:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id CAD9060C9D; Tue, 24 Aug 2021 14:51:32 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.43.2.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50E2260C82 for ; Tue, 24 Aug 2021 14:51:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629816731; 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=4WUQJlvKvkgw5dgfjGwrl6KRqfxE7hZ5QHYVfzgiiho=; b=awRjJBmivWlb1Wr8tv6rwWFOZhlcIjiB8nh+0t42LsLbm1mxTZ3U5Wl3F1cqVyGH5Tfn0I tWLBB2gw1XxXXPMZaUAmm25cT/ujupJBA+p7tXUS4i8cBVLZgotJTmEPev7nNYR8gxIWjb PBiDmIZ+bFI/kJv1t81fUO8ns4iK4+w= X-MC-Unique: TIc_QijVPSmvBGfhbm-t-Q-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 2/4] storage_conf: add validation against schema in pool define Date: Tue, 24 Aug 2021 16:51:09 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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: 1629816733780100001 Content-Type: text/plain; charset="utf-8" We need to validate the XML against schema if option '--validate' was passed to the virsh command. This patch also includes propagation of flags into the virStoragePoolDefParse() function. Signed-off-by: Kristina Hanicova Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 2 +- src/conf/storage_conf.c | 13 ++++++++----- src/conf/storage_conf.h | 3 ++- src/storage/storage_driver.c | 4 ++-- src/test/test_driver.c | 4 ++-- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0328447f87..6127513117 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -30707,7 +30707,7 @@ virDomainStorageSourceTranslateSourcePool(virStorag= eSource *src, if (!(poolxml =3D virStoragePoolGetXMLDesc(pool, 0))) return -1; =20 - if (!(pooldef =3D virStoragePoolDefParseString(poolxml))) + if (!(pooldef =3D virStoragePoolDefParseString(poolxml, 0))) return -1; =20 src->srcpool->pooltype =3D pooldef->type; diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 040a413d0f..c78456695c 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1004,12 +1004,14 @@ virStoragePoolDefParseNode(xmlDocPtr xml, =20 static virStoragePoolDef * virStoragePoolDefParse(const char *xmlStr, - const char *filename) + const char *filename, + unsigned int flags) { virStoragePoolDef *ret =3D NULL; g_autoptr(xmlDoc) xml =3D NULL; =20 - if ((xml =3D virXMLParse(filename, xmlStr, _("(storage_pool_definition= )"), NULL, false))) { + if ((xml =3D virXMLParse(filename, xmlStr, _("(storage_pool_definition= )"), + "storagepool.rng", flags & VIR_STORAGE_POOL_DEF= INE_VALIDATE))) { ret =3D virStoragePoolDefParseNode(xml, xmlDocGetRootElement(xml)); } =20 @@ -1018,16 +1020,17 @@ virStoragePoolDefParse(const char *xmlStr, =20 =20 virStoragePoolDef * -virStoragePoolDefParseString(const char *xmlStr) +virStoragePoolDefParseString(const char *xmlStr, + unsigned int flags) { - return virStoragePoolDefParse(xmlStr, NULL); + return virStoragePoolDefParse(xmlStr, NULL, flags); } =20 =20 virStoragePoolDef * virStoragePoolDefParseFile(const char *filename) { - return virStoragePoolDefParse(NULL, filename); + return virStoragePoolDefParse(NULL, filename, 0); } =20 =20 diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h index 76efaac531..aaecf138d6 100644 --- a/src/conf/storage_conf.h +++ b/src/conf/storage_conf.h @@ -275,7 +275,8 @@ virStoragePoolDef * virStoragePoolDefParseXML(xmlXPathContextPtr ctxt); =20 virStoragePoolDef * -virStoragePoolDefParseString(const char *xml); +virStoragePoolDefParseString(const char *xml, + unsigned int flags); =20 virStoragePoolDef * virStoragePoolDefParseFile(const char *filename); diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 6aa10d89f6..37b84d038a 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -737,7 +737,7 @@ storagePoolCreateXML(virConnectPtr conn, VIR_EXCLUSIVE_FLAGS_RET(VIR_STORAGE_POOL_BUILD_OVERWRITE, VIR_STORAGE_POOL_BUILD_NO_OVERWRITE, NULL); =20 - if (!(newDef =3D virStoragePoolDefParseString(xml))) + if (!(newDef =3D virStoragePoolDefParseString(xml, 0))) goto cleanup; =20 if (virStoragePoolCreateXMLEnsureACL(conn, newDef) < 0) @@ -818,7 +818,7 @@ storagePoolDefineXML(virConnectPtr conn, =20 virCheckFlags(0, NULL); =20 - if (!(newDef =3D virStoragePoolDefParseString(xml))) + if (!(newDef =3D virStoragePoolDefParseString(xml, 0))) goto cleanup; =20 if (virXMLCheckIllegalChars("name", newDef->name, "\n") < 0) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index f60ea870db..33bab0f9d3 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -6645,7 +6645,7 @@ testStoragePoolCreateXML(virConnectPtr conn, virCheckFlags(0, NULL); =20 virObjectLock(privconn); - if (!(newDef =3D virStoragePoolDefParseString(xml))) + if (!(newDef =3D virStoragePoolDefParseString(xml, 0))) goto cleanup; =20 if (!(obj =3D virStoragePoolObjListAdd(privconn->pools, newDef, @@ -6708,7 +6708,7 @@ testStoragePoolDefineXML(virConnectPtr conn, virCheckFlags(0, NULL); =20 virObjectLock(privconn); - if (!(newDef =3D virStoragePoolDefParseString(xml))) + if (!(newDef =3D virStoragePoolDefParseString(xml, 0))) goto cleanup; =20 newDef->capacity =3D defaultPoolCap; --=20 2.31.1 From nobody Thu May 2 22:17:28 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=1629816713; cv=none; d=zohomail.com; s=zohoarc; b=GYvjRhytHPsg2anDHMFwO/Zkox4drwCCB72hHklQQjCu09g3iy08uRGJS8sJa2XjrvlPS3VN0Trtt5YR1cWGwpfG+H48nsQ9bu15Jj8r1kOirUCTLzKHb10DoOZwNusls/wSLfeKE+k2q2vBqZX2yshQV8urhhBnqpQlrX8Jww4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629816713; 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=QAiMR0bojBi2Uz+d0fVtxykBp+lv2j9r+7LnuoGR0NA=; b=atdXgr2vhreS59DkFVLn7V7Ys06WE+/8T4vkuWZ8+79lNOFPiLNjUYde4swgSfW5dWBkI4fk7tFYXODbvEEUBRjpQVLiqT/OlP0Kr6y2hNZgPT0nV/BmPn5w1zh8AEabyCyh1gUROijg/+/so2f/mpMJP2v5jMvzrSykEWH7luM= 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 1629816713467896.8827447376555; Tue, 24 Aug 2021 07:51:53 -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-558-L5Rzt0-kMh-hLN1hOT1uBw-1; Tue, 24 Aug 2021 10:51:50 -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 21FD0838E61; Tue, 24 Aug 2021 14:51:45 +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 076576E0B9; Tue, 24 Aug 2021 14:51:45 +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 AB4105003A; Tue, 24 Aug 2021 14:51:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17OEpXNI007246 for ; Tue, 24 Aug 2021 10:51:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 995D960C82; Tue, 24 Aug 2021 14:51:33 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.43.2.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2390760C0F for ; Tue, 24 Aug 2021 14:51:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629816712; 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=QAiMR0bojBi2Uz+d0fVtxykBp+lv2j9r+7LnuoGR0NA=; b=btJI5XdWwfn/Mtdugmcd5ToVcdXT3j5G+5E0QSSrXrdmmzLL+ydnrhT7CN/1UULkH/aP14 bSh9CpYdxohu/9FZJ3I9lt8qBfutCLpUzUONjkfCK6gdhZ4XdrmW99TpwlMwxof9yGwu57 V5syWQT/UCu9cYrSQ7ILLjMy15PnenY= X-MC-Unique: L5Rzt0-kMh-hLN1hOT1uBw-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 3/4] storage_driver & test_driver: allow VIR_STORAGE_POOL_DEFINE_VALIDATE flag Date: Tue, 24 Aug 2021 16:51:10 +0200 Message-Id: <60145efc00c6911f9056792fe686f36374acca89.1629815312.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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: 1629816715058100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova Reviewed-by: Michal Privoznik --- src/storage/storage_driver.c | 4 ++-- src/test/test_driver.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 37b84d038a..51daf6a05d 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -816,9 +816,9 @@ storagePoolDefineXML(virConnectPtr conn, virObjectEvent *event =3D NULL; g_autoptr(virStoragePoolDef) newDef =3D NULL; =20 - virCheckFlags(0, NULL); + virCheckFlags(VIR_STORAGE_POOL_DEFINE_VALIDATE, NULL); =20 - if (!(newDef =3D virStoragePoolDefParseString(xml, 0))) + if (!(newDef =3D virStoragePoolDefParseString(xml, flags))) goto cleanup; =20 if (virXMLCheckIllegalChars("name", newDef->name, "\n") < 0) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 33bab0f9d3..2f19b7c520 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -6705,10 +6705,10 @@ testStoragePoolDefineXML(virConnectPtr conn, virObjectEvent *event =3D NULL; g_autoptr(virStoragePoolDef) newDef =3D NULL; =20 - virCheckFlags(0, NULL); + virCheckFlags(VIR_STORAGE_POOL_DEFINE_VALIDATE, NULL); =20 virObjectLock(privconn); - if (!(newDef =3D virStoragePoolDefParseString(xml, 0))) + if (!(newDef =3D virStoragePoolDefParseString(xml, flags))) goto cleanup; =20 newDef->capacity =3D defaultPoolCap; --=20 2.31.1 From nobody Thu May 2 22:17:28 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=1629816716; cv=none; d=zohomail.com; s=zohoarc; b=NBIAp0yLSDNNwvAajhOs1pOsaHBdgvy/QLtFttIL7a+Q38Iasnp0jH2KVSvu4LjGLCI4lKQ45vM0HgVkI8A8oVWtEEp0rI1OHpVqBzPMVnVV3PtFrdZ7F6tLbmYjj91npv+Wu1aOqJv8oBKpDfvypwt1/HonGPiINz301Zfw49c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629816716; 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=EkobCs7/3Nnx4EziO5KYoaMWIFX33vGFL+sQCm2+/uI=; b=BoKv5LDSo4BbrKiRnNLBCpDAZtM5NsQ7eTbLlit9WBCSSwEXfQetReCGT33hdLx3JhfJb5JmxfuIBQkxwoeGOC0x5mCqQ0i+Gj3E0edZqWdhky223KaekJNBXtLLd8vvno+cuw1I7PhDTHzI4fHlkQHDWcbg5wQzymsJiQqx+BQ= 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 1629816716196656.7963195842809; Tue, 24 Aug 2021 07:51:56 -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-106-oR4qhJziPeCO5Hz3gweSiQ-1; Tue, 24 Aug 2021 10:51:53 -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 EC106760C5; Tue, 24 Aug 2021 14:51:47 +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 CD3D867899; Tue, 24 Aug 2021 14:51: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 962785003E; Tue, 24 Aug 2021 14:51:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17OEpYGR007254 for ; Tue, 24 Aug 2021 10:51:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 68E3C60C82; Tue, 24 Aug 2021 14:51:34 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.43.2.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id E665260C0F for ; Tue, 24 Aug 2021 14:51:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629816715; 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=EkobCs7/3Nnx4EziO5KYoaMWIFX33vGFL+sQCm2+/uI=; b=An7/XeqCjWClHlC1WrRL1HwontbIr7nfeLI6PSsxxSOcEiDjc8H+HVLzcy1G5QtkA6/+VZ vxCfeCCc3Xyz6rWIINbHlFvw2w7LrP0O6IGZeWHrHWfHnqCoVGJ/AoS99sn/BIwJExXWkp xp3Tvy5IhY6y+FiQOGtaWGDrxsJJsKQ= X-MC-Unique: oR4qhJziPeCO5Hz3gweSiQ-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 4/4] virsh: add support for '--validate' option in define storage pool Date: Tue, 24 Aug 2021 16:51:11 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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: 1629816717482100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova Reviewed-by: Michal Privoznik --- docs/manpages/virsh.rst | 4 +++- tools/virsh-pool.c | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 850a862fd9..2204bed3bb 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -5958,10 +5958,12 @@ pool-define =20 :: =20 - pool-define file + pool-define file [--validate] =20 Define an inactive persistent storage pool or modify an existing persisten= t 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 pool-define-as diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index f0ee95bdf8..1a2ab8cc53 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -520,7 +520,10 @@ static const vshCmdInfo info_pool_define[] =3D { =20 static const vshCmdOptDef opts_pool_define[] =3D { VIRSH_COMMON_OPT_FILE(N_("file containing an XML pool description")), - + {.name =3D "validate", + .type =3D VSH_OT_BOOL, + .help =3D N_("validate the XML against the schema") + }, {.name =3D NULL} }; =20 @@ -531,15 +534,19 @@ cmdPoolDefine(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_STORAGE_POOL_DEFINE_VALIDATE; + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; =20 - pool =3D virStoragePoolDefineXML(priv->conn, buffer, 0); + pool =3D virStoragePoolDefineXML(priv->conn, buffer, flags); =20 if (pool !=3D NULL) { vshPrintExtra(ctl, _("Pool %s defined from %s\n"), --=20 2.31.1