[PATCH 1/1] virStorageSource: note that capacity/allocation/physical are stale caches
These three fields are cached values that do not reflect reality unless the caller refreshes them. 'allocation' is in addition ultra-unreliable: any guest write into a previously unallocated part of a sparse image invalidates it, even right after a refresh. Document this on the struct so new callers do not trust the values. Signed-off-by: Denis V. Lunev <den@openvz.org> CC: Peter Krempa <pkrempa@redhat.com> --- src/conf/storage_source_conf.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h index 5ddcebb282..fa71a9ef39 100644 --- a/src/conf/storage_source_conf.h +++ b/src/conf/storage_source_conf.h @@ -326,6 +326,8 @@ struct _virStorageSource { virStoragePerms *perms; virStorageTimestamps *timestamps; + + /* Cached, unreliable. Refresh before use. */ unsigned long long capacity; /* in bytes, 0 if unknown */ unsigned long long allocation; /* in bytes, 0 if unknown */ unsigned long long physical; /* in bytes, 0 if unknown */ -- 2.51.0
On Mon, May 11, 2026 at 23:55:24 +0200, Denis V. Lunev wrote:
These three fields are cached values that do not reflect reality unless the caller refreshes them. 'allocation' is in addition ultra-unreliable: any guest write into a previously unallocated part of a sparse image invalidates it, even right after a refresh.
Document this on the struct so new callers do not trust the values.
Signed-off-by: Denis V. Lunev <den@openvz.org> CC: Peter Krempa <pkrempa@redhat.com> --- src/conf/storage_source_conf.h | 2 ++ 1 file changed, 2 insertions(+)
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
participants (1)
-
Denis V. Lunev -
Peter Krempa