@@ -26,18 +26,28 @@ let activate vg lv local_device =
2626 Devmapper. mknod name path 0o0600 ;
2727 return ()
2828
29- let lvchange_activate copts vg_name lv_name physical_device =
29+ let lvchange_activate copts vg_name lv_name physical_device ( offline :bool ) : unit =
3030 let open Xenvm_common in
3131 Lwt_main. run (
3232 get_vg_info_t copts vg_name >> = fun info ->
3333 set_uri copts info;
34- Client. get_lv ~name: lv_name >> = fun (vg , lv ) ->
35- if vg.Lvm.Vg. name <> vg_name then failwith " Invalid URI" ;
36- let local_device = match (info,physical_device) with
34+ let local_device : string = match (info,physical_device) with
3735 | _ , Some d -> d (* cmdline overrides default for the VG *)
3836 | Some info , None -> info.local_device (* If we've got a default, use that *)
39- | None , None -> failwith " Need to know the local device!"
40- in
37+ | None , None -> failwith " Need to know the local device!" in
38+ ( if offline then begin
39+ with_block local_device
40+ (fun x ->
41+ let module Vg_IO = Lvm.Vg. Make (Log )(Block )(Time )(Clock ) in
42+ Vg_IO. connect [ x ] `RO >> |= fun vg ->
43+ match Vg_IO. find vg lv_name with
44+ | None -> failwith (Printf. sprintf " Failed to find LV %s" lv_name)
45+ | Some vol ->
46+ return (Vg_IO. metadata_of vg, Vg_IO.Volume. metadata_of vol)
47+ )
48+ end else Client. get_lv ~name: lv_name
49+ ) >> = fun (vg , lv ) ->
50+ if vg.Lvm.Vg. name <> vg_name then failwith " Invalid URI" ;
4151 activate vg lv local_device
4252 )
4353
@@ -105,10 +115,10 @@ let lvchange_refresh copts vg_name lv_name physical_device =
105115 reload vg lv local_device
106116 )
107117
108- let lvchange copts (vg_name ,lv_name_opt ) physical_device action perm refresh add_tag del_tag =
118+ let lvchange copts (vg_name ,lv_name_opt ) physical_device action perm refresh add_tag del_tag offline =
109119 let lv_name = match lv_name_opt with Some l -> l | None -> failwith " Need LV name" in
110120 (match action with
111- | Some Activate -> lvchange_activate copts vg_name lv_name physical_device
121+ | Some Activate -> lvchange_activate copts vg_name lv_name physical_device offline
112122 | Some Deactivate -> lvchange_deactivate copts vg_name lv_name
113123 | None -> () );
114124 (if refresh then lvchange_refresh copts vg_name lv_name physical_device);
@@ -158,12 +168,16 @@ let add_tag_arg =
158168let del_tag_arg =
159169 let doc = " Remove the given tag from the LV" in
160170 Arg. (value & opt (some string ) None & info [" deltag" ] ~docv: " DELTAG" ~doc )
161-
171+
172+ let offline_arg =
173+ let doc = " Assume xenvmd is offline and read metadata from the disk" in
174+ Arg. (value & flag & info [ " offline" ] ~docv: " OFFLINE" ~doc )
175+
162176let lvchange_cmd =
163177 let doc = " Change the attributes of a logical volume" in
164178 let man = [
165179 `S " DESCRIPTION" ;
166180 `P " lvchange allows you to change the attributes of a logical volume including making them known to the kernel ready for use."
167181 ] in
168- Term. (pure lvchange $ Xenvm_common. copts_t $ Xenvm_common. name_arg $ Xenvm_common. physical_device_arg $ action_arg $ perm_arg $ refresh_arg $ add_tag_arg $ del_tag_arg),
182+ Term. (pure lvchange $ Xenvm_common. copts_t $ Xenvm_common. name_arg $ Xenvm_common. physical_device_arg $ action_arg $ perm_arg $ refresh_arg $ add_tag_arg $ del_tag_arg $ offline_arg ),
169183 Term. info " lvchange" ~sdocs: " COMMON OPTIONS" ~doc ~man
0 commit comments