On 3/25/21 10:26 AM, Olaf Hering wrote:
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
Let's hope third time is a charm :-).
Jim
No functional change intended.
Signed-off-by: Olaf Hering <olaf(a)aepfle.de>
---
src/libxl/libxl_api_wrapper.h | 24 ++++++++++++++++++++++++
src/libxl/libxl_domain.c | 4 ++--
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/src/libxl/libxl_api_wrapper.h b/src/libxl/libxl_api_wrapper.h
index 13200cfec6..193f971919 100644
--- a/src/libxl/libxl_api_wrapper.h
+++ b/src/libxl/libxl_api_wrapper.h
@@ -114,3 +114,27 @@ libxlDomainUnpauseWrapper(libxl_ctx *ctx, uint32_t domid)
return ret;
}
+
+#define INVALID_DOMID ~0
+static inline int
+libxlDomainNeedMemoryWrapper(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 a034fe2219..d6554bc230 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 (libxlDomainNeedMemoryWrapper(ctx, d_config, &needed_mem) < 0)
goto error;
do {