mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-09 23:15:51 -06:00
virutil: introduce helper functions for memory limits
The first one is to truncate the memory limit to VIR_DOMAIN_MEMORY_PARAM_UNLIMITED if the value is greater and the second one is to decide whether the memory limit is set or not, unlimited means that it's not set. Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
c2020b08ce
commit
a73395ae66
@ -2270,6 +2270,8 @@ virIsCapableVport;
|
||||
virIsDevMapperDevice;
|
||||
virIsSUID;
|
||||
virManageVport;
|
||||
virMemoryLimitIsSet;
|
||||
virMemoryLimitTruncate;
|
||||
virParseNumber;
|
||||
virParseOwnershipIds;
|
||||
virParseVersionString;
|
||||
|
@ -2598,3 +2598,27 @@ long virGetSystemPageSizeKB(void)
|
||||
return val;
|
||||
return val / 1024;
|
||||
}
|
||||
|
||||
/**
|
||||
* virMemoryLimitTruncate
|
||||
*
|
||||
* Return truncated memory limit to VIR_DOMAIN_MEMORY_PARAM_UNLIMITED as maximum
|
||||
* which means that the limit is not set => unlimited.
|
||||
*/
|
||||
unsigned long long
|
||||
virMemoryLimitTruncate(unsigned long long value)
|
||||
{
|
||||
return value < VIR_DOMAIN_MEMORY_PARAM_UNLIMITED ? value :
|
||||
VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
|
||||
}
|
||||
|
||||
/**
|
||||
* virMemoryLimitIsSet
|
||||
*
|
||||
* Returns true if the limit is set and false for unlimited value.
|
||||
*/
|
||||
bool
|
||||
virMemoryLimitIsSet(unsigned long long value)
|
||||
{
|
||||
return value < VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
|
||||
}
|
||||
|
@ -247,4 +247,7 @@ unsigned int virGetListenFDs(void);
|
||||
long virGetSystemPageSize(void);
|
||||
long virGetSystemPageSizeKB(void);
|
||||
|
||||
unsigned long long virMemoryLimitTruncate(unsigned long long value);
|
||||
bool virMemoryLimitIsSet(unsigned long long value);
|
||||
|
||||
#endif /* __VIR_UTIL_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user