The various drivers each have vir*EnsureACL and vir*CheckACL API's
which are generated on the fly by gendispatch to include the driver
typed "def" name as the last argument based on the API being checked
and the driver name (e.g. Node, Interface, Secrets, etc.).
Rather than having that name by typed, it's possible to generate the
API prototype using a "void *opaque" argument and then modify the first
line of the code to make the typed def argumment based off the opaque
data. This way we can generalize the ACL typedefs in object parsing
code to just be an opaque type. The next step in that generalization
is to remove the multiple typdef's and replace it with one general
typedef in order to further generalize the various drivers object
and object list handling functions.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/conf/domain_conf.h | 3 +--
src/conf/interface_conf.h | 3 +--
src/conf/network_conf.h | 3 +--
src/conf/node_device_conf.h | 3 +--
src/conf/storage_conf.h | 3 +--
src/conf/virsecretobj.h | 3 +--
src/rpc/gendispatch.pl | 5 ++++-
7 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index dd79206..dd9e43e 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2400,8 +2400,7 @@ struct _virDomainObj {
* restore will be required later */
};
-typedef bool (*virDomainObjListACLFilter)(virConnectPtr conn,
- virDomainDefPtr def);
+typedef bool (*virDomainObjListACLFilter)(virConnectPtr conn, void *opaque);
typedef enum {
diff --git a/src/conf/interface_conf.h b/src/conf/interface_conf.h
index 2523207..1e38412 100644
--- a/src/conf/interface_conf.h
+++ b/src/conf/interface_conf.h
@@ -212,8 +212,7 @@ char *virInterfaceDefFormat(const virInterfaceDef *def);
void virInterfaceObjLock(virInterfaceObjPtr obj);
void virInterfaceObjUnlock(virInterfaceObjPtr obj);
-typedef bool (*virInterfaceObjListFilter)(virConnectPtr conn,
- virInterfaceDefPtr def);
+typedef bool (*virInterfaceObjListFilter)(virConnectPtr conn, void *opaque);
# define VIR_CONNECT_LIST_INTERFACES_FILTERS_ACTIVE \
(VIR_CONNECT_LIST_INTERFACES_ACTIVE | \
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index 9e4ae71..217b548 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -331,8 +331,7 @@ bool virNetworkObjTaint(virNetworkObjPtr obj,
void virNetworkDefFree(virNetworkDefPtr def);
-typedef bool (*virNetworkObjListFilter)(virConnectPtr conn,
- virNetworkDefPtr def);
+typedef bool (*virNetworkObjListFilter)(virConnectPtr conn, void *opaque);
enum {
VIR_NETWORK_OBJ_LIST_ADD_LIVE = (1 << 0),
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
index 1634483..e1cdb1d 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -315,8 +315,7 @@ void virNodeDeviceObjUnlock(virNodeDeviceObjPtr obj);
VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS | \
VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC)
-typedef bool (*virNodeDeviceObjListFilter)(virConnectPtr conn,
- virNodeDeviceDefPtr def);
+typedef bool (*virNodeDeviceObjListFilter)(virConnectPtr conn, void *opaque);
int virNodeDeviceObjListExport(virConnectPtr conn,
virNodeDeviceObjList devobjs,
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index e952f5f..5eda544 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -314,8 +314,7 @@ struct _virStoragePoolSourceList {
virStoragePoolSourcePtr sources;
};
-typedef bool (*virStoragePoolObjListFilter)(virConnectPtr conn,
- virStoragePoolDefPtr def);
+typedef bool (*virStoragePoolObjListFilter)(virConnectPtr conn, void *opaque);
static inline int
virStoragePoolObjIsActive(virStoragePoolObjPtr pool)
diff --git a/src/conf/virsecretobj.h b/src/conf/virsecretobj.h
index fa45b42..673a4c8 100644
--- a/src/conf/virsecretobj.h
+++ b/src/conf/virsecretobj.h
@@ -65,8 +65,7 @@ virSecretObjPtr virSecretObjListAdd(virSecretObjListPtr secrets,
const char *configDir,
virSecretDefPtr *oldDef);
-typedef bool (*virSecretObjListACLFilter)(virConnectPtr conn,
- virSecretDefPtr def);
+typedef bool (*virSecretObjListACLFilter)(virConnectPtr conn, void *opaque);
int virSecretObjListNumOfSecrets(virSecretObjListPtr secrets,
virSecretObjListACLFilter filter,
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index 173189c..12b047b 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -2066,7 +2066,7 @@ elsif ($mode eq "client") {
if ($object eq "StorageVol") {
push @argdecls, "virStoragePoolDefPtr pool";
}
- push @argdecls, "$objecttype $arg";
+ push @argdecls, "void *opaque";
}
if ($checkflags) {
push @argdecls, "unsigned int flags";
@@ -2101,6 +2101,9 @@ elsif ($mode eq "client") {
print "/* Returns: $fail on error/denied, $pass on allowed
*/\n";
print "$ret $apiname(" . join(", ", @argdecls) .
")\n";
print "{\n";
+ if ($object ne "Connect") {
+ print " $objecttype $arg = opaque;\n";
+ }
print " virAccessManagerPtr mgr;\n";
print " int rv;\n";
print "\n";
--
2.7.4