[PATCH v2 07/12] libxl: add API wrapper for libxl_domain_need_memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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 {




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux