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@xxxxxxxxx> --- src/libxl/libxl_api_wrapper.h | 19 +++++++++++++++++++ src/libxl/libxl_conf.c | 5 +++-- src/libxl/libxl_domain.c | 4 ++-- tests/libxlmock.c | 7 ++++++- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/libxl/libxl_api_wrapper.h b/src/libxl/libxl_api_wrapper.h index 193f971919..a400bbd5a3 100644 --- a/src/libxl/libxl_api_wrapper.h +++ b/src/libxl/libxl_api_wrapper.h @@ -138,3 +138,22 @@ libxlDomainNeedMemoryWrapper(libxl_ctx *ctx, 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; +} diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 4b6a7e6096..8fe04fd8e0 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -36,6 +36,7 @@ #include "viruuid.h" #include "vircommand.h" #include "virsocketaddr.h" +#include "libxl_api_wrapper.h" #include "libxl_domain.h" #include "libxl_conf.h" #include "libxl_utils.h" @@ -1785,7 +1786,7 @@ libxlDriverConfigNew(void) int libxlDriverConfigInit(libxlDriverConfigPtr cfg) { - unsigned int free_mem; + uint64_t free_mem; if (g_mkdir_with_parents(cfg->logDir, 0777) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1817,7 +1818,7 @@ libxlDriverConfigInit(libxlDriverConfigPtr cfg) /* This will fill xenstore info about free and dom0 memory if missing, * 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")); return -1; } diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index d6554bc230..ac613b96b9 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -1009,7 +1009,7 @@ static int libxlDomainFreeMem(libxl_ctx *ctx, libxl_domain_config *d_config) { uint64_t needed_mem; - uint32_t free_mem; + uint64_t free_mem; int32_t target_mem; int tries = 3; int wait_secs = 10; @@ -1018,7 +1018,7 @@ libxlDomainFreeMem(libxl_ctx *ctx, libxl_domain_config *d_config) goto error; do { - if (libxl_get_free_memory(ctx, &free_mem) < 0) + if (libxlGetFreeMemoryWrapper(ctx, &free_mem) < 0) goto error; if (free_mem >= needed_mem) diff --git a/tests/libxlmock.c b/tests/libxlmock.c index a36ca135f6..604dc4bfbe 100644 --- a/tests/libxlmock.c +++ b/tests/libxlmock.c @@ -67,7 +67,12 @@ VIR_MOCK_IMPL_RET_ARGS(libxl_get_version_info, VIR_MOCK_STUB_RET_ARGS(libxl_get_free_memory, int, 0, 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, int, 0,