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@eu.citrix.com>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
*/
}
+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)
&& 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);
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;
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);