Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions idl/META
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# OASIS_START
# DO NOT EDIT (digest: 798568431db55f5a6dcaff164adbe75d)
# DO NOT EDIT (digest: c6b1ef075eec04a5c6fad660e74dad2f)
version = "0.1"
description = "LVM-like volume manager supporting thinly provisioned LVs"
requires =
"rpclib rpclib.syntax sexplib sexplib.syntax lvm cohttp.lwt threads bisect mirage-block-unix devmapper"
"rpclib rpclib.syntax sexplib sexplib.syntax lvm cohttp.lwt threads mirage-block-unix devmapper bisect"
archive(byte) = "xenvmidl.cma"
archive(byte, plugin) = "xenvmidl.cma"
archive(native) = "xenvmidl.cmxa"
Expand Down
4 changes: 2 additions & 2 deletions xenvm-local-allocator/local_allocator.ml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ let query_lvm config =
module FromLVM = struct
module R = Shared_block.Ring.Make(Log)(Vg_IO.Volume)(FreeAllocation)
let rec attach ~disk () =
fatal_error "attaching to FromLVM queue" (R.Consumer.attach ~disk ())
fatal_error "attaching to FromLVM queue" (R.Consumer.attach ~queue:"FromLVM Consumer" ~client:"xenvm-local-allocator" ~disk ())
let state t =
fatal_error "querying FromLVM state" (R.Consumer.state t)
let rec suspend t =
Expand Down Expand Up @@ -116,7 +116,7 @@ end
module ToLVM = struct
module R = Shared_block.Ring.Make(Log)(Vg_IO.Volume)(ExpandVolume)
let rec attach ~disk () =
R.Producer.attach ~disk ()
R.Producer.attach ~queue:"ToLVM Producer" ~client:"xenvm-local-allocator" ~disk ()
>>= function
| `Ok x -> return x
| _ ->
Expand Down
12 changes: 12 additions & 0 deletions xenvm/vgcreate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ let vgcreate vg_name devices =
>>|= fun (_, op) ->
Vg_IO.update vg [ op ]
>>|= fun () ->
let module Eraser = EraseBlock.Make(Vg_IO.Volume) in
let open Lwt in
( match Vg_IO.find vg _journal_name with
| None -> Lwt.return (`Error (`Msg "Failed to find the xenvmd journal LV to erase it"))
| Some lv ->
Vg_IO.Volume.connect lv
>>= function
| `Ok disk ->
let open IO in
Eraser.erase ~pattern:"Block erased because this is the xenvmd journal" disk
| `Error _ -> Lwt.return (`Error (`Msg "Failed to open the xenvmd journal to erase it"))
) >>|= fun () ->
return () in
Lwt_main.run t

Expand Down
23 changes: 17 additions & 6 deletions xenvmd/xenvmd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ module ToLVM = struct
module R = Shared_block.Ring.Make(Log)(Vg_IO.Volume)(ExpandVolume)
let create ~disk () =
fatal_error "creating ToLVM queue" (R.Producer.create ~disk ())
let attach ~disk () =
fatal_error "attaching to ToLVM queue" (R.Consumer.attach ~disk ())
let attach ~name ~disk () =
fatal_error "attaching to ToLVM queue" (R.Consumer.attach ~queue:(name ^ " ToLVM Consumer") ~client:"xenvmd" ~disk ())
let state t =
fatal_error "querying ToLVM state" (R.Consumer.state t)
let rec suspend t =
Expand Down Expand Up @@ -103,12 +103,12 @@ module FromLVM = struct
module R = Shared_block.Ring.Make(Log)(Vg_IO.Volume)(FreeAllocation)
let create ~disk () =
fatal_error "FromLVM.create" (R.Producer.create ~disk ())
let rec attach ~disk () = R.Producer.attach ~disk () >>= function
let rec attach ~name ~disk () = R.Producer.attach ~queue:(name ^ " FromLVM Producer") ~client:"xenvmd" ~disk () >>= function
| `Error `Suspended ->
debug "FromLVM.attach got `Suspended; sleeping";
Lwt_unix.sleep 5.
>>= fun () ->
attach ~disk ()
attach ~name ~disk ()
| x -> fatal_error "FromLVM.attach" (return x)
let state t = fatal_error "FromLVM.state" (R.Producer.state t)
let rec push t item = R.Producer.push ~t ~item () >>= function
Expand Down Expand Up @@ -198,24 +198,35 @@ module VolumeManager = struct
(* The local allocator needs to see the volumes now *)
sync () >>= fun () ->
myvg >>= fun vg ->

( match Vg_IO.find vg toLVM with
| Some lv -> return lv
| None -> assert false ) >>= fun v ->
Vg_IO.Volume.connect v
>>= function
| `Error _ -> fail (Failure (Printf.sprintf "Failed to open %s" toLVM))
| `Ok disk ->
let module Eraser = Lvm.EraseBlock.Make(Vg_IO.Volume) in
Eraser.erase ~pattern:(Printf.sprintf "xenvmd erased the %s volume" toLVM) disk
>>= function
| `Error _ -> fail (Failure (Printf.sprintf "Failed to erase %s" toLVM))
| `Ok () ->
ToLVM.create ~disk ()
>>= fun () ->
Vg_IO.Volume.disconnect disk
>>= fun () ->

( match Vg_IO.find vg fromLVM with
| Some lv -> return lv
| None -> assert false ) >>= fun v ->
Vg_IO.Volume.connect v
>>= function
| `Error _ -> fail (Failure (Printf.sprintf "Failed to open %s" fromLVM))
| `Ok disk ->
Eraser.erase ~pattern:(Printf.sprintf "xenvmd erased the %s volume" fromLVM) disk
>>= function
| `Error _ -> fail (Failure (Printf.sprintf "Failed to erase %s" fromLVM))
| `Ok () ->
FromLVM.create ~disk ()
>>= fun () ->
Vg_IO.Volume.disconnect disk >>= fun () ->
Expand Down Expand Up @@ -244,7 +255,7 @@ module VolumeManager = struct
>>= function
| `Error _ -> fail (Failure (Printf.sprintf "Failed to open %s" toLVM))
| `Ok disk ->
ToLVM.attach ~disk ()
ToLVM.attach ~name ~disk ()
>>= fun to_LVM ->
ToLVM.state to_LVM
>>= fun state ->
Expand All @@ -258,7 +269,7 @@ module VolumeManager = struct
>>= function
| `Error _ -> fail (Failure (Printf.sprintf "Failed to open %s" fromLVM))
| `Ok disk ->
FromLVM.attach ~disk ()
FromLVM.attach ~name ~disk ()
>>= fun from_LVM ->
FromLVM.state from_LVM
>>= fun state ->
Expand Down