Upcoming changes will use different LIBXL_API_VERSION variants.
Prepare libxl_set_memory_target, which changed the storage size of
parameter "target_memkb" in Xen 4.8.
No functional change intended.
Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
#pragma once
+#include <limits.h>
#include <libxl.h>
static inline int
return ret;
}
+
+static inline int
+libxlSetMemoryTargetWrapper(libxl_ctx *ctx,
+ uint32_t domid,
+ uint64_t target_memkb,
+ int relative,
+ int enforce)
+{
+ int ret = -1;
+
+ /* Technically this guard could be LIBXL_HAVE_MEMKB_64BITS */
+#if LIBXL_API_VERSION < 0x040800
+ if (target_memkb < UINT_MAX) {
+ uint32_t val32 = target_memkb;
+
+ ret = libxl_set_memory_target(ctx, domid, val32, relative, enforce);
+ }
+#else
+ if (target_memkb < LLONG_MAX) {
+ int64_t val64 = target_memkb;
+ ret = libxl_set_memory_target(ctx, domid, val64, relative, enforce);
+ }
+#endif
+
+ return ret;
+}
{
uint64_t needed_mem;
uint64_t free_mem;
- int32_t target_mem;
+ uint64_t target_mem;
int tries = 3;
int wait_secs = 10;
return 0;
target_mem = free_mem - needed_mem;
- if (libxl_set_memory_target(ctx, 0, target_mem,
- /* relative */ 1, 0) < 0)
+ if (libxlSetMemoryTargetWrapper(ctx, 0, target_mem,
+ /* relative */ 1, 0) < 0)
goto error;
if (libxl_wait_for_memory_target(ctx, 0, wait_secs) < 0)
/* Unlock virDomainObj while ballooning memory */
virObjectUnlock(vm);
- res = libxl_set_memory_target(cfg->ctx, vm->def->id, newmem, 0,
- /* force */ 1);
+ res = libxlSetMemoryTargetWrapper(cfg->ctx, vm->def->id, newmem, 0,
+ /* force */ 1);
virObjectLock(vm);
if (res < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,