From nobody Fri May 3 18:30:48 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=1629460870; cv=none; d=zohomail.com; s=zohoarc; b=XhTOBeOg8SexUgT/ig15d+iwuuQsmO+76YA7ZeoSfuOu2B0tmyci9dSylmrGks0c8DpbnOA1Zgk7K5MdDnfbpfsiKoq5HbwJSM/rlCNEw7CNXcJxd/l0zg2MdbvlSFLKkWtH6C8vCemp+C+fJeylHFo2Pa4ecm5rpyE47Tasgs0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629460870; 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=g/LiEqH7prF7/8Ao8RJmenwmZqbcglGz814H2xAIcRY=; b=U4Jeo76cr1yP/2Vt0ctx8j2JfveY3AssfDyF0sLIICcaA00jq1v3XFDja9SiMJV0tZPD223Liik/EFeb8WCHLWx8wkkfAaSWVmpCZGjySCOkX9xw/RHJWVxzkDH3YkI3G+HOS/P3dGC7iEVqojZeYxI/wZFRiSFlKiwmzZxw6Zg= 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 1629460870458411.356379651299; Fri, 20 Aug 2021 05:01:10 -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-586-iYq57lCpPmSh3OGhOBYq1Q-1; Fri, 20 Aug 2021 08:01:07 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9C721802929; Fri, 20 Aug 2021 12:01:02 +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 122D71B49E; Fri, 20 Aug 2021 12:01:02 +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 7EAF4181A2A6; Fri, 20 Aug 2021 12:01:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17KBvawm007817 for ; Fri, 20 Aug 2021 07:57:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id C779B1B5C0; Fri, 20 Aug 2021 11:57:36 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BC9A1B49E for ; Fri, 20 Aug 2021 11:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629460869; 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=g/LiEqH7prF7/8Ao8RJmenwmZqbcglGz814H2xAIcRY=; b=Pjk33o3Gw/0MUo3lEdAso5/F2iA6eGswnicC0Zaw0mXK3xUvSxdLNCFOo/EzV0UMyTKjsq BpTwbYWEkaYvu+rEdM/4wJ4xtBXerTP6lX9RoDo/xvuYdg9Zq1Lm194HoxUtZ+cFzpxlOg esoDCbVpaEkbVPdv6xAafgRJeTDvwVI= X-MC-Unique: iYq57lCpPmSh3OGhOBYq1Q-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 1/6] api: add public virNWFilterDefineXMLFlags() and remote protocol Date: Fri, 20 Aug 2021 13:57:05 +0200 Message-Id: <4ecdcb9ead6ab3dbfb60e7709e36be0eeab13cf2.1629460370.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.13 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: 1629460872180100001 Content-Type: text/plain; charset="utf-8" This new API function allows to define nwfilter with given flags. Signed-off-by: Kristina Hanicova Reviewed-by: Michal Privoznik --- include/libvirt/libvirt-nwfilter.h | 3 +++ src/driver-nwfilter.h | 6 +++++ src/libvirt-nwfilter.c | 43 ++++++++++++++++++++++++++++++ src/libvirt_public.syms | 5 ++++ src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 18 ++++++++++++- src/remote_protocol-structs | 8 ++++++ 7 files changed, 83 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-nwfilter.h b/include/libvirt/libvirt-n= wfilter.h index 44ca1b3fae..041b1fc33b 100644 --- a/include/libvirt/libvirt-nwfilter.h +++ b/include/libvirt/libvirt-nwfilter.h @@ -85,6 +85,9 @@ virNWFilterPtr virNWFilterLookupByUUIDString (vi= rConnectPtr conn, */ virNWFilterPtr virNWFilterDefineXML (virConnectPtr conn, const char *xmlDesc); +virNWFilterPtr virNWFilterDefineXMLFlags(virConnectPtr conn, + const char *xmlDesc, + unsigned int flags); =20 /* * Delete persistent nwfilter diff --git a/src/driver-nwfilter.h b/src/driver-nwfilter.h index fd76e3af84..1ec591ece9 100644 --- a/src/driver-nwfilter.h +++ b/src/driver-nwfilter.h @@ -49,6 +49,11 @@ typedef virNWFilterPtr (*virDrvNWFilterDefineXML)(virConnectPtr conn, const char *xmlDesc); =20 +typedef virNWFilterPtr +(*virDrvNWFilterDefineXMLFlags)(virConnectPtr conn, + const char *xmlDesc, + unsigned int flags); + typedef int (*virDrvNWFilterUndefine)(virNWFilterPtr nwfilter); =20 @@ -98,6 +103,7 @@ struct _virNWFilterDriver { virDrvNWFilterLookupByName nwfilterLookupByName; virDrvNWFilterLookupByUUID nwfilterLookupByUUID; virDrvNWFilterDefineXML nwfilterDefineXML; + virDrvNWFilterDefineXMLFlags nwfilterDefineXMLFlags; virDrvNWFilterUndefine nwfilterUndefine; virDrvNWFilterGetXMLDesc nwfilterGetXMLDesc; virDrvConnectListAllNWFilterBindings connectListAllNWFilterBindings; diff --git a/src/libvirt-nwfilter.c b/src/libvirt-nwfilter.c index e299385895..c5c53327d3 100644 --- a/src/libvirt-nwfilter.c +++ b/src/libvirt-nwfilter.c @@ -406,6 +406,49 @@ virNWFilterDefineXML(virConnectPtr conn, const char *x= mlDesc) } =20 =20 +/** + * virNWFilterDefineXMLFlags: + * @conn: pointer to the hypervisor connection + * @xmlDesc: an XML description of the nwfilter + * @flags: extra flags; not used yet, so callers should always pass 0 + * + * Define a new network filter, based on an XML description + * similar to the one returned by virNWFilterGetXMLDesc() + * + * virNWFilterFree should be used to free the resources after the + * nwfilter object is no longer needed. + * + * Returns a new nwfilter object or NULL in case of failure + */ +virNWFilterPtr +virNWFilterDefineXMLFlags(virConnectPtr conn, const char *xmlDesc, unsigne= d int flags) +{ + VIR_DEBUG("conn=3D%p, xmlDesc=3D%s", conn, NULLSTR(xmlDesc)); + + virResetLastError(); + + virCheckFlags(0, NULL); + + virCheckConnectReturn(conn, NULL); + virCheckNonNullArgGoto(xmlDesc, error); + virCheckReadOnlyGoto(conn->flags, error); + + if (conn->nwfilterDriver && conn->nwfilterDriver->nwfilterDefineXMLFla= gs) { + virNWFilterPtr ret; + ret =3D conn->nwfilterDriver->nwfilterDefineXMLFlags(conn, xmlDesc= , flags); + if (!ret) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(conn); + return NULL; +} + + /** * virNWFilterUndefine: * @nwfilter: a nwfilter object diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 5678a13cda..68f5e9c900 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -896,4 +896,9 @@ LIBVIRT_7.3.0 { virNodeDeviceCreate; } LIBVIRT_7.2.0; =20 +LIBVIRT_7.7.0 { + global: + virNWFilterDefineXMLFlags; +} LIBVIRT_7.3.0; + # .... define new API here using predicted next version number .... diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index c03c68ec30..9ee22e7e15 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8680,6 +8680,7 @@ static virNWFilterDriver nwfilter_driver =3D { .nwfilterLookupByName =3D remoteNWFilterLookupByName, /* 0.8.0 */ .nwfilterGetXMLDesc =3D remoteNWFilterGetXMLDesc, /* 0.8.0 */ .nwfilterDefineXML =3D remoteNWFilterDefineXML, /* 0.8.0 */ + .nwfilterDefineXMLFlags =3D remoteNWFilterDefineXMLFlags, /* 7.7= .0 */ .nwfilterUndefine =3D remoteNWFilterUndefine, /* 0.8.0 */ .connectNumOfNWFilters =3D remoteConnectNumOfNWFilters, /* 0.8.0= */ .connectListNWFilters =3D remoteConnectListNWFilters, /* 0.8.0 = */ diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index de69704b68..56f610839e 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -1627,6 +1627,15 @@ struct remote_nwfilter_define_xml_ret { remote_nonnull_nwfilter nwfilter; }; =20 +struct remote_nwfilter_define_xml_flags_args { + remote_nonnull_string xml; + unsigned int flags; +}; + +struct remote_nwfilter_define_xml_flags_ret { + remote_nonnull_nwfilter nwfilter; +}; + struct remote_nwfilter_undefine_args { remote_nonnull_nwfilter nwfilter; }; @@ -6784,6 +6793,13 @@ enum remote_procedure { * @priority: high * @acl: node_device:start */ - REMOTE_PROC_NODE_DEVICE_CREATE =3D 430 + REMOTE_PROC_NODE_DEVICE_CREATE =3D 430, =20 + /** + * @generate: both + * @priority: high + * @acl: nwfilter:write + * @acl: nwfilter:save + */ + REMOTE_PROC_NWFILTER_DEFINE_XML_FLAGS =3D 431 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 6b46328adc..d51f12f781 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -1174,6 +1174,13 @@ struct remote_nwfilter_define_xml_args { struct remote_nwfilter_define_xml_ret { remote_nonnull_nwfilter nwfilter; }; +struct remote_nwfilter_define_xml_flags_args { + remote_nonnull_string xml; + u_int flags; +}; +struct remote_nwfilter_define_xml_flags_ret { + remote_nonnull_nwfilter nwfilter; +}; struct remote_nwfilter_undefine_args { remote_nonnull_nwfilter nwfilter; }; @@ -3623,4 +3630,5 @@ enum remote_procedure { REMOTE_PROC_NODE_DEVICE_DEFINE_XML =3D 428, REMOTE_PROC_NODE_DEVICE_UNDEFINE =3D 429, REMOTE_PROC_NODE_DEVICE_CREATE =3D 430, + REMOTE_PROC_NWFILTER_DEFINE_XML_FLAGS =3D 431, }; --=20 2.31.1 From nobody Fri May 3 18:30:48 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=1629461134; cv=none; d=zohomail.com; s=zohoarc; b=Yy1OX9K3pb9cA0RAZDeHN80bexYdwKK+nFn+RpObmfDN/rV1opXheAVewF5ur/r3J3fR2MwVo7sxrI9NAqGKdQl365DjbERPlFiRKC5Yb9D7Znm6qDrasPTvVBxk8r/82OuG598l8/dVJPM4nGgmeVo3oQuolCpwbnQKmdx0O/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629461134; 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=IrSLxZ6wLigV/TpPSWfVbREd4FTsrOAZ/mA0vRJ2TJ4=; b=SZrmbui+MrPvWAPqstcswSa9+mPZdlkCiQMKqh4pFDiPHO/ORsxrNhFWjbpB7MpJ86ymAu9Y4OpkwLmxaGg2WhuppMv3KgpyMOsT8zzoXKc8dNdJJQrYsM9xVDAB0pjkyWsXCl9gaHoYJdIqxE99drDyZ7xokJ7aadXp0ADeg+Y= 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 1629461134245162.02932050730112; Fri, 20 Aug 2021 05:05:34 -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-231-nooQeQ37P6-vFVZGtNSZTw-1; Fri, 20 Aug 2021 08:05:31 -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 50F83EC1A7; Fri, 20 Aug 2021 12:05:26 +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 366E5189BB; Fri, 20 Aug 2021 12:05:26 +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 021984BB7C; Fri, 20 Aug 2021 12:05:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17KBvbXb007822 for ; Fri, 20 Aug 2021 07:57:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 955B1226E7; Fri, 20 Aug 2021 11:57:37 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FA901B49E for ; Fri, 20 Aug 2021 11:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629461133; 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=IrSLxZ6wLigV/TpPSWfVbREd4FTsrOAZ/mA0vRJ2TJ4=; b=cBr2X1/+X5j0xA8ZqkgTcs0VvDGzSW/aeI5CjpC2yxtuuH/FPIdmEXimVdEvy6+/HOOs73 MqRPlitZYoRdW028tKKtFGxNGlGykJTgYXbvCZHGTLUpCHdJ5CrG5WumOS6Oj12FEct6fJ hOZ1MRFY6n7f4IJeswO8AEZd9YHzaxo= X-MC-Unique: nooQeQ37P6-vFVZGtNSZTw-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 2/6] nwfilter: add nwfilterDefineXMLFlags() Date: Fri, 20 Aug 2021 13:57:06 +0200 Message-Id: <61561df0e774125696ad40d275745504ffe32b6c.1629460370.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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: 1629461135611100001 Content-Type: text/plain; charset="utf-8" I have added a new driver function which allows to define nwfilter with given flags. I have also replaced definition of nwfilterDefineXML() with function call to the new function. Signed-off-by: Kristina Hanicova Reviewed-by: Michal Privoznik --- src/nwfilter/nwfilter_driver.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index edb284aa4b..4b355ffff1 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -525,9 +525,11 @@ nwfilterConnectListAllNWFilters(virConnectPtr conn, return ret; } =20 + static virNWFilterPtr -nwfilterDefineXML(virConnectPtr conn, - const char *xml) +nwfilterDefineXMLFlags(virConnectPtr conn, + const char *xml, + unsigned int flags) { virNWFilterDef *def; virNWFilterObj *obj =3D NULL; @@ -540,13 +542,15 @@ nwfilterDefineXML(virConnectPtr conn, return NULL; } =20 + virCheckFlags(0, NULL); + nwfilterDriverLock(); virNWFilterWriteLockFilterUpdates(); =20 if (!(def =3D virNWFilterDefParseString(xml))) goto cleanup; =20 - if (virNWFilterDefineXMLEnsureACL(conn, def) < 0) + if (virNWFilterDefineXMLFlagsEnsureACL(conn, def) < 0) goto cleanup; =20 if (!(obj =3D virNWFilterObjListAssignDef(driver->nwfilters, def))) @@ -572,6 +576,14 @@ nwfilterDefineXML(virConnectPtr conn, } =20 =20 +static virNWFilterPtr +nwfilterDefineXML(virConnectPtr conn, + const char *xml) +{ + return nwfilterDefineXMLFlags(conn, xml, 0); +} + + static int nwfilterUndefine(virNWFilterPtr nwfilter) { @@ -809,6 +821,7 @@ static virNWFilterDriver nwfilterDriver =3D { .nwfilterLookupByName =3D nwfilterLookupByName, /* 0.8.0 */ .nwfilterLookupByUUID =3D nwfilterLookupByUUID, /* 0.8.0 */ .nwfilterDefineXML =3D nwfilterDefineXML, /* 0.8.0 */ + .nwfilterDefineXMLFlags =3D nwfilterDefineXMLFlags, /* 7.7.0 */ .nwfilterUndefine =3D nwfilterUndefine, /* 0.8.0 */ .nwfilterGetXMLDesc =3D nwfilterGetXMLDesc, /* 0.8.0 */ .nwfilterBindingLookupByPortDev =3D nwfilterBindingLookupByPortDev, /*= 4.5.0 */ --=20 2.31.1 From nobody Fri May 3 18:30:48 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=1629460881; cv=none; d=zohomail.com; s=zohoarc; b=Nl9ZEBGCzyDd98wNF+dzeAK1p4IM3X1ZoULHgrTJ9HdOcOmwOYAN4FUqME8D8VILVBtfbAn5u0s23y1QoiK1BvrDfXhP2n0L28vbaFcn7jaDEX+nIDsU2bo+ZqNS/oSS2DnCYMpbLaBdnu5q6Xyg47kOTLGJtYiPgFS3QGXwPYQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629460881; 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=GoNN2rFk1zRZky/rrn6ohyMQ1jFFq/haZ3AFn2u3ebY=; b=aZ9jifkJrX8cIN98I8C8UBI9QJEOpCdbYuMAUIF0QEmQcr7XdEcpburLofDErDZ3Ugf3uF4NSJI8OlKDkVu/XMp+eJ73hJY5oq07oSEJf7rRK2tbL/413ChIv/wLJbO53TyboAhkwu/AhQndarawjul+17HjLfIIPLLG79bmpKA= 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 162946088178925.387721205697176; Fri, 20 Aug 2021 05:01:21 -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-426-Ea9MCZ9GMkugZ8x23m1YPw-1; Fri, 20 Aug 2021 08:01:18 -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 D331987D543; Fri, 20 Aug 2021 12:01:13 +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 B74022C175; Fri, 20 Aug 2021 12:01:13 +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 5B1F2181A2A7; Fri, 20 Aug 2021 12:01:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17KBvcQQ007839 for ; Fri, 20 Aug 2021 07:57:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 636BB6A057; Fri, 20 Aug 2021 11:57:38 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id E1E221B49E for ; Fri, 20 Aug 2021 11:57:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629460880; 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=GoNN2rFk1zRZky/rrn6ohyMQ1jFFq/haZ3AFn2u3ebY=; b=NLS0ycl7E5LYkM4VfWNqpH8gdTzjNYD+74oelI6VTIwr17Kw/XS2iXfKXkJkElbuxwzsXB mQUssWKcr+q31OCqZhxubjkdMYQI35KuXstSuXuZGr+FzXQuFNy977HkU0H0Byq6LZtNJU PyJFvD0CvtXlg/vT7Hq7V3Fu12J95EQ= X-MC-Unique: Ea9MCZ9GMkugZ8x23m1YPw-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 3/6] api: add virNWFilterDefineFlags Date: Fri, 20 Aug 2021 13:57:07 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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: 1629460884295100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova Reviewed-by: Michal Privoznik --- include/libvirt/libvirt-nwfilter.h | 4 ++++ src/libvirt-nwfilter.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/libvirt/libvirt-nwfilter.h b/include/libvirt/libvirt-n= wfilter.h index 041b1fc33b..9897df6df6 100644 --- a/include/libvirt/libvirt-nwfilter.h +++ b/include/libvirt/libvirt-nwfilter.h @@ -80,6 +80,10 @@ virNWFilterPtr virNWFilterLookupByUUID (v= irConnectPtr conn, virNWFilterPtr virNWFilterLookupByUUIDString (virConnectPtr conn, const char *uuid); =20 +typedef enum { + VIR_NWFILTER_DEFINE_VALIDATE =3D 1 << 0, /* Validate the XML document = against schema */ +} virNWFilterDefineFlags; + /* * Define persistent nwfilter */ diff --git a/src/libvirt-nwfilter.c b/src/libvirt-nwfilter.c index c5c53327d3..ca4dddf89e 100644 --- a/src/libvirt-nwfilter.c +++ b/src/libvirt-nwfilter.c @@ -410,7 +410,7 @@ virNWFilterDefineXML(virConnectPtr conn, const char *xm= lDesc) * virNWFilterDefineXMLFlags: * @conn: pointer to the hypervisor connection * @xmlDesc: an XML description of the nwfilter - * @flags: extra flags; not used yet, so callers should always pass 0 + * @flags: bitwise-OR of virNWFilterDefineFlags * * Define a new network filter, based on an XML description * similar to the one returned by virNWFilterGetXMLDesc() @@ -427,7 +427,7 @@ virNWFilterDefineXMLFlags(virConnectPtr conn, const cha= r *xmlDesc, unsigned int =20 virResetLastError(); =20 - virCheckFlags(0, NULL); + virCheckFlags(VIR_NWFILTER_DEFINE_VALIDATE, NULL); =20 virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(xmlDesc, error); --=20 2.31.1 From nobody Fri May 3 18:30:48 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=1629460999; cv=none; d=zohomail.com; s=zohoarc; b=RHc85sss2vApMRpDZi1FlfPluOKBFolMmtI3I921i9HS6k5sm6BDGtoUaKVbdI+PZG43nVLB0o9+ybohOlBqLdiB7LnULPoMcRqrHe8Wuj96EQmNYgmcC2jul/xsbcA3mrAbdl39FGArg/tSCe9/XMhULbF0oVy+QtDIUBBXNfo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629460999; 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=dxfwOYb8pZZ9FaZ4jjqyMVotTm2qnLPSuAbbH+v+8pk=; b=f9jmOX84jHPrgu0bSCnjn4PTZIrxLrrv6i07VkXx1abxONrDPiIugeV7reHefoekpahj2NTS+e002CVuxWknmVtEDHTkb53/oqWCHxPqyF62S5IzIN1Mq/xQdVNujebqyMfhwNLB73HtRvtfJWi0Tf/F0t/YVhaai1uhTIrVR60= 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 1629460999366491.84783370675734; Fri, 20 Aug 2021 05:03:19 -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-351-76js2W4JO72W-jYA6cEHVw-1; Fri, 20 Aug 2021 08:01:22 -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 A57831026211; Fri, 20 Aug 2021 12:01:17 +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 8127A1346F; Fri, 20 Aug 2021 12:01:17 +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 3F365181A2A8; Fri, 20 Aug 2021 12:01:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17KBvd5b007846 for ; Fri, 20 Aug 2021 07:57:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 30B6A6A057; Fri, 20 Aug 2021 11:57:39 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFD0E1B49E for ; Fri, 20 Aug 2021 11:57:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629460998; 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=dxfwOYb8pZZ9FaZ4jjqyMVotTm2qnLPSuAbbH+v+8pk=; b=Smj4WjcdWW+9GTzJAEqGXXSVjMLZhWuSwSP0GZDI4bkgqkIuKWahjJgN8mpDGFMev1LoW0 P1RZxv+fciMfFAp3SQ7M50y/2bcu50p6yTR8eoUo75Wlok05yxluG44S91Fq5214WGz570 KWk5d6tRpbDt+neZolO4Eed0eiDbj0Y= X-MC-Unique: 76js2W4JO72W-jYA6cEHVw-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 4/6] nwfilter_conf: add validation against schema in define Date: Fri, 20 Aug 2021 13:57:08 +0200 Message-Id: <2be98f58a71bb43090b5bb5bc76f667e4fcdc787.1629460370.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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: 1629460999849100001 Content-Type: text/plain; charset="utf-8" This patch also includes propagation of flags into the virNWFilterDefParse(). Signed-off-by: Kristina Hanicova Reviewed-by: Michal Privoznik --- src/conf/nwfilter_conf.c | 13 ++++++++----- src/conf/nwfilter_conf.h | 3 ++- src/nwfilter/nwfilter_driver.c | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 7d491e27b1..a3109962af 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2739,12 +2739,14 @@ virNWFilterDefParseNode(xmlDocPtr xml, =20 static virNWFilterDef * virNWFilterDefParse(const char *xmlStr, - const char *filename) + const char *filename, + unsigned int flags) { virNWFilterDef *def =3D NULL; g_autoptr(xmlDoc) xml =3D NULL; =20 - if ((xml =3D virXMLParse(filename, xmlStr, _("(nwfilter_definition)"),= NULL, false))) { + if ((xml =3D virXMLParse(filename, xmlStr, _("(nwfilter_definition)"),= "nwfilter.rng", + flags & VIR_NWFILTER_DEFINE_VALIDATE))) { def =3D virNWFilterDefParseNode(xml, xmlDocGetRootElement(xml)); } =20 @@ -2753,16 +2755,17 @@ virNWFilterDefParse(const char *xmlStr, =20 =20 virNWFilterDef * -virNWFilterDefParseString(const char *xmlStr) +virNWFilterDefParseString(const char *xmlStr, + unsigned int flags) { - return virNWFilterDefParse(xmlStr, NULL); + return virNWFilterDefParse(xmlStr, NULL, flags); } =20 =20 virNWFilterDef * virNWFilterDefParseFile(const char *filename) { - return virNWFilterDefParse(NULL, filename); + return virNWFilterDefParse(NULL, filename, 0); } =20 =20 diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h index 8d5684eb4e..bbe12284a5 100644 --- a/src/conf/nwfilter_conf.h +++ b/src/conf/nwfilter_conf.h @@ -546,7 +546,8 @@ virNWFilterSaveConfig(const char *configDir, virNWFilterDef *def); =20 virNWFilterDef * -virNWFilterDefParseString(const char *xml); +virNWFilterDefParseString(const char *xml, + unsigned int flags); =20 virNWFilterDef * virNWFilterDefParseFile(const char *filename); diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 4b355ffff1..4cfdd42a37 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -547,7 +547,7 @@ nwfilterDefineXMLFlags(virConnectPtr conn, nwfilterDriverLock(); virNWFilterWriteLockFilterUpdates(); =20 - if (!(def =3D virNWFilterDefParseString(xml))) + if (!(def =3D virNWFilterDefParseString(xml, 0))) goto cleanup; =20 if (virNWFilterDefineXMLFlagsEnsureACL(conn, def) < 0) --=20 2.31.1 From nobody Fri May 3 18:30:48 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=1629460912; cv=none; d=zohomail.com; s=zohoarc; b=LKTsP2aRDNF1kKRLYJjeaqjaZGlzM48PQiBZNnG+TQk5Hva7XqmmHq8jo57C6EqPz858rHAfDmqr3cSQ8VNWuzD+7ndGObGSoPr2b5te+YBFBG+Yzmz5aNZbkyxQIG3Rn+vLK40vOIiuNT5V9FahZXQW6eKGtXTdkiQT4qpl35o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629460912; 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=xZB03yxl8sHgjPCdD3sz+Vk2cj+L0FF9gL4vfzZDo20=; b=YCEibmLe3OQyrbZLMDHRBCLGtpMvEOpwgbGV/ABUJnyHS42+Pxt+mnAJUKzjne7v1l2C4P9fNGurDIiQQJ3xzOmg5+qGejUmeglz26K56cYpK2cwFr3Lf7X1WzPB+llKmZgW7am40VKLF5kSsZtlqkoYOGyktAb+wDswjSpde1I= 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 1629460912780311.31498153996165; Fri, 20 Aug 2021 05:01:52 -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-593-Kft4wRqSNkCVMfOKPBe4SQ-1; Fri, 20 Aug 2021 08:01:49 -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 7619C102620A; Fri, 20 Aug 2021 12:01:44 +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 5009F1017CE7; Fri, 20 Aug 2021 12:01:44 +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 196F24BB7C; Fri, 20 Aug 2021 12:01:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17KBveXu007854 for ; Fri, 20 Aug 2021 07:57:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id F2A7D6EF4F; Fri, 20 Aug 2021 11:57:39 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D1651B49E for ; Fri, 20 Aug 2021 11:57:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629460911; 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=xZB03yxl8sHgjPCdD3sz+Vk2cj+L0FF9gL4vfzZDo20=; b=P2NtP5UtIzr/2fpeSsyviCXrgOMaJ0tvKYgGsx0V6UM/RJYVPJN78rvSo5paTxIsl203Yj HaG+L8GrnYEOk1eeTb/jTBILuEU7qdBSl8a7oR/uSZkDIUdhX6bfHvZeiG59ZTQLWi2Nf2 JnJkG8kvgqPXHLuLtlo7kONaZEaLmvE= X-MC-Unique: Kft4wRqSNkCVMfOKPBe4SQ-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 5/6] nwfilter_driver: allow VIR_NWFILTER_DEFINE_VALIDATE flag Date: Fri, 20 Aug 2021 13:57:09 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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: 1629460913992100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova Reviewed-by: Michal Privoznik --- src/nwfilter/nwfilter_driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 4cfdd42a37..d38c5b78e3 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -542,12 +542,12 @@ nwfilterDefineXMLFlags(virConnectPtr conn, return NULL; } =20 - virCheckFlags(0, NULL); + virCheckFlags(VIR_NWFILTER_DEFINE_VALIDATE, NULL); =20 nwfilterDriverLock(); virNWFilterWriteLockFilterUpdates(); =20 - if (!(def =3D virNWFilterDefParseString(xml, 0))) + if (!(def =3D virNWFilterDefParseString(xml, flags))) goto cleanup; =20 if (virNWFilterDefineXMLFlagsEnsureACL(conn, def) < 0) --=20 2.31.1 From nobody Fri May 3 18:30:48 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=1629461137; cv=none; d=zohomail.com; s=zohoarc; b=MsWrlqUzgS4G8a0STNzpVLPcT2gVKmbZc9MuCH5PqtoQWgigateqYgHUMeczECJZgggNCpkX5js4+NFh7yhXMr2/jHLDtAro+sxgC8xyeK3suT9j6Uk8/qO8Vkt+DfUgR5lC9LTS/kESLHjVvVBxNSx7YMHM1v/ImIxrji2WlUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629461137; 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=Nb0/0cKfL/lfYHM7KucA2Z91Mra98E9+fljASo7RraE=; b=iCz5EFE9ZaDlT5jrYEudciQbbWETWa1n+ikLTYN6oZeqE5pWYu+IbJD0ZjlfgDOG2FtfpjDUuQA8Cd4zdW4fzcNuzUYLDFq+MkIx4I89jwa0dB/G6IKzRSyg2ktI7mslPZBY2c4rgYhz9Dg0WmJNvmrZpHnudiXHJlThdM/gL6U= 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 1629461137421835.3059614373924; Fri, 20 Aug 2021 05:05:37 -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-588-1Zf5AgrMMw2XLW501t4t3A-1; Fri, 20 Aug 2021 08:05:34 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4401B802935; Fri, 20 Aug 2021 12:05:29 +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 1F2546A907; Fri, 20 Aug 2021 12:05:29 +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 E098E4A7CA; Fri, 20 Aug 2021 12:05:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17KBveQO007864 for ; Fri, 20 Aug 2021 07:57:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id C04E76EF4F; Fri, 20 Aug 2021 11:57:40 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AD4A1B49E for ; Fri, 20 Aug 2021 11:57:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629461136; 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=Nb0/0cKfL/lfYHM7KucA2Z91Mra98E9+fljASo7RraE=; b=FvgtILXaYGrvrnRuOxLyS3wsZrBMwAFjsPu4b7SN6LLL8anYf/clAubAbC4rbBQiMNRSUL s+d0uUCKBdu+7CnIDCL2UezEIYwcz6mnkFE7c9Y1FQawk4+YMyoAUoWWaBVZc+9pvWBOui iGaEi6y+ucjSjJw/RGwx/f5Ai2BMh1k= X-MC-Unique: 1Zf5AgrMMw2XLW501t4t3A-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 6/6] virsh: add support for '--validate' option in define nwfilter Date: Fri, 20 Aug 2021 13:57:10 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.15 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: 1629461138182100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova Reviewed-by: Michal Privoznik --- docs/manpages/virsh.rst | 5 ++++- tools/virsh-nwfilter.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 3eb310d02e..0326a7d015 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -7483,7 +7483,7 @@ nwfilter-define =20 :: =20 - nwfilter-define xmlfile + nwfilter-define xmlfile [--validate] =20 Make a new network filter known to libvirt. If a network filter with the same name already exists, it will be replaced with the new XML. @@ -7492,6 +7492,9 @@ its network traffic rules adapted. If for any reason = the network traffic filtering rules cannot be instantiated by any of the running virtual machines, then the new XML will be rejected. =20 +Optionally, the format of the input XML file can be validated against an +internal RNG schema with *--validate*. + =20 nwfilter-undefine ----------------- diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index f38f33798d..e062aa1649 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -81,6 +81,10 @@ static const vshCmdInfo info_nwfilter_define[] =3D { static const vshCmdOptDef opts_nwfilter_define[] =3D { VIRSH_COMMON_OPT_FILE(N_("file containing an XML network " "filter description")), + {.name =3D "validate", + .type =3D VSH_OT_BOOL, + .help =3D N_("validate the XML against the schema") + }, {.name =3D NULL} }; =20 @@ -91,15 +95,22 @@ cmdNWFilterDefine(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_NWFILTER_DEFINE_VALIDATE; + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; =20 - nwfilter =3D virNWFilterDefineXML(priv->conn, buffer); + if (flags) + nwfilter =3D virNWFilterDefineXMLFlags(priv->conn, buffer, flags); + else + nwfilter =3D virNWFilterDefineXML(priv->conn, buffer); =20 if (nwfilter !=3D NULL) { vshPrintExtra(ctl, _("Network filter %s defined from %s\n"), --=20 2.31.1