-
由 Daniel P. Berrange 提交于
The virConnectPtr struct will cache instances of all other objects. APIs like virDomainLookupByUUID will return a cached object, so if you do virDomainLookupByUUID twice in a row, you'll get the same exact virDomainPtr instance. This does not have any performance benefit, since the actual logic in virDomainLookupByUUID (and other APIs returning virDomainPtr, etc instances) is not short-circuited. All it does is to ensure there is only one single virDomainPtr in existance for any given UUID. The caching has a number of downsides though, all relating to stale data. If APIs aren't careful to always overwrite the 'id' field in virDomainPtr it may become out of data. Likewise for the name field, if a guest is renamed, or if a guest is deleted, and then a new one created with the same UUID but different name. This has been an ongoing, endless source of bugs for all applications using libvirt from languages with garbage collection, causing them to get virDomainPtr instances from long ago with stale data. The caching is also a waste of memory resources, since both applications, and language bindings often maintain their own hashtable caches of object instances. This patch removes all the hash table caching, so all APIs return brand new virDomainPtr (etc) object instances. * src/datatypes.h: Delete all hash tables. * src/datatypes.c: Remove all object caching code
2ff4c137