@@ -1637,6 +1637,7 @@ module VM = struct
16371637 {
16381638 Domain. memory_max= vm.memory_static_max /// 1024L
16391639 ; memory_target= vm.memory_dynamic_min /// 1024L
1640+ ; memory_total_source= None
16401641 ; kernel= " "
16411642 ; vcpus= vm.vcpu_max
16421643 ; priv= builder_spec_info
@@ -1747,8 +1748,8 @@ module VM = struct
17471748 in
17481749 (device_id, revision)
17491750
1750- let create_exn task memory_upper_bound vm final_id no_sharept num_of_vbds
1751- num_of_vifs =
1751+ let create_exn task memory_upper_bound memory_total_source vm final_id
1752+ no_sharept num_of_vbds num_of_vifs =
17521753 let k = vm.Vm. id in
17531754 with_xc_and_xs (fun xc xs ->
17541755 (* Ensure the DB contains something for this VM - this is to avoid a
@@ -1821,33 +1822,40 @@ module VM = struct
18211822 needed. If we are live migrating then we will only know an
18221823 upper bound. If we are starting from scratch then we have a
18231824 free choice. *)
1824- let min_bytes, max_bytes =
1825+ let min_bytes, max_bytes, memory_total_source_bytes =
18251826 match memory_upper_bound with
18261827 | Some x ->
18271828 debug " VM = %s; using memory_upper_bound = %Ld" vm.Vm. id x ;
1828- (x, x)
1829+ (x, x, memory_total_source )
18291830 | None ->
18301831 if resuming then (
18311832 debug " VM = %s; using stored suspend_memory_bytes = %Ld"
18321833 vm.Vm. id persistent.VmExtra. suspend_memory_bytes ;
18331834 ( persistent.VmExtra. suspend_memory_bytes
18341835 , persistent.VmExtra. suspend_memory_bytes
1836+ , Some persistent.VmExtra. suspend_memory_bytes
18351837 )
18361838 ) else (
18371839 debug
18381840 " VM = %s; using memory_dynamic_min = %Ld and \
18391841 memory_dynamic_max = %Ld"
18401842 vm.Vm. id vm.memory_dynamic_min vm.memory_dynamic_max ;
1841- (vm.memory_dynamic_min, vm.memory_dynamic_max)
1843+ (vm.memory_dynamic_min, vm.memory_dynamic_max, None )
18421844 )
18431845 in
18441846 let min_kib = kib_of_bytes_used (min_bytes +++ overhead_bytes)
1847+ and memory_total_source_kib =
1848+ Option. map kib_of_bytes_used memory_total_source_bytes
18451849 and max_kib = kib_of_bytes_used (max_bytes +++ overhead_bytes) in
18461850 (* XXX: we would like to be able to cancel an in-progress
18471851 with_reservation *)
18481852 let dbg = Xenops_task. get_dbg task in
18491853 Mem. with_reservation dbg min_kib max_kib
18501854 (fun target_plus_overhead_kib reservation_id ->
1855+ debug
1856+ " VM = %s, memory [%Ld KiB, %Ld KiB], \
1857+ target_plus_overhead=%Ld KiB"
1858+ vm.Vm. id min_kib max_kib target_plus_overhead_kib ;
18511859 let domain_config, persistent =
18521860 match persistent.VmExtra. domain_config with
18531861 | Some dc ->
@@ -1888,8 +1896,26 @@ module VM = struct
18881896 let target_bytes =
18891897 target_plus_overhead_bytes --- overhead_bytes
18901898 in
1899+ debug
1900+ " VM = %s, memory target_bytes = %Ld, dynamic max = %Ld"
1901+ vm.Vm. id target_bytes vm.memory_dynamic_max ;
18911902 min vm.memory_dynamic_max target_bytes
18921903 in
1904+ let persistent =
1905+ match persistent with
1906+ | {VmExtra. build_info = Some x ; _} as t ->
1907+ {
1908+ t with
1909+ build_info=
1910+ Some
1911+ {
1912+ x with
1913+ memory_total_source= memory_total_source_kib
1914+ }
1915+ }
1916+ | _ ->
1917+ persistent
1918+ in
18931919 set_initial_target ~xs domid (Int64. div initial_target 1024L ) ;
18941920 (* Log uses of obsolete option *)
18951921 if vm.suppress_spurious_page_faults then
@@ -2367,6 +2393,7 @@ module VM = struct
23672393 {
23682394 Domain. memory_max= static_max_kib
23692395 ; memory_target= initial_target
2396+ ; memory_total_source= None
23702397 ; kernel
23712398 ; vcpus= vm.vcpu_max
23722399 ; priv
@@ -3005,6 +3032,7 @@ module VM = struct
30053032 | _ ->
30063033 " "
30073034 in
3035+ debug " VM = %s, initial_target = %Ld" vm.Vm. id initial_target ;
30083036 ({x with Domain. memory_target= initial_target}, timeoffset)
30093037 in
30103038 let vtpm = vtpm_of ~vm in
@@ -3144,7 +3172,10 @@ module VM = struct
31443172 let memory_actual =
31453173 let pages = Int64. of_nativeint di.Xenctrl. total_memory_pages in
31463174 let kib = Xenctrl. pages_to_kib pages in
3147- Memory. bytes_of_kib kib
3175+ let bytes = Memory. bytes_of_kib kib in
3176+ D. debug " VM %s memory actual: %Ld pages = %Ld KiB = %Ld bytes"
3177+ (Uuidm. to_string uuid) pages kib bytes ;
3178+ bytes
31483179 in
31493180 let memory_limit =
31503181 (* The maximum amount of memory the domain can consume is the max
@@ -3167,7 +3198,10 @@ module VM = struct
31673198 in
31683199 (* CA-31764: may be larger than static_max if maxmem has been
31693200 increased to initial-reservation. *)
3170- max memory_actual max_memory_bytes
3201+ let result = max memory_actual max_memory_bytes in
3202+ D. debug " VM %s memory limit = %Ld bytes" (Uuidm. to_string uuid)
3203+ result ;
3204+ result
31713205 in
31723206 let rtc =
31733207 try
0 commit comments