@@ -69,9 +69,40 @@ let lvcreate_l =
6969 assert_lv_exists ~expected_size_in_extents: 1L " test" ;
7070 xenvm [ " lvremove" ; vg ^ " /test" ] |> ignore_string
7171
72+ let file_exists filename =
73+ try
74+ Unix.LargeFile. stat filename |> ignore;
75+ true
76+ with Unix. Unix_error (Unix. ENOENT, _ , _ ) -> false
77+
78+ let dm_exists name = match Devmapper. stat name with
79+ | None -> false
80+ | Some _ -> true
81+
82+ let dev_path_of name = " /dev/" ^ vg ^ " /" ^ name
83+ let mapper_path_of name = " /dev/mapper/" ^ vg ^ " -" ^ name
84+
85+ let lvchange_n =
86+ " lvchange -an <device>: check that we can deactivate a volume" > ::
87+ fun () ->
88+ xenvm [ " lvcreate" ; " -n" ; " test" ; " -L" ; " 3" ; vg ] |> ignore_string;
89+ assert_lv_exists ~expected_size_in_extents: 1L " test" ;
90+ let vg_metadata, lv_metadata = Lwt_main. run (Client. get_lv " test" ) in
91+ let name = Mapper. name_of vg_metadata lv_metadata in
92+ xenvm [ " lvchange" ; " -ay" ; " /dev/" ^ vg ^ " /test" ] |> ignore_string;
93+ assert_equal ~printer: string_of_bool true (file_exists (dev_path_of " test" ));
94+ assert_equal ~printer: string_of_bool true (file_exists (mapper_path_of " test" ));
95+ assert_equal ~printer: string_of_bool true (dm_exists name);
96+ xenvm [ " lvchange" ; " -an" ; " /dev/" ^ vg ^ " /test" ] |> ignore_string;
97+ assert_equal ~printer: string_of_bool false (file_exists (dev_path_of" test" ));
98+ assert_equal ~printer: string_of_bool false (file_exists (mapper_path_of" test" ));
99+ assert_equal ~printer: string_of_bool false (dm_exists name);
100+ xenvm [ " lvremove" ; vg ^ " /test" ] |> ignore_string
101+
72102let xenvmd_suite = " Commands which require xenvmd" > ::: [
73103 lvcreate_L;
74104 lvcreate_l;
105+ lvchange_n;
75106]
76107
77108let _ =
0 commit comments