virt-resize: Add --ntfsresize-force option.
authorRichard W.M. Jones <rjones@redhat.com>
Wed, 13 Jul 2011 08:27:57 +0000 (09:27 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Wed, 13 Jul 2011 08:27:57 +0000 (09:27 +0100)
Use the non-deprecated g#ntfsresize_opts API call, and also add
the --ntfsresize-force option for forcing resize.

resize/resize.ml
resize/virt-resize.pod

index 82fd765..8e7057c 100644 (file)
@@ -30,7 +30,7 @@ let prog = Filename.basename Sys.executable_name
 
 let infile, outfile, copy_boot_loader, debug, deletes, dryrun,
   expand, expand_content, extra_partition, format, ignores,
 
 let infile, outfile, copy_boot_loader, debug, deletes, dryrun,
   expand, expand_content, extra_partition, format, ignores,
-  lv_expands, output_format,
+  lv_expands, ntfsresize_force, output_format,
   quiet, resizes, resizes_force, shrink =
   let display_version () =
     let g = new G.guestfs () in
   quiet, resizes, resizes_force, shrink =
   let display_version () =
     let g = new G.guestfs () in
@@ -57,6 +57,7 @@ let infile, outfile, copy_boot_loader, debug, deletes, dryrun,
   let format = ref "" in
   let ignores = ref [] in
   let lv_expands = ref [] in
   let format = ref "" in
   let ignores = ref [] in
   let lv_expands = ref [] in
+  let ntfsresize_force = ref false in
   let output_format = ref "" in
   let quiet = ref false in
   let resizes = ref [] in
   let output_format = ref "" in
   let quiet = ref false in
   let resizes = ref [] in
@@ -85,6 +86,7 @@ let infile, outfile, copy_boot_loader, debug, deletes, dryrun,
     "-n",        Arg.Set dryrun,            " Don't perform changes";
     "--dryrun",  Arg.Set dryrun,            " -\"-";
     "--dry-run", Arg.Set dryrun,            " -\"-";
     "-n",        Arg.Set dryrun,            " Don't perform changes";
     "--dryrun",  Arg.Set dryrun,            " -\"-";
     "--dry-run", Arg.Set dryrun,            " -\"-";
+    "--ntfsresize-force", Arg.Set ntfsresize_force, " Force ntfsresize";
     "--output-format", Arg.Set_string format, "format Format of output disk";
     "-q",        Arg.Set quiet,             " Don't print the summary";
     "--quiet",   Arg.Set quiet,             " -\"-";
     "--output-format", Arg.Set_string format, "format Format of output disk";
     "-q",        Arg.Set quiet,             " Don't print the summary";
     "--quiet",   Arg.Set quiet,             " -\"-";
@@ -123,6 +125,7 @@ read the man page virt-resize(1).
   let format = match !format with "" -> None | str -> Some str in
   let ignores = List.rev !ignores in
   let lv_expands = List.rev !lv_expands in
   let format = match !format with "" -> None | str -> Some str in
   let ignores = List.rev !ignores in
   let lv_expands = List.rev !lv_expands in
+  let ntfsresize_force = !ntfsresize_force in
   let output_format = match !output_format with "" -> None | str -> Some str in
   let quiet = !quiet in
   let resizes = List.rev !resizes in
   let output_format = match !output_format with "" -> None | str -> Some str in
   let quiet = !quiet in
   let resizes = List.rev !resizes in
@@ -138,7 +141,7 @@ read the man page virt-resize(1).
 
   infile, outfile, copy_boot_loader, debug, deletes, dryrun,
   expand, expand_content, extra_partition, format, ignores,
 
   infile, outfile, copy_boot_loader, debug, deletes, dryrun,
   expand, expand_content, extra_partition, format, ignores,
-  lv_expands, output_format,
+  lv_expands, ntfsresize_force, output_format,
   quiet, resizes, resizes_force, shrink
 
 (* Default to true, since NTFS support is usually available. *)
   quiet, resizes, resizes_force, shrink
 
 (* Default to true, since NTFS support is usually available. *)
@@ -916,7 +919,7 @@ let () =
       | Resize2fs ->
           g#e2fsck_f target;
           g#resize2fs target
       | Resize2fs ->
           g#e2fsck_f target;
           g#resize2fs target
-      | NTFSResize -> g#ntfsresize target
+      | NTFSResize -> g#ntfsresize_opts ~force:ntfsresize_force target
     in
 
     (* Expand partition content as required. *)
     in
 
     (* Expand partition content as required. *)
index c84e40f..69c93e3 100644 (file)
@@ -405,6 +405,14 @@ of partitions, if it knows how (see I<--expand> option above).
 If you give the I<--no-expand-content> option then virt-resize
 will not attempt this.
 
 If you give the I<--no-expand-content> option then virt-resize
 will not attempt this.
 
+=item B<--ntfsresize-force>
+
+Pass the I<--force> option to L<ntfsresize(8)>, allowing resizing
+even if the NTFS disk is marked as needing a consistency check.
+You have to use this option if you want to resize a Windows
+guest multiple times without booting into Windows between each
+resize.
+
 =item B<-d>
 
 =item B<--debug>
 =item B<-d>
 
 =item B<--debug>