mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0015-v2v-Add-input-adjust_overlay_parameters-method.patch

0d20ef
From 9b1984eb3ce4411b1a1882cddc263766b3984ba0 Mon Sep 17 00:00:00 2001
0d20ef
From: "Richard W.M. Jones" <rjones@redhat.com>
0d20ef
Date: Mon, 20 Oct 2014 18:21:38 +0100
0d20ef
Subject: [PATCH] v2v: Add input#adjust_overlay_parameters method.
0d20ef
0d20ef
This is called before the copying phase to allow the input method to
0d20ef
adjust overlay/backing parameters.
0d20ef
0d20ef
The default implementation does nothing, so this commit has no effect.
0d20ef
0d20ef
(cherry picked from commit 0084736f5fe75f62f72f0014333b32ab753b1554)
0d20ef
---
0d20ef
 v2v/types.ml  | 1 +
0d20ef
 v2v/types.mli | 3 +++
0d20ef
 v2v/v2v.ml    | 7 +++++++
0d20ef
 3 files changed, 11 insertions(+)
0d20ef
0d20ef
diff --git a/v2v/types.ml b/v2v/types.ml
0d20ef
index 5124f3c..c5a05f6 100644
0d20ef
--- a/v2v/types.ml
0d20ef
+++ b/v2v/types.ml
0d20ef
@@ -194,6 +194,7 @@ and guestcaps_video_type = QXL | Cirrus
0d20ef
 class virtual input verbose = object
0d20ef
   method virtual as_options : string
0d20ef
   method virtual source : unit -> source
0d20ef
+  method adjust_overlay_parameters (_ : overlay) = ()
0d20ef
 end
0d20ef
 
0d20ef
 class virtual output verbose = object
0d20ef
diff --git a/v2v/types.mli b/v2v/types.mli
0d20ef
index c077dc2..2123a41 100644
0d20ef
--- a/v2v/types.mli
0d20ef
+++ b/v2v/types.mli
0d20ef
@@ -143,6 +143,9 @@ class virtual input : bool -> object
0d20ef
       This is just used for pretty-printing log messages. *)
0d20ef
   method virtual source : unit -> source
0d20ef
   (** Examine the source hypervisor and create a source struct. *)
0d20ef
+  method adjust_overlay_parameters : overlay -> unit
0d20ef
+  (** Called just before copying to allow the input module to adjust
0d20ef
+      parameters of the overlay disk. *)
0d20ef
 end
0d20ef
 (** Encapsulates all [-i], etc input arguments as an object. *)
0d20ef
 
0d20ef
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
0d20ef
index 6bd2e2c..6f98a8c 100644
0d20ef
--- a/v2v/v2v.ml
0d20ef
+++ b/v2v/v2v.ml
0d20ef
@@ -307,6 +307,13 @@ let rec main () =
0d20ef
           if not ((new G.guestfs ())#disk_has_backing_file overlay_file) then
0d20ef
             error (f_"internal error: qemu corrupted the overlay file");
0d20ef
 
0d20ef
+          (* Give the input module a chance to adjust the parameters
0d20ef
+           * of the overlay/backing file.  This allows us to increase
0d20ef
+           * the readahead parameter when copying (see RHBZ#1151033 and
0d20ef
+           * RHBZ#1153589 for the gruesome details).
0d20ef
+           *)
0d20ef
+          input#adjust_overlay_parameters t.target_overlay;
0d20ef
+
0d20ef
           (* It turns out that libguestfs's disk creation code is
0d20ef
            * considerably more flexible and easier to use than
0d20ef
            * qemu-img, so create the disk explicitly using libguestfs
0d20ef
-- 
0d20ef
1.8.3.1
0d20ef