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

[Xen-changelog] [xen master] libxl: Remove/deprecate libxl_get_required_*_memory from the API



commit 5dedc18d64f46d7afb9eb6ce688791cc13f3e059
Author:     Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
AuthorDate: Fri Oct 4 15:36:59 2019 +0100
Commit:     Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
CommitDate: Thu Oct 24 16:08:41 2019 +0100

    libxl: Remove/deprecate libxl_get_required_*_memory from the API
    
    These are now redundant because shadow_memkb and iommu_memkb are now
    defaulted automatically by libxl_domain_need_memory and
    libxl_domain_create etc.  Callers should not now call these; instead,
    they should just let libxl take care of it.
    
    libxl_get_required_shadow_memory was introduced in f89f555827a6
      "remove late (on-demand) construction of IOMMU page tables"
    We can freely remove it because it was never in any release.
    
    libxl_get_required_shadow_memory has been in libxl approximately
    forever.  It should probably not have survived the creation of
    libxl_domain_create, but it seems the API awkwardnesses we see in
    recent commits prevented this.  So we have to keep it.  It remains
    functional but we can deprecate it.  Hopefully we can get rid of it
    completely before we find the need to change the calculation to use
    additional information which its arguments do not currently supply.
    
    Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
    Acked-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
    Release-acked-by: Juergen Gross <jgross@xxxxxxxx>
---
 tools/libxl/libxl_create.c | 17 ++++++++++++++++-
 tools/libxl/libxl_utils.c  | 15 ---------------
 tools/libxl/libxl_utils.h  |  2 +-
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 3b3b6ec381..e4ddfd067f 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -892,6 +892,21 @@ static bool ok_to_default_memkb_in_create(libxl__gc *gc)
      */
 }
 
+static unsigned long libxl__get_required_iommu_memory(unsigned long maxmem_kb)
+{
+    unsigned long iommu_pages = 0, mem_pages = maxmem_kb / 4;
+    unsigned int level;
+
+    /* Assume a 4 level page table with 512 entries per level */
+    for (level = 0; level < 4; level++)
+    {
+        mem_pages = DIV_ROUNDUP(mem_pages, 512);
+        iommu_pages += mem_pages;
+    }
+
+    return iommu_pages * 4;
+}
+
 int libxl__domain_config_setdefault(libxl__gc *gc,
                                     libxl_domain_config *d_config,
                                     uint32_t domid)
@@ -1015,7 +1030,7 @@ int libxl__domain_config_setdefault(libxl__gc *gc,
         && ok_to_default_memkb_in_create(gc))
         d_config->b_info.iommu_memkb =
             (d_config->c_info.passthrough == LIBXL_PASSTHROUGH_SYNC_PT)
-            ? libxl_get_required_iommu_memory(d_config->b_info.max_memkb)
+            ? libxl__get_required_iommu_memory(d_config->b_info.max_memkb)
             : 0;
 
     ret = libxl__domain_build_info_setdefault(gc, &d_config->b_info);
diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
index 405733b7e1..f360f5e228 100644
--- a/tools/libxl/libxl_utils.c
+++ b/tools/libxl/libxl_utils.c
@@ -48,21 +48,6 @@ unsigned long libxl_get_required_shadow_memory(unsigned long 
maxmem_kb, unsigned
     return 4 * (256 * smp_cpus + 2 * (maxmem_kb / 1024));
 }
 
-unsigned long libxl_get_required_iommu_memory(unsigned long maxmem_kb)
-{
-    unsigned long iommu_pages = 0, mem_pages = maxmem_kb / 4;
-    unsigned int level;
-
-    /* Assume a 4 level page table with 512 entries per level */
-    for (level = 0; level < 4; level++)
-    {
-        mem_pages = DIV_ROUNDUP(mem_pages, 512);
-        iommu_pages += mem_pages;
-    }
-
-    return iommu_pages * 4;
-}
-
 char *libxl_domid_to_name(libxl_ctx *ctx, uint32_t domid)
 {
     unsigned int len;
diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h
index 630ccbe28a..46918aea84 100644
--- a/tools/libxl/libxl_utils.h
+++ b/tools/libxl/libxl_utils.h
@@ -24,7 +24,7 @@ const
 char *libxl_basename(const char *name); /* returns string from strdup */
 
 unsigned long libxl_get_required_shadow_memory(unsigned long maxmem_kb, 
unsigned int smp_cpus);
-unsigned long libxl_get_required_iommu_memory(unsigned long maxmem_kb);
+  /* deprecated; see LIBXL_HAVE_DOMAIN_NEED_MEMORY_CONFIG in libxl.h */
 int libxl_name_to_domid(libxl_ctx *ctx, const char *name, uint32_t *domid);
 int libxl_domain_qualifier_to_domid(libxl_ctx *ctx, const char *name, uint32_t 
*domid);
 char *libxl_domid_to_name(libxl_ctx *ctx, uint32_t domid);
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.