Richard W.M. Jones
2017-Mar-10 14:04 UTC
[Libguestfs] [PATCH] v2v: -o null: Force output format to be raw sparse.
When converting and throwing away the output (-o null), the input format should not really matter. However it does currently matter for a couple of reasons: (1) If the input is not raw or qcow2, then you'll get the error below because virt-v2v wants to write the same output format as input format but only allows raw or qcow2 as output formats: virt-v2v: error: output format should be 'raw' or 'qcow2'. (2) If you use -o null -oa preallocated then a non-sparse temporary disk is created before being deleted, but that just wastes disk space for no reason. Therefore this change (i) prevents '-o null -oa preallocated' from being specified on the command line, (ii) prevents '-o null -of <anything>', (iii) forces the output (temporary file) to be raw sparse. --- v2v/cmdline.ml | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml index f417dea..a72aa49 100644 --- a/v2v/cmdline.ml +++ b/v2v/cmdline.ml @@ -337,7 +337,7 @@ read the man page virt-v2v(1). (* Parse the output mode. *) if output_mode <> `Not_set && in_place then error (f_"-o and --in-place cannot be used at the same time"); - let output + let output, output_format, output_alloc match output_mode with | `Glance -> if output_conn <> None then @@ -348,7 +348,8 @@ read the man page virt-v2v(1). error (f_"-o glance: --qemu-boot option cannot be used in this output mode"); if not do_copy then error (f_"--no-copy and '-o glance' cannot be used at the same time"); - Output_glance.output_glance () + Output_glance.output_glance (), + output_format, output_alloc | `Not_set | `Libvirt -> @@ -358,7 +359,8 @@ read the man page virt-v2v(1). error (f_"-o libvirt: --qemu-boot option cannot be used in this output mode"); if not do_copy then error (f_"--no-copy and '-o libvirt' cannot be used at the same time"); - Output_libvirt.output_libvirt output_conn output_storage + Output_libvirt.output_libvirt output_conn output_storage, + output_format, output_alloc | `Local -> let os @@ -370,16 +372,23 @@ read the man page virt-v2v(1). | Some d -> d in if qemu_boot then error (f_"-o local: --qemu-boot option cannot be used in this output mode"); - Output_local.output_local os + Output_local.output_local os, + output_format, output_alloc | `Null -> + if output_alloc <> Sparse then + error (f_"-o null: -oa option cannot be used in this output mode"); if output_conn <> None then error (f_"-o null: -oc option cannot be used in this output mode"); + if output_format <> None then + error (f_"-o null: -of option cannot be used in this output mode"); if output_storage <> None then error (f_"-o null: -os option cannot be used in this output mode"); if qemu_boot then error (f_"-o null: --qemu-boot option cannot be used in this output mode"); - Output_null.output_null () + Output_null.output_null (), + (* Force output format to raw sparse in -o null mode. *) + Some "raw", Sparse | `QEmu -> let os @@ -389,7 +398,8 @@ read the man page virt-v2v(1). | Some d when not (is_directory d) -> error (f_"-os %s: output directory does not exist or is not a directory") d | Some d -> d in - Output_qemu.output_qemu os qemu_boot + Output_qemu.output_qemu os qemu_boot, + output_format, output_alloc | `RHV -> let os @@ -399,7 +409,8 @@ read the man page virt-v2v(1). | Some d -> d in if qemu_boot then error (f_"-o rhv: --qemu-boot option cannot be used in this output mode"); - Output_rhv.output_rhv os output_alloc + Output_rhv.output_rhv os output_alloc, + output_format, output_alloc | `VDSM -> let os @@ -423,7 +434,8 @@ read the man page virt-v2v(1). ovf_output = vdsm_ovf_output; compat = vdsm_compat; } in - Output_vdsm.output_vdsm os vdsm_params output_alloc in + Output_vdsm.output_vdsm os vdsm_params output_alloc, + output_format, output_alloc in { compressed = compressed; debug_overlays = debug_overlays; -- 2.9.3
Pino Toscano
2017-Mar-10 14:38 UTC
Re: [Libguestfs] [PATCH] v2v: -o null: Force output format to be raw sparse.
On Friday, 10 March 2017 15:04:04 CET Richard W.M. Jones wrote:> When converting and throwing away the output (-o null), the input > format should not really matter. However it does currently matter for > a couple of reasons: > > (1) If the input is not raw or qcow2, then you'll get the error below > because virt-v2v wants to write the same output format as input format > but only allows raw or qcow2 as output formats: > > virt-v2v: error: output format should be 'raw' or 'qcow2'. > > (2) If you use -o null -oa preallocated then a non-sparse temporary > disk is created before being deleted, but that just wastes disk space > for no reason. > > Therefore this change > > (i) prevents '-o null -oa preallocated' from being specified on the > command line, > > (ii) prevents '-o null -of <anything>', > > (iii) forces the output (temporary file) to be raw sparse. > ---LGTM. Thanks, -- Pino Toscano
Possibly Parallel Threads
- [PATCH] v2v: Refactor some command line error messages.
- [PATCH 3/4] ocaml tools: Use global variables to store trace (-x) and verbose (-v) flags.
- [v2v PATCH 1/2] Add back guestcaps as parameter of output#prepare_targets
- [PATCH v2 3/3] v2v: Add -o rhv-upload output mode.
- [PATCH 5/5] v2v: Add -o rhv-upload output mode.