Skip to content

Commit

Permalink
Merge pull request #275 from zli/CA-213992
Browse files Browse the repository at this point in the history
CA-213992: update sm-data as part of HVM media insert/eject
  • Loading branch information
Jon Ludlam authored Jul 14, 2016
2 parents 5d90085 + bef6580 commit b31cac7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
17 changes: 0 additions & 17 deletions xc/device.ml
Original file line number Diff line number Diff line change
Expand Up @@ -351,23 +351,6 @@ let devty_of_string = function
| "floppy" -> Floppy
| _ -> invalid_arg "devty_of_string"

let add_backend_keys ~xs (x: device) subdir keys =
let backend_stub = backend_path_of_device ~xs x in
let backend = backend_stub ^ "/" ^ subdir in
debug "About to write data %s to path %s" (String.concat ";" (List.map (fun (a,b) -> "("^a^","^b^")") keys)) backend;
Xs.transaction xs (fun t ->
ignore(t.Xst.read backend_stub);
t.Xst.writev backend keys
)

let remove_backend_keys ~xs (x: device) subdir keys =
let backend_stub = backend_path_of_device ~xs x in
let backend = backend_stub ^ "/" ^ subdir in
Xs.transaction xs (fun t ->
List.iter (fun key -> t.Xst.rm (backend ^ "/" ^ key)) keys
)


let uses_blktap ~phystype = List.mem phystype [ Qcow; Vhd; Aio ]

(** Request either a clean or hard shutdown *)
Expand Down
16 changes: 16 additions & 0 deletions xc/device_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,22 @@ let backend_pause_done_path_of_device ~xs (x: device) =
let backend_state_path_of_device ~xs (x: device) =
sprintf "%s/state" (backend_path_of_device ~xs x)

let add_backend_keys ~xs (x: device) subdir keys =
let backend_stub = backend_path_of_device ~xs x in
let backend = backend_stub ^ "/" ^ subdir in
debug "About to write data %s to path %s" (String.concat ";" (List.map (fun (a,b) -> "("^a^","^b^")") keys)) backend;
Xs.transaction xs (fun t ->
ignore(t.Xst.read backend_stub);
t.Xst.writev backend keys
)

let remove_backend_keys ~xs (x: device) subdir keys =
let backend_stub = backend_path_of_device ~xs x in
let backend = backend_stub ^ "/" ^ subdir in
Xs.transaction xs (fun t ->
List.iter (fun key -> t.Xst.rm (backend ^ "/" ^ key)) keys
)

let string_of_device (x: device) =
sprintf "frontend %s; backend %s" (string_of_endpoint x.frontend) (string_of_endpoint x.backend)

Expand Down
3 changes: 3 additions & 0 deletions xc/device_common.mli
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ val list_devices_between : xs:Xenstore.Xs.xsh -> Xenctrl.domid -> Xenctrl.domid

val device_of_backend : endpoint -> Xenctrl.domid -> device

val add_backend_keys : xs:Xenstore.Xs.xsh -> device -> string -> (string * string) list -> unit
val remove_backend_keys: xs:Xenstore.Xs.xsh -> device -> string -> string list -> unit

type protocol = Protocol_Native | Protocol_X86_32 | Protocol_X86_64
val string_of_protocol : protocol -> string
val protocol_of_string : string -> protocol
Expand Down
4 changes: 3 additions & 1 deletion xc/xenops_server_xen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2102,7 +2102,8 @@ module VBD = struct
let phystype = Device.Vbd.Phys in
(* We store away the disk so we can implement VBD.stat *)
xs.Xs.write (vdi_path_of_device ~xs device) (disk |> rpc_of_disk |> Jsonrpc.to_string);
Device.Vbd.media_insert ~xs ~phystype ~params:vdi.attach_info.Storage_interface.params device
Device.Vbd.media_insert ~xs ~phystype ~params:vdi.attach_info.Storage_interface.params device;
Device_common.add_backend_keys ~xs device "sm-data" vdi.attach_info.Storage_interface.xenstore_data
end
) Newest vm

Expand All @@ -2112,6 +2113,7 @@ module VBD = struct
let (device: Device_common.device) = device_by_id xc xs vm (device_kind_of ~xs vbd) Oldest (id_of vbd) in
Device.Vbd.media_eject ~xs device;
safe_rm xs (vdi_path_of_device ~xs device);
safe_rm xs (Device_common.backend_path_of_device ~xs device ^ "/sm-data");
Storage.dp_destroy task (Storage.id_of (string_of_int (frontend_domid_of_device device)) vbd.Vbd.id)
) Oldest vm

Expand Down

0 comments on commit b31cac7

Please sign in to comment.