mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
v2v: Add 'exit' choice to --root ask.
If the user does ^C then this leaves temporary overlay files around (possibly a bug?). Offer an 'exit' choice to the user which exits cleanly. The new message looks like this: Dual- or multi-boot operating system detected. Choose the root filesystem that contains the main operating system from the list below: [1] /dev/sda3 (Fedora release 20 (Heisenbug)) [2] /dev/sdb3 Enter a number between 1 and 2, or 'exit': exit
This commit is contained in:
16
v2v/v2v.ml
16
v2v/v2v.ml
@@ -417,7 +417,7 @@ and inspect_source g root_choice =
|
||||
| `Ask ->
|
||||
(* List out the roots and ask the user to choose. *)
|
||||
printf "\n***\n";
|
||||
printf (f_"dual- or multi-boot operating system detected. Choose the root filesystem\nthat contains the main operating system from the list below:\n");
|
||||
printf (f_"Dual- or multi-boot operating system detected. Choose the root filesystem\nthat contains the main operating system from the list below:\n");
|
||||
printf "\n";
|
||||
iteri (
|
||||
fun i root ->
|
||||
@@ -430,11 +430,15 @@ and inspect_source g root_choice =
|
||||
let i = ref 0 in
|
||||
let n = List.length roots in
|
||||
while !i < 1 || !i > n do
|
||||
printf (f_"Enter number between 1 and %d: ") n;
|
||||
(try i := int_of_string (read_line ())
|
||||
with
|
||||
| End_of_file -> error (f_"connection closed")
|
||||
| Failure "int_of_string" -> ()
|
||||
printf (f_"Enter a number between 1 and %d, or 'exit': ") n;
|
||||
let input = read_line () in
|
||||
if input = "exit" || input = "q" || input = "quit" then
|
||||
exit 0
|
||||
else (
|
||||
try i := int_of_string input
|
||||
with
|
||||
| End_of_file -> error (f_"connection closed")
|
||||
| Failure "int_of_string" -> ()
|
||||
)
|
||||
done;
|
||||
List.nth roots (!i - 1)
|
||||
|
||||
Reference in New Issue
Block a user