On 8/20/21 1:57 PM, Kristina Hanicova wrote: > This new API function allows to define nwfilter with given flags. > > Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx> > --- > 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-nwfilter.h > index 44ca1b3fae..041b1fc33b 100644 > --- a/include/libvirt/libvirt-nwfilter.h > +++ b/include/libvirt/libvirt-nwfilter.h > @@ -85,6 +85,9 @@ virNWFilterPtr virNWFilterLookupByUUIDString (virConnectPtr conn, > */ > virNWFilterPtr virNWFilterDefineXML (virConnectPtr conn, > const char *xmlDesc); > +virNWFilterPtr virNWFilterDefineXMLFlags(virConnectPtr conn, > + const char *xmlDesc, > + unsigned int flags); > > /* > * 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); > > +typedef virNWFilterPtr > +(*virDrvNWFilterDefineXMLFlags)(virConnectPtr conn, > + const char *xmlDesc, > + unsigned int flags); > + > typedef int > (*virDrvNWFilterUndefine)(virNWFilterPtr nwfilter); > > @@ -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 *xmlDesc) > } > > > +/** > + * 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, unsigned int flags) > +{ > + VIR_DEBUG("conn=%p, xmlDesc=%s", conn, NULLSTR(xmlDesc)); The @flags should be included in the debug printing too. > + > + virResetLastError(); > + > + virCheckFlags(0, NULL); This isn't a good idea. It stops client from sending a flag they don't know, true. But ultimately it's the server (nwfilter driver) where we want to validate @flags because a client can be talking to newer/older server which in general supports different set of flags. Just drop this line. Michal