@@ -888,6 +888,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)
@@ -1011,7 +1026,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);
@@ -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;
@@ -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);