mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
libxl: add API wrapper for libxl_get_free_memory
Upcoming changes will use different LIBXL_API_VERSION variants. Prepare libxl_get_free_memory, which changed storage size of parameter "memkb" in Xen 4.8. No functional change intended. Signed-off-by: Olaf Hering <olaf@aepfle.de> Reviewed-by: Jim Fehlig <jfehlig@suse.com>
This commit is contained in:
parent
0acd258e2e
commit
e8fd24d810
@ -138,3 +138,22 @@ libxlDomainNeedMemoryWrapper(libxl_ctx *ctx,
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
libxlGetFreeMemoryWrapper(libxl_ctx *ctx, uint64_t *memkb)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
#if LIBXL_API_VERSION < 0x040800
|
||||||
|
{
|
||||||
|
uint32_t val32 = 0;
|
||||||
|
|
||||||
|
ret = libxl_get_free_memory(ctx, &val32);
|
||||||
|
*memkb = val32;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
ret = libxl_get_free_memory(ctx, memkb);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "viruuid.h"
|
#include "viruuid.h"
|
||||||
#include "vircommand.h"
|
#include "vircommand.h"
|
||||||
#include "virsocketaddr.h"
|
#include "virsocketaddr.h"
|
||||||
|
#include "libxl_api_wrapper.h"
|
||||||
#include "libxl_domain.h"
|
#include "libxl_domain.h"
|
||||||
#include "libxl_conf.h"
|
#include "libxl_conf.h"
|
||||||
#include "libxl_utils.h"
|
#include "libxl_utils.h"
|
||||||
@ -1778,7 +1779,7 @@ libxlDriverConfigNew(void)
|
|||||||
int
|
int
|
||||||
libxlDriverConfigInit(libxlDriverConfigPtr cfg)
|
libxlDriverConfigInit(libxlDriverConfigPtr cfg)
|
||||||
{
|
{
|
||||||
unsigned int free_mem;
|
uint64_t free_mem;
|
||||||
|
|
||||||
if (g_mkdir_with_parents(cfg->logDir, 0777) < 0) {
|
if (g_mkdir_with_parents(cfg->logDir, 0777) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
@ -1810,7 +1811,7 @@ libxlDriverConfigInit(libxlDriverConfigPtr cfg)
|
|||||||
|
|
||||||
/* This will fill xenstore info about free and dom0 memory if missing,
|
/* This will fill xenstore info about free and dom0 memory if missing,
|
||||||
* should be called before starting first domain */
|
* should be called before starting first domain */
|
||||||
if (libxl_get_free_memory(cfg->ctx, &free_mem)) {
|
if (libxlGetFreeMemoryWrapper(cfg->ctx, &free_mem)) {
|
||||||
VIR_ERROR(_("Unable to configure libxl's memory management parameters"));
|
VIR_ERROR(_("Unable to configure libxl's memory management parameters"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1009,7 +1009,7 @@ static int
|
|||||||
libxlDomainFreeMem(libxl_ctx *ctx, libxl_domain_config *d_config)
|
libxlDomainFreeMem(libxl_ctx *ctx, libxl_domain_config *d_config)
|
||||||
{
|
{
|
||||||
uint64_t needed_mem;
|
uint64_t needed_mem;
|
||||||
uint32_t free_mem;
|
uint64_t free_mem;
|
||||||
int32_t target_mem;
|
int32_t target_mem;
|
||||||
int tries = 3;
|
int tries = 3;
|
||||||
int wait_secs = 10;
|
int wait_secs = 10;
|
||||||
@ -1018,7 +1018,7 @@ libxlDomainFreeMem(libxl_ctx *ctx, libxl_domain_config *d_config)
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (libxl_get_free_memory(ctx, &free_mem) < 0)
|
if (libxlGetFreeMemoryWrapper(ctx, &free_mem) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (free_mem >= needed_mem)
|
if (free_mem >= needed_mem)
|
||||||
|
@ -67,7 +67,12 @@ VIR_MOCK_IMPL_RET_ARGS(libxl_get_version_info,
|
|||||||
VIR_MOCK_STUB_RET_ARGS(libxl_get_free_memory,
|
VIR_MOCK_STUB_RET_ARGS(libxl_get_free_memory,
|
||||||
int, 0,
|
int, 0,
|
||||||
libxl_ctx *, ctx,
|
libxl_ctx *, ctx,
|
||||||
uint32_t *, memkb);
|
# if LIBXL_API_VERSION < 0x040800
|
||||||
|
uint32_t *,
|
||||||
|
# else
|
||||||
|
uint64_t *,
|
||||||
|
# endif
|
||||||
|
memkb);
|
||||||
|
|
||||||
VIR_MOCK_STUB_RET_ARGS(xc_interface_close,
|
VIR_MOCK_STUB_RET_ARGS(xc_interface_close,
|
||||||
int, 0,
|
int, 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user