This is to list the secret objects. No flags are supported
include/libvirt/libvirt.h.in: Declare enum virConnectListAllSecretFlags
and virConnectListAllSecrets.
python/generator.py: Skip auto-generating
src/driver.h: (virDrvConnectListAllSecrets)
src/libvirt.c: Implement the public API
src/libvirt_public.syms: Export the symbol to public
---
include/libvirt/libvirt.h.in | 3 ++
python/generator.py | 1 +
src/driver.h | 5 ++++
src/libvirt.c | 50 ++++++++++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 1 +
5 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index aea4d8a..c67c89b 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -3164,6 +3164,9 @@ int virConnectNumOfSecrets (virConnectPtr
conn);
int virConnectListSecrets (virConnectPtr conn,
char **uuids,
int maxuuids);
+int virConnectListAllSecrets(virConnectPtr conn,
+ virSecretPtr **secrets,
+ unsigned int flags);
virSecretPtr virSecretLookupByUUID(virConnectPtr conn,
const unsigned char *uuid);
virSecretPtr virSecretLookupByUUIDString(virConnectPtr conn,
diff --git a/python/generator.py b/python/generator.py
index 00e242f..447ff47 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -462,6 +462,7 @@ skip_function = (
'virConnectListAllInterfaces', # overridden in virConnect.py
'virConnectListAllNodeDevices', # overridden in virConnect.py
'virConnectListAllNWFilters', # overridden in virConnect.py
+ 'virConnectListAllSecrets', # overridden in virConnect.py
'virStreamRecvAll', # Pure python libvirt-override-virStream.py
'virStreamSendAll', # Pure python libvirt-override-virStream.py
diff --git a/src/driver.h b/src/driver.h
index 5ace502..8c1d799 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -1540,6 +1540,10 @@ typedef int
(*virDrvListSecrets) (virConnectPtr conn,
char **uuids,
int maxuuids);
+typedef int
+ (*virDrvListAllSecrets) (virConnectPtr conn,
+ virSecretPtr **secrets,
+ unsigned int flags);
typedef struct _virSecretDriver virSecretDriver;
typedef virSecretDriver *virSecretDriverPtr;
@@ -1561,6 +1565,7 @@ struct _virSecretDriver {
virDrvNumOfSecrets numOfSecrets;
virDrvListSecrets listSecrets;
+ virDrvListAllSecrets listAllSecrets;
virDrvSecretLookupByUUID lookupByUUID;
virDrvSecretLookupByUsage lookupByUsage;
virDrvSecretDefineXML defineXML;
diff --git a/src/libvirt.c b/src/libvirt.c
index ff02c88..009e99f 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -14350,6 +14350,56 @@ error:
}
/**
+ * virConnectListAllSecrets:
+ * @conn: Pointer to the hypervisor connection.
+ * @secrets: Pointer to a variable to store the array containing the secret
+ * objects or NULL if the list is not required (just returns the
+ * number of secrets).
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Collect the list of secrets, and allocate an array to store those objects.
+ *
+ * Returns the number of secrets found or -1 and sets @secrets to NULL in case
+ * of error. On success, the array stored into @secrets is guaranteed to
+ * have an extra allocated element set to NULL but not included in the return count,
+ * to make iteration easier. The caller is responsible for calling
+ * virSecretFree() on each array element, then calling free() on @secrets.
+ */
+int
+virConnectListAllSecrets(virConnectPtr conn,
+ virSecretPtr **secrets,
+ unsigned int flags)
+{
+ VIR_DEBUG("conn=%p, secrets=%p, flags=%x", conn, secrets, flags);
+
+ virResetLastError();
+
+ if (secrets)
+ *secrets = NULL;
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virDispatchError(NULL);
+ return -1;
+ }
+
+ if (conn->secretDriver &&
+ conn->secretDriver->listAllSecrets) {
+ int ret;
+ ret = conn->secretDriver->listAllSecrets(conn, secrets, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ virDispatchError(conn);
+ return -1;
+}
+
+/**
* virConnectListSecrets:
* @conn: virConnect connection
* @uuids: Pointer to an array to store the UUIDs
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index ab5f156..33b6446 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -552,6 +552,7 @@ LIBVIRT_0.9.14 {
virConnectListAllInterfaces;
virConnectListAllNodeDevices;
virConnectListAllNWFilters;
+ virConnectListAllSecrets;
} LIBVIRT_0.9.13;
# .... define new API here using predicted next version number ....
--
1.7.7.3