mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00: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;
|
virIsDevMapperDevice;
|
||||||
virIsSUID;
|
virIsSUID;
|
||||||
virManageVport;
|
virManageVport;
|
||||||
|
virMemoryLimitIsSet;
|
||||||
|
virMemoryLimitTruncate;
|
||||||
virParseNumber;
|
virParseNumber;
|
||||||
virParseOwnershipIds;
|
virParseOwnershipIds;
|
||||||
virParseVersionString;
|
virParseVersionString;
|
||||||
|
@ -2598,3 +2598,27 @@ long virGetSystemPageSizeKB(void)
|
|||||||
return val;
|
return val;
|
||||||
return val / 1024;
|
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 virGetSystemPageSize(void);
|
||||||
long virGetSystemPageSizeKB(void);
|
long virGetSystemPageSizeKB(void);
|
||||||
|
|
||||||
|
unsigned long long virMemoryLimitTruncate(unsigned long long value);
|
||||||
|
bool virMemoryLimitIsSet(unsigned long long value);
|
||||||
|
|
||||||
#endif /* __VIR_UTIL_H__ */
|
#endif /* __VIR_UTIL_H__ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user