Skip to content

Commit 10e4264

Browse files
committed
CP-18289 record platform:{nomigrate,nested_virt} in VmExtra state
We store the values of the two platform flags in persistent data and recall it when reporting the state of the VM via xcp-idl. This code has been manually tested with an updated xenopsd/xapi * A running or suspended VM receives the default values for nomigrate and nested_virt when xenopsd is updated. * Xenopsd stores the values of platform:nomigrate, platform:nested_virt in the meta data at boot time but does not pick up changes to these value later in the lifecycle of the VM. Signed-off-by: Christian Lindig <[email protected]>
1 parent 5d6a8fa commit 10e4264

File tree

3 files changed

+80
-2
lines changed

3 files changed

+80
-2
lines changed

lib/xenops_utils.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,8 @@ let halted_vm = {
548548
last_start_time = 0.;
549549
shadow_multiplier_target = 1.;
550550
hvm = false;
551+
nomigrate=false;
552+
nested_virt=false;
551553
}
552554

553555
let unplugged_pci = {

xc/xenops_server_xen.ml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,25 @@ module VmExtra = struct
8484
build_info: Domain.build_info option;
8585
ty: Vm.builder_info option;
8686
last_start_time: float;
87+
nomigrate: bool; (* platform:nomigrate at boot time *)
88+
nested_virt: bool (* platform:nested_virt at boot time *)
8789
} with rpc
8890

91+
let default_persistent_t =
92+
{ build_info = None
93+
; ty = None
94+
; last_start_time = 0.0
95+
; nomigrate = false
96+
; nested_virt = false
97+
}
98+
99+
(* override rpc code generated for persistent_t. It is important that
100+
* this code is before the declaration of type t because otherwise
101+
* the rpc code for type t won't use it. *)
102+
let persistent_t_of_rpc rpc =
103+
Rpc.struct_extend rpc (rpc_of_persistent_t default_persistent_t)
104+
|> persistent_t_of_rpc
105+
89106
type non_persistent_t = {
90107
create_info: Domain.create_info;
91108
vcpu_max: int;
@@ -759,6 +776,8 @@ module VM = struct
759776
(* Earlier than the PV drivers update time, therefore
760777
any cached PV driver information will be kept. *)
761778
last_start_time = 0.;
779+
nomigrate = false;
780+
nested_virt = false
762781
} |> VmExtra.rpc_of_persistent_t |> Jsonrpc.to_string
763782

764783
let mkints n =
@@ -855,7 +874,19 @@ module VM = struct
855874
x.VmExtra.persistent, x.VmExtra.non_persistent
856875
| None -> begin
857876
debug "VM = %s; has no stored domain-level configuration, regenerating" vm.Vm.id;
858-
let persistent = { VmExtra.build_info = None; ty = None; last_start_time = Unix.gettimeofday ()} in
877+
let persistent =
878+
{ VmExtra.build_info = None
879+
; ty = None
880+
; last_start_time = Unix.gettimeofday ()
881+
; nomigrate = Platform.is_true
882+
~key:"nomigrate"
883+
~platformdata:vm.Xenops_interface.Vm.platformdata
884+
~default:false
885+
; nested_virt=Platform.is_true
886+
~key:"nested_virt"
887+
~platformdata:vm.Xenops_interface.Vm.platformdata
888+
~default:false
889+
} in
859890
let non_persistent = generate_non_persistent_state xc xs vm in
860891
persistent, non_persistent
861892
end in
@@ -1638,6 +1669,14 @@ module VM = struct
16381669
end;
16391670
hvm = di.Xenctrl.hvm_guest;
16401671
shadow_multiplier_target = shadow_multiplier_target;
1672+
nomigrate = begin match vme with
1673+
| None -> false
1674+
| Some x -> x.VmExtra.persistent.VmExtra.nomigrate
1675+
end;
1676+
nested_virt = begin match vme with
1677+
| None -> false
1678+
| Some x -> x.VmExtra.persistent.VmExtra.nested_virt
1679+
end
16411680
}
16421681
)
16431682

xl/xenops_server_xenlight.ml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ module VmExtra = struct
236236
build_info: Domain.build_info option;
237237
ty: Vm.builder_info option;
238238
last_start_time: float;
239+
nomigrate: bool; (* platform:nomigrate at boot time *)
240+
nested_virt: bool (* platform:nested_virt at boot time *)
239241
} with rpc
240242

241243
type non_persistent_t = {
@@ -256,6 +258,19 @@ module VmExtra = struct
256258
persistent: persistent_t;
257259
non_persistent: non_persistent_t;
258260
} with rpc
261+
262+
let default_persistent_t =
263+
{ build_info = None
264+
; ty = None
265+
; last_start_time = 0.0
266+
; nomigrate = false
267+
; nested_virt = false
268+
}
269+
270+
(* override rpc code generated for persistent_t *)
271+
let persistent_t_of_rpc rpc =
272+
Rpc.struct_extend rpc (rpc_of_persistent_t default_persistent_t)
273+
|> persistent_t_of_rpc
259274
end
260275

261276
module DB = struct
@@ -1793,6 +1808,8 @@ module VM = struct
17931808
(* Earlier than the PV drivers update time, therefore
17941809
any cached PV driver information will be kept. *)
17951810
last_start_time = 0.;
1811+
nomigrate = false;
1812+
nested_virt = false
17961813
} |> VmExtra.rpc_of_persistent_t |> Jsonrpc.to_string
17971814

17981815
(* Could use fold_left to get the same value, but that would necessarily go through the whole list everytime, instead of the first n items, only. *)
@@ -2087,7 +2104,19 @@ module VM = struct
20872104
x.VmExtra.persistent, x.VmExtra.non_persistent
20882105
| None -> begin
20892106
debug "VM = %s; has no stored domain-level configuration, regenerating" vm.Vm.id;
2090-
let persistent = { VmExtra.build_info = None; ty = None; last_start_time = Unix.gettimeofday () } in
2107+
let persistent =
2108+
{ VmExtra.build_info = None
2109+
; ty = None
2110+
; last_start_time = Unix.gettimeofday ()
2111+
; nomigrate = Platform.is_true
2112+
~key:"nomigrate"
2113+
~platformdata:vm.Xenops_interface.Vm.platformdata
2114+
~default:false
2115+
; nested_virt=Platform.is_true
2116+
~key:"nested_virt"
2117+
~platformdata:vm.Xenops_interface.Vm.platformdata
2118+
~default:false
2119+
} in
20912120
let non_persistent = generate_non_persistent_state xs vm in
20922121
persistent, non_persistent
20932122
end in
@@ -2682,6 +2711,14 @@ module VM = struct
26822711
end;
26832712
shadow_multiplier_target = shadow_multiplier_target;
26842713
hvm;
2714+
nomigrate = begin match vme with
2715+
| None -> false
2716+
| Some x -> x.VmExtra.persistent.VmExtra.nomigrate
2717+
end;
2718+
nested_virt = begin match vme with
2719+
| None -> false
2720+
| Some x -> x.VmExtra.persistent.VmExtra.nested_virt
2721+
end
26852722
}
26862723
)
26872724

0 commit comments

Comments
 (0)