[Libguestfs] [PATCH v2 2/3] v2v: Add output#tranfer_format method

Nir Soffer nirsof at gmail.com
Tue Nov 26 03:07:31 UTC 2019


Typically the transfer format is the same as the target format. But some
outputs may want to override the transfer format but create disks using
target format.

This change does not affect existing outputs, but will using raw
transfer format in rhv_upload when using qcow2 target format.
---
 v2v/types.ml  | 1 +
 v2v/types.mli | 4 ++++
 v2v/v2v.ml    | 2 +-
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/v2v/types.ml b/v2v/types.ml
index 977d9bda..8de48aec 100644
--- a/v2v/types.ml
+++ b/v2v/types.ml
@@ -529,6 +529,7 @@ class virtual output = object
   method virtual supported_firmware : target_firmware list
   method check_target_firmware (_ : guestcaps) (_ : target_firmware) = ()
   method override_output_format (_ : overlay) = (None : string option)
+  method transfer_format t = t.target_format
   method virtual prepare_targets : string -> (string * overlay) list -> target_file list
   method disk_create = (open_guestfs ())#disk_create
   method disk_copied (_ : target) (_ : int) (_ : int) = ()
diff --git a/v2v/types.mli b/v2v/types.mli
index 4c1d3595..9ceee8a2 100644
--- a/v2v/types.mli
+++ b/v2v/types.mli
@@ -488,6 +488,10 @@ class virtual output : object
       line (silently).  It’s best not to do this, instead modify
       prepare_targets so it gives an error if the output format
       chosen is not supported by the target. *)
+  method transfer_format : target -> string
+  (** Typically the transfer format is same as the target format, but
+      some outputs may need to overide the transfer format, but create disk
+      using target format. *)
   method virtual prepare_targets : string -> (string * overlay) list -> target_file list
   (** Called after conversion but before copying to prepare (but {b not}
       create) the target file.  The [(string * overlay list)] parameter
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index 03590c9e..f9d81460 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -739,7 +739,7 @@ and copy_targets cmdline targets input output =
           | TargetURI uri -> uri in
         [ "qemu-img"; "convert" ] @
         (if not (quiet ()) then [ "-p" ] else []) @
-        [ "-n"; "-f"; "qcow2"; "-O"; t.target_format ] @
+        [ "-n"; "-f"; "qcow2"; "-O"; output#transfer_format t ] @
         (if cmdline.compressed then [ "-c" ] else []) @
         [ "-S"; "64k" ] @
         [ overlay_file; filename ] in
-- 
2.21.0





More information about the Libguestfs mailing list