]> xenbits.xensource.com Git - libvirt.git/commitdiff
libxl: allow libxl to calculate shadow mem requirements
authorJim Fehlig <jfehlig@suse.com>
Tue, 2 Aug 2016 23:36:34 +0000 (17:36 -0600)
committerJim Fehlig <jfehlig@suse.com>
Wed, 3 Aug 2016 20:07:23 +0000 (14:07 -0600)
Long, long ago before libxl_get_required_shadow_memory() was
made publicly available, its code was copied to the libxl driver
for calculating shadow memory requirements of HVM domains.

Long ago, libxl_get_required_shadow_memory() was exported in
libxl_utils.h and included in xen-devel packages everywhere.

Remove the copied code, which has become stale, and let libxl
provode a proper shadow memory value.

src/libxl/libxl_conf.c

index 13446047d3f91e404a67a2a7929db0437e0a3c63..5202ca12deb3bc19ffadd8cc0e9dce2787ec72fd 100644 (file)
@@ -493,15 +493,10 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
             }
         }
 
-        /*
-         * The following comment and calculation were taken directly from
-         * libxenlight's internal function libxl_get_required_shadow_memory():
-         *
-         * 256 pages (1MB) per vcpu, plus 1 page per MiB of RAM for the P2M map,
-         * plus 1 page per MiB of RAM to shadow the resident processes.
-         */
-        b_info->shadow_memkb = 4 * (256 * libxl_bitmap_count_set(&b_info->avail_vcpus) +
-                                    2 * (b_info->max_memkb / 1024));
+        /* Allow libxl to calculate shadow memory requirements */
+        b_info->shadow_memkb =
+            libxl_get_required_shadow_memory(b_info->max_memkb,
+                                             b_info->max_vcpus);
     } else {
         /*
          * For compatibility with the legacy xen toolstack, default to pygrub