Skip to content

Commit

Permalink
CP-18289 record platform:{nomigrate,nested_virt} in VmExtra state
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
lindig committed Aug 17, 2016
1 parent 5d6a8fa commit 10e4264
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/xenops_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,8 @@ let halted_vm = {
last_start_time = 0.;
shadow_multiplier_target = 1.;
hvm = false;
nomigrate=false;
nested_virt=false;
}

let unplugged_pci = {
Expand Down
41 changes: 40 additions & 1 deletion xc/xenops_server_xen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,25 @@ module VmExtra = struct
build_info: Domain.build_info option;
ty: Vm.builder_info option;
last_start_time: float;
nomigrate: bool; (* platform:nomigrate at boot time *)
nested_virt: bool (* platform:nested_virt at boot time *)
} with rpc

let default_persistent_t =
{ build_info = None
; ty = None
; last_start_time = 0.0
; nomigrate = false
; nested_virt = false
}

(* override rpc code generated for persistent_t. It is important that
* this code is before the declaration of type t because otherwise
* the rpc code for type t won't use it. *)
let persistent_t_of_rpc rpc =
Rpc.struct_extend rpc (rpc_of_persistent_t default_persistent_t)
|> persistent_t_of_rpc

type non_persistent_t = {
create_info: Domain.create_info;
vcpu_max: int;
Expand Down Expand Up @@ -759,6 +776,8 @@ module VM = struct
(* Earlier than the PV drivers update time, therefore
any cached PV driver information will be kept. *)
last_start_time = 0.;
nomigrate = false;
nested_virt = false
} |> VmExtra.rpc_of_persistent_t |> Jsonrpc.to_string

let mkints n =
Expand Down Expand Up @@ -855,7 +874,19 @@ module VM = struct
x.VmExtra.persistent, x.VmExtra.non_persistent
| None -> begin
debug "VM = %s; has no stored domain-level configuration, regenerating" vm.Vm.id;
let persistent = { VmExtra.build_info = None; ty = None; last_start_time = Unix.gettimeofday ()} in
let persistent =
{ VmExtra.build_info = None
; ty = None
; last_start_time = Unix.gettimeofday ()
; nomigrate = Platform.is_true
~key:"nomigrate"
~platformdata:vm.Xenops_interface.Vm.platformdata
~default:false
; nested_virt=Platform.is_true
~key:"nested_virt"
~platformdata:vm.Xenops_interface.Vm.platformdata
~default:false
} in
let non_persistent = generate_non_persistent_state xc xs vm in
persistent, non_persistent
end in
Expand Down Expand Up @@ -1638,6 +1669,14 @@ module VM = struct
end;
hvm = di.Xenctrl.hvm_guest;
shadow_multiplier_target = shadow_multiplier_target;
nomigrate = begin match vme with
| None -> false
| Some x -> x.VmExtra.persistent.VmExtra.nomigrate
end;
nested_virt = begin match vme with
| None -> false
| Some x -> x.VmExtra.persistent.VmExtra.nested_virt
end
}
)

Expand Down
39 changes: 38 additions & 1 deletion xl/xenops_server_xenlight.ml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ module VmExtra = struct
build_info: Domain.build_info option;
ty: Vm.builder_info option;
last_start_time: float;
nomigrate: bool; (* platform:nomigrate at boot time *)
nested_virt: bool (* platform:nested_virt at boot time *)
} with rpc

type non_persistent_t = {
Expand All @@ -256,6 +258,19 @@ module VmExtra = struct
persistent: persistent_t;
non_persistent: non_persistent_t;
} with rpc

let default_persistent_t =
{ build_info = None
; ty = None
; last_start_time = 0.0
; nomigrate = false
; nested_virt = false
}

(* override rpc code generated for persistent_t *)
let persistent_t_of_rpc rpc =
Rpc.struct_extend rpc (rpc_of_persistent_t default_persistent_t)
|> persistent_t_of_rpc
end

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

(* 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. *)
Expand Down Expand Up @@ -2087,7 +2104,19 @@ module VM = struct
x.VmExtra.persistent, x.VmExtra.non_persistent
| None -> begin
debug "VM = %s; has no stored domain-level configuration, regenerating" vm.Vm.id;
let persistent = { VmExtra.build_info = None; ty = None; last_start_time = Unix.gettimeofday () } in
let persistent =
{ VmExtra.build_info = None
; ty = None
; last_start_time = Unix.gettimeofday ()
; nomigrate = Platform.is_true
~key:"nomigrate"
~platformdata:vm.Xenops_interface.Vm.platformdata
~default:false
; nested_virt=Platform.is_true
~key:"nested_virt"
~platformdata:vm.Xenops_interface.Vm.platformdata
~default:false
} in
let non_persistent = generate_non_persistent_state xs vm in
persistent, non_persistent
end in
Expand Down Expand Up @@ -2682,6 +2711,14 @@ module VM = struct
end;
shadow_multiplier_target = shadow_multiplier_target;
hvm;
nomigrate = begin match vme with
| None -> false
| Some x -> x.VmExtra.persistent.VmExtra.nomigrate
end;
nested_virt = begin match vme with
| None -> false
| Some x -> x.VmExtra.persistent.VmExtra.nested_virt
end
}
)

Expand Down

0 comments on commit 10e4264

Please sign in to comment.