mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-01 06:27:16 +00:00
libxl: add API wrapper for libxl_set_memory_target
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>
This commit is contained in:
parent
4d6e2c0f89
commit
8bc6a55f1b
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
#include <libxl.h>
|
#include <libxl.h>
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
@ -188,3 +189,29 @@ libxlSendTriggerWrapper(libxl_ctx *ctx,
|
|||||||
|
|
||||||
return ret;
|
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;
|
||||||
|
}
|
||||||
|
@ -1010,7 +1010,7 @@ libxlDomainFreeMem(libxl_ctx *ctx, libxl_domain_config *d_config)
|
|||||||
{
|
{
|
||||||
uint64_t needed_mem;
|
uint64_t needed_mem;
|
||||||
uint64_t free_mem;
|
uint64_t free_mem;
|
||||||
int32_t target_mem;
|
uint64_t target_mem;
|
||||||
int tries = 3;
|
int tries = 3;
|
||||||
int wait_secs = 10;
|
int wait_secs = 10;
|
||||||
|
|
||||||
@ -1025,8 +1025,8 @@ libxlDomainFreeMem(libxl_ctx *ctx, libxl_domain_config *d_config)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
target_mem = free_mem - needed_mem;
|
target_mem = free_mem - needed_mem;
|
||||||
if (libxl_set_memory_target(ctx, 0, target_mem,
|
if (libxlSetMemoryTargetWrapper(ctx, 0, target_mem,
|
||||||
/* relative */ 1, 0) < 0)
|
/* relative */ 1, 0) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (libxl_wait_for_memory_target(ctx, 0, wait_secs) < 0)
|
if (libxl_wait_for_memory_target(ctx, 0, wait_secs) < 0)
|
||||||
|
@ -1695,8 +1695,8 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
|
|||||||
|
|
||||||
/* Unlock virDomainObj while ballooning memory */
|
/* Unlock virDomainObj while ballooning memory */
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
res = libxl_set_memory_target(cfg->ctx, vm->def->id, newmem, 0,
|
res = libxlSetMemoryTargetWrapper(cfg->ctx, vm->def->id, newmem, 0,
|
||||||
/* force */ 1);
|
/* force */ 1);
|
||||||
virObjectLock(vm);
|
virObjectLock(vm);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
Loading…
Reference in New Issue
Block a user