Upcoming changes will use different LIBXL_API_VERSION variants.
Prepare libxl_domain_need_memory, which changed the storage size of
"need_memkb" in Xen 4.8. With Xen 4.12 the libxl_domain_config
parameter was changed
No functional change intended.
Signed-off-by: Olaf Hering <olaf(a)aepfle.de>
---
src/libxl/libxl_api.h | 24 ++++++++++++++++++++++++
src/libxl/libxl_domain.c | 4 ++--
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/src/libxl/libxl_api.h b/src/libxl/libxl_api.h
index 86d2d64b37..5c1545c3c0 100644
--- a/src/libxl/libxl_api.h
+++ b/src/libxl/libxl_api.h
@@ -114,3 +114,27 @@ Libxl_Domain_Unpause(libxl_ctx *ctx, uint32_t domid)
return ret;
}
+
+#define INVALID_DOMID ~0
+static inline int
+Libxl_Domain_Need_Memory(libxl_ctx *ctx,
+ libxl_domain_config *d_config,
+ uint64_t *need_memkb)
+{
+ int ret;
+
+#if LIBXL_API_VERSION < 0x040800
+ {
+ uint32_t val32 = 0;
+
+ ret = libxl_domain_need_memory(ctx, &d_config->b_info, &val32);
+ *need_memkb = val32;
+ }
+#elif LIBXL_API_VERSION < 0x041300
+ ret = libxl_domain_need_memory(ctx, &d_config->b_info, need_memkb);
+#else
+ ret = libxl_domain_need_memory(ctx, d_config, INVALID_DOMID, need_memkb);
+#endif
+
+ return ret;
+}
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 6eca7027eb..337764b5c7 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -1008,13 +1008,13 @@ libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver,
virDomainObjPtr vm)
static int
libxlDomainFreeMem(libxl_ctx *ctx, libxl_domain_config *d_config)
{
- uint32_t needed_mem;
+ uint64_t needed_mem;
uint32_t free_mem;
int32_t target_mem;
int tries = 3;
int wait_secs = 10;
- if (libxl_domain_need_memory(ctx, &d_config->b_info, &needed_mem) < 0)
+ if (Libxl_Domain_Need_Memory(ctx, d_config, &needed_mem) < 0)
goto error;
do {