[libvirt] [PATCH] nwfilter: drop unused flag argument

The public API has no flags argument, so neither should the internal callback API. This simplifies the RPC generator. * src/driver.h (virDrvNWFilterDefineXML): Drop argument that does not match public API. * src/nwfilter/nwfilter_driver.c (nwfilterDefine): Likewise. * src/libvirt.c (virNWFilterDefineXML): Likewise. * daemon/remote_generator.pl: Drop special case. --- The comment in the generator was a bit off - the public API had no flags argument, just the internal callback API. daemon/remote_generator.pl | 6 ------ src/driver.h | 3 +-- src/libvirt.c | 2 +- src/nwfilter/nwfilter_driver.c | 6 +++--- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl index bce6261..c53ebc8 100755 --- a/daemon/remote_generator.pl +++ b/daemon/remote_generator.pl @@ -879,12 +879,6 @@ elsif ($opt_k) { push(@args_list, "virConnectPtr conn"); } - if ($call->{ProcName} eq "NWFilterDefineXML") { - # SPECIAL: virNWFilterDefineXML has a flags parameter in the - # public API that is missing in the XDR protocol - push(@args_list, "unsigned int flags ATTRIBUTE_UNUSED"); - } - # fix priv_name for the NumOf* functions if ($priv_name eq "privateData" and !($call->{ProcName} =~ m/(Domains|DomainSnapshot)/) and diff --git a/src/driver.h b/src/driver.h index 5cd0cea..ea80701 100644 --- a/src/driver.h +++ b/src/driver.h @@ -1181,8 +1181,7 @@ typedef virNWFilterPtr const unsigned char *uuid); typedef virNWFilterPtr (*virDrvNWFilterDefineXML) (virConnectPtr conn, - const char *xmlDesc, - unsigned int flags); + const char *xmlDesc); typedef int (*virDrvNWFilterUndefine) (virNWFilterPtr nwfilter); diff --git a/src/libvirt.c b/src/libvirt.c index 0726df4..7564db0 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -12253,7 +12253,7 @@ virNWFilterDefineXML(virConnectPtr conn, const char *xmlDesc) if (conn->nwfilterDriver && conn->nwfilterDriver->defineXML) { virNWFilterPtr ret; - ret = conn->nwfilterDriver->defineXML (conn, xmlDesc, 0); + ret = conn->nwfilterDriver->defineXML (conn, xmlDesc); if (!ret) goto error; return ret; diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 17af7a6..18ea752 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -2,7 +2,7 @@ * nwfilter_driver.c: core driver for network filter APIs * (based on storage_driver.c) * - * Copyright (C) 2006-2010 Red Hat, Inc. + * Copyright (C) 2006-2011 Red Hat, Inc. * Copyright (C) 2006-2008 Daniel P. Berrange * Copyright (C) 2010 IBM Corporation * Copyright (C) 2010 Stefan Berger @@ -327,8 +327,8 @@ nwfilterListNWFilters(virConnectPtr conn, static virNWFilterPtr nwfilterDefine(virConnectPtr conn, - const char *xml, - unsigned int flags ATTRIBUTE_UNUSED) { + const char *xml) +{ virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData; virNWFilterDefPtr def; virNWFilterObjPtr nwfilter = NULL; -- 1.7.4.4

On 05/11/2011 06:32 PM, Eric Blake wrote:
The public API has no flags argument, so neither should the internal callback API. This simplifies the RPC generator.
* src/driver.h (virDrvNWFilterDefineXML): Drop argument that does not match public API. * src/nwfilter/nwfilter_driver.c (nwfilterDefine): Likewise. * src/libvirt.c (virNWFilterDefineXML): Likewise. * daemon/remote_generator.pl: Drop special case. ---
The comment in the generator was a bit off - the public API had no flags argument, just the internal callback API.
daemon/remote_generator.pl | 6 ------ src/driver.h | 3 +-- src/libvirt.c | 2 +- src/nwfilter/nwfilter_driver.c | 6 +++--- 4 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl index bce6261..c53ebc8 100755 --- a/daemon/remote_generator.pl +++ b/daemon/remote_generator.pl @@ -879,12 +879,6 @@ elsif ($opt_k) { push(@args_list, "virConnectPtr conn"); }
- if ($call->{ProcName} eq "NWFilterDefineXML") { - # SPECIAL: virNWFilterDefineXML has a flags parameter in the - # public API that is missing in the XDR protocol - push(@args_list, "unsigned int flags ATTRIBUTE_UNUSED"); - } - # fix priv_name for the NumOf* functions if ($priv_name eq "privateData" and !($call->{ProcName} =~ m/(Domains|DomainSnapshot)/) and diff --git a/src/driver.h b/src/driver.h index 5cd0cea..ea80701 100644 --- a/src/driver.h +++ b/src/driver.h @@ -1181,8 +1181,7 @@ typedef virNWFilterPtr const unsigned char *uuid); typedef virNWFilterPtr (*virDrvNWFilterDefineXML) (virConnectPtr conn, - const char *xmlDesc, - unsigned int flags); + const char *xmlDesc); typedef int (*virDrvNWFilterUndefine) (virNWFilterPtr nwfilter);
diff --git a/src/libvirt.c b/src/libvirt.c index 0726df4..7564db0 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -12253,7 +12253,7 @@ virNWFilterDefineXML(virConnectPtr conn, const char *xmlDesc)
if (conn->nwfilterDriver&& conn->nwfilterDriver->defineXML) { virNWFilterPtr ret; - ret = conn->nwfilterDriver->defineXML (conn, xmlDesc, 0); + ret = conn->nwfilterDriver->defineXML (conn, xmlDesc); if (!ret) goto error; return ret; diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 17af7a6..18ea752 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -2,7 +2,7 @@ * nwfilter_driver.c: core driver for network filter APIs * (based on storage_driver.c) * - * Copyright (C) 2006-2010 Red Hat, Inc. + * Copyright (C) 2006-2011 Red Hat, Inc. * Copyright (C) 2006-2008 Daniel P. Berrange * Copyright (C) 2010 IBM Corporation * Copyright (C) 2010 Stefan Berger @@ -327,8 +327,8 @@ nwfilterListNWFilters(virConnectPtr conn,
static virNWFilterPtr nwfilterDefine(virConnectPtr conn, - const char *xml, - unsigned int flags ATTRIBUTE_UNUSED) { + const char *xml) +{ virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData; virNWFilterDefPtr def; virNWFilterObjPtr nwfilter = NULL; I assume this causes not interoperability problems between libvirt versions. I initially introduced the flag because other define functions had it also and thought I'd leave the option of having flags open.
ACK Stefan

On 05/11/2011 06:16 PM, Stefan Berger wrote:
On 05/11/2011 06:32 PM, Eric Blake wrote:
The public API has no flags argument, so neither should the internal callback API. This simplifies the RPC generator.
static virNWFilterPtr nwfilterDefine(virConnectPtr conn, - const char *xml, - unsigned int flags ATTRIBUTE_UNUSED) { + const char *xml) +{ virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData; virNWFilterDefPtr def; virNWFilterObjPtr nwfilter = NULL; I assume this causes not interoperability problems between libvirt versions. I initially introduced the flag because other define functions had it also and thought I'd leave the option of having flags open.
For a single libvirt binary, there are no issues (the driver code is linked privately, and we are allowed to change the API of anything in libvirt_private.syms without impact to public interfaces). And between libvirt binaries, we have the fortunate situation that the over-the-wire protocol didn't pass a flags argument. Thus, when calling the API, you had this scenario: virNWFilterDefineXML(no flags) -> remote callback(0 flag) -> RPC over-wire format (no flags) -> virNWFilterDefineXML(no flags) -> nwfilter callback (0 flag) Removing the flag argument means that every step along the path has the same number of arguments, all without having to invent or ignore a 0 flag argument, and without any externally visible changes. And when mixing an older server with a newer client, or a newer client with an older server, then the older side will still be passing and ignoring an extra argument internally, with no change in behavior. Meanwhile, the only way to use a flags argument is to introduce a new API; if and when we introduce a new virNWFilterDefineXMLFlags(), we will also introduce a new RPC call that also preserves that flags argument over the wire. Whether we then change the driver.h callback to re-add a flags argument at that time, and share the callback between both APIs, or whether we have two driver.h callbacks, is a choice we can make at that time.
ACK
Thanks; I've gone ahead and pushed this (I wrote it on top of Matthias' generator whitelist patch, and had worried that it might not rebase well, but thankfully it worked without a hitch). -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Stefan Berger