API: discourage usage of non-ListAll APIs

They require the caller to provide the maximum number
of array elements upfront, leading to either incomplete
results or violations of the zero-one-infinity rule.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Ján Tomko 2020-10-05 00:20:27 +02:00
parent c7f3a1f787
commit fb234839a7
8 changed files with 34 additions and 16 deletions

View File

@ -381,8 +381,10 @@ virDomainSnapshotNum(virDomainPtr domain, unsigned int flags)
* snapshots were listed if the return is less than @nameslen. Likewise, * snapshots were listed if the return is less than @nameslen. Likewise,
* you should be prepared for virDomainSnapshotLookupByName() to fail when * you should be prepared for virDomainSnapshotLookupByName() to fail when
* converting a name from this call into a snapshot object, if another * converting a name from this call into a snapshot object, if another
* connection deletes the snapshot in the meantime. For more control over * connection deletes the snapshot in the meantime.
* the results, see virDomainListAllSnapshots(). *
* The use of this function is discouraged. Instead, use
* virDomainListAllSnapshots().
* *
* Returns the number of domain snapshots found or -1 in case of error. * Returns the number of domain snapshots found or -1 in case of error.
* The caller is responsible to call free() for each member of the array. * The caller is responsible to call free() for each member of the array.
@ -582,8 +584,10 @@ virDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot, unsigned int flags)
* snapshots were listed if the return is less than @nameslen. Likewise, * snapshots were listed if the return is less than @nameslen. Likewise,
* you should be prepared for virDomainSnapshotLookupByName() to fail when * you should be prepared for virDomainSnapshotLookupByName() to fail when
* converting a name from this call into a snapshot object, if another * converting a name from this call into a snapshot object, if another
* connection deletes the snapshot in the meantime. For more control over * connection deletes the snapshot in the meantime.
* the results, see virDomainSnapshotListAllChildren(). *
* The use of this function is discouraged. Instead, use
* virDomainSnapshotListAllChildren().
* *
* Returns the number of domain snapshots found or -1 in case of error. * Returns the number of domain snapshots found or -1 in case of error.
* The caller is responsible to call free() for each member of the array. * The caller is responsible to call free() for each member of the array.

View File

@ -41,8 +41,8 @@ VIR_LOG_INIT("libvirt.domain");
* *
* Collect the list of active domains, and store their IDs in array @ids * Collect the list of active domains, and store their IDs in array @ids
* *
* For inactive domains, see virConnectListDefinedDomains(). For more * The use of this function is discouraged. Instead, use
* control over the results, see virConnectListAllDomains(). * virConnectListAllDomains().
* *
* Returns the number of domains found or -1 in case of error. Note that * Returns the number of domains found or -1 in case of error. Note that
* this command is inherently racy; a domain can be started between a * this command is inherently racy; a domain can be started between a
@ -6526,8 +6526,8 @@ virConnectNumOfDefinedDomains(virConnectPtr conn)
* list the defined but inactive domains, stores the pointers to the names * list the defined but inactive domains, stores the pointers to the names
* in @names * in @names
* *
* For active domains, see virConnectListDomains(). For more control over * The use of this function is discouraged. Instead, use
* the results, see virConnectListAllDomains(). * virConnectListAllDomains().
* *
* Returns the number of names provided in the array or -1 in case of error. * Returns the number of names provided in the array or -1 in case of error.
* Note that this command is inherently racy; a domain can be defined between * Note that this command is inherently racy; a domain can be defined between

View File

@ -150,7 +150,8 @@ virConnectNumOfInterfaces(virConnectPtr conn)
* Collect the list of active physical host interfaces, * Collect the list of active physical host interfaces,
* and store their names in @names * and store their names in @names
* *
* For more control over the results, see virConnectListAllInterfaces(). * The use of this function is discouraged. Instead, use
* virConnectListAllInterfaces().
* *
* Returns the number of interfaces found or -1 in case of error. Note that * Returns the number of interfaces found or -1 in case of error. Note that
* this command is inherently racy; a interface can be started between a call * this command is inherently racy; a interface can be started between a call
@ -227,7 +228,8 @@ virConnectNumOfDefinedInterfaces(virConnectPtr conn)
* Collect the list of defined (inactive) physical host interfaces, * Collect the list of defined (inactive) physical host interfaces,
* and store their names in @names. * and store their names in @names.
* *
* For more control over the results, see virConnectListAllInterfaces(). * The use of this function is discouraged. Instead, use
* virConnectListAllInterfaces().
* *
* Returns the number of names provided in the array or -1 in case of error. * Returns the number of names provided in the array or -1 in case of error.
* Note that this command is inherently racy; a interface can be defined between * Note that this command is inherently racy; a interface can be defined between

View File

@ -159,7 +159,8 @@ virConnectNumOfNetworks(virConnectPtr conn)
* *
* Collect the list of active networks, and store their names in @names * Collect the list of active networks, and store their names in @names
* *
* For more control over the results, see virConnectListAllNetworks(). * The use of this function is discouraged. Instead, use
* virConnectListAllNetworks().
* *
* Returns the number of networks found or -1 in case of error. Note that * Returns the number of networks found or -1 in case of error. Note that
* this command is inherently racy; a network can be started between a call * this command is inherently racy; a network can be started between a call
@ -235,7 +236,8 @@ virConnectNumOfDefinedNetworks(virConnectPtr conn)
* *
* list the inactive networks, stores the pointers to the names in @names * list the inactive networks, stores the pointers to the names in @names
* *
* For more control over the results, see virConnectListAllNetworks(). * The use of this function is discouraged. Instead, use
* virConnectListAllNetworks().
* *
* Returns the number of names provided in the array or -1 in case of error. * Returns the number of names provided in the array or -1 in case of error.
* Note that this command is inherently racy; a network can be defined between * Note that this command is inherently racy; a network can be defined between

View File

@ -128,7 +128,8 @@ virConnectListAllNodeDevices(virConnectPtr conn,
* *
* Collect the list of node devices, and store their names in @names * Collect the list of node devices, and store their names in @names
* *
* For more control over the results, see virConnectListAllNodeDevices(). * The use of this function is discouraged. Instead, use
* virConnectListAllNodeDevices().
* *
* If the optional 'cap' argument is non-NULL, then the count * If the optional 'cap' argument is non-NULL, then the count
* will be restricted to devices with the specified capability * will be restricted to devices with the specified capability

View File

@ -117,6 +117,9 @@ virConnectListAllNWFilters(virConnectPtr conn,
* *
* Collect the list of network filters, and store their names in @names * Collect the list of network filters, and store their names in @names
* *
* The use of this function is discouraged. Instead, use
* virConnectListAllNWFilters().
*
* Returns the number of network filters found or -1 in case of error * Returns the number of network filters found or -1 in case of error
*/ */
int int

View File

@ -156,6 +156,9 @@ virConnectListAllSecrets(virConnectPtr conn,
* *
* List UUIDs of defined secrets, store pointers to names in uuids. * List UUIDs of defined secrets, store pointers to names in uuids.
* *
* The use of this function is discouraged. Instead, use
* virConnectListAllSecrets().
*
* Returns the number of UUIDs provided in the array, or -1 on failure. * Returns the number of UUIDs provided in the array, or -1 on failure.
*/ */
int int

View File

@ -179,7 +179,8 @@ virConnectNumOfStoragePools(virConnectPtr conn)
* If there are more than maxnames, the remaining names will be silently * If there are more than maxnames, the remaining names will be silently
* ignored. * ignored.
* *
* For more control over the results, see virConnectListAllStoragePools(). * The use of this function is discouraged. Instead, use
* virConnectListAllStoragePools().
* *
* Returns the number of pools found or -1 in case of error. Note that * Returns the number of pools found or -1 in case of error. Note that
* this command is inherently racy; a pool can be started between a call to * this command is inherently racy; a pool can be started between a call to
@ -259,7 +260,8 @@ virConnectNumOfDefinedStoragePools(virConnectPtr conn)
* If there are more than maxnames, the remaining names will be silently * If there are more than maxnames, the remaining names will be silently
* ignored. * ignored.
* *
* For more control over the results, see virConnectListAllStoragePools(). * The use of this function is discouraged. Instead, use
* virConnectListAllStoragePools().
* *
* Returns the number of names provided in the array or -1 in case of error. * Returns the number of names provided in the array or -1 in case of error.
* Note that this command is inherently racy; a pool can be defined between * Note that this command is inherently racy; a pool can be defined between
@ -1254,7 +1256,8 @@ virStoragePoolNumOfVolumes(virStoragePoolPtr pool)
* Fetch list of storage volume names, limiting to * Fetch list of storage volume names, limiting to
* at most maxnames. * at most maxnames.
* *
* To list the volume objects directly, see virStoragePoolListAllVolumes(). * The use of this function is discouraged. Instead, use
* virStoragePoolListAllVolumes().
* *
* Returns the number of names fetched, or -1 on error * Returns the number of names fetched, or -1 on error
*/ */