Skip to content

Commit

Permalink
CA-388210: SMAPIv3 concurrency safety: send the (unique) datapath arg…
Browse files Browse the repository at this point in the history
…ument as domain for Dom0

Dom0 allows multiple attaches of RO disks, used e.g. for VDI.copy.
Send a unique value to SMAPIv3 plugins to avoid bugs to the lack of reference counting in those plugins.

XAPI already sends a unique value here, either vbd/domid/device, or a fresh UUID (for storage migration).

Signed-off-by: Edwin Török <[email protected]>
  • Loading branch information
edwintorok committed Nov 18, 2024
1 parent b5e8cdd commit b241d2b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion ocaml/xapi-storage-script/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,22 @@ let backend_backtrace_error name args backtrace =
let missing_uri () =
backend_error "MISSING_URI" ["Please include a URI in the device-config"]

let domain_of ~dp:_ ~vm' = Storage_interface.Vm.string_of vm'
(** return a unique 'domain' string for Dom0, so that we can plug disks
multiple times (e.g. for copy).
XAPI should give us a unique 'dp' (datapath) string, e.g. a UUID for storage migration,
or vbd/domid/device.
For regular guests keep the domain as passed by XAPI (an integer).
*)
let domain_of ~dp ~vm' =
let vm = Storage_interface.Vm.string_of vm' in
match vm with
| "0" ->
(* SM tries to use this in filesystem paths, so cannot have /,
and systemd might be a bit unhappy with - *)
"u0-" ^ dp |> String.map ~f:(function '/' | '-' -> '_' | c -> c)
| _ ->
vm

(** Functions to wrap calls to the above client modules and convert their
exceptions and errors into SMAPIv2 errors of type
Expand Down

0 comments on commit b241d2b

Please sign in to comment.