[libguestfs] More upstream patches to fix virt-v2v test harness.

Richard W.M. Jones rjones at fedoraproject.org
Fri Mar 20 13:06:28 UTC 2015


commit 35ff7d7647c9c6c8186f3cadea8a1c8aa9d7fe8d
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Fri Mar 20 13:05:52 2015 +0000

    More upstream patches to fix virt-v2v test harness.
    
    - Do not delete OCaml *.a files, including ones in the virt-v2v test harness.

 0001-v2v-test-harness-Add-support-for-OVA.patch | 99 +++++++++++++++++++++++++
 libguestfs.spec                                 | 17 +++--
 2 files changed, 111 insertions(+), 5 deletions(-)
---
diff --git a/0001-v2v-test-harness-Add-support-for-OVA.patch b/0001-v2v-test-harness-Add-support-for-OVA.patch
new file mode 100644
index 0000000..d0acef7
--- /dev/null
+++ b/0001-v2v-test-harness-Add-support-for-OVA.patch
@@ -0,0 +1,99 @@
+From 5ac87b975fef867663402743d79e1b693d485bb8 Mon Sep 17 00:00:00 2001
+From: "Richard W.M. Jones" <rjones at redhat.com>
+Date: Fri, 20 Mar 2015 12:14:42 +0000
+Subject: [PATCH] v2v: test-harness: Add support for OVA.
+
+This makes VMware testing easier, since it means you don't need to
+test against a live server.
+---
+ v2v/test-harness/v2v_test_harness.ml | 62 ++++++++++++++++++++++--------------
+ 1 file changed, 38 insertions(+), 24 deletions(-)
+
+diff --git a/v2v/test-harness/v2v_test_harness.ml b/v2v/test-harness/v2v_test_harness.ml
+index fe09d6f..67a49d8 100644
+--- a/v2v/test-harness/v2v_test_harness.ml
++++ b/v2v/test-harness/v2v_test_harness.ml
+@@ -62,10 +62,6 @@ let run ~test ?input_disk ?input_xml ?(test_plan = default_plan) () =
+     match input_disk with
+     | None -> test ^ ".img.xz"
+     | Some input_disk -> input_disk in
+-  let input_xml =
+-    match input_xml with
+-    | None -> test ^ ".xml"
+-    | Some input_xml -> input_xml in
+ 
+   let inspect_and_mount_disk filename =
+     let g = new G.guestfs () in
+@@ -332,31 +328,49 @@ let run ~test ?input_disk ?input_xml ?(test_plan = default_plan) () =
+ 
+   printf "v2v_test_harness: starting test: %s\n%!" test;
+ 
+-  (* Check we are started in the correct directory, ie. the input_disk
+-   * and input_xml files should exist, and they should be local files.
++  (* Check we are started in the correct directory.
+    *)
+-  if not (Sys.file_exists input_disk) || not (Sys.file_exists input_xml) then
+-    failwithf "cannot find input files: %s, %s: you are probably running the test script from the wrong directory" input_disk input_xml;
++  if not (Sys.file_exists input_disk) then
++    failwith "cannot find input files: you are probably running the test script from the wrong directory";
+ 
+-  (* Uncompress the input, if it doesn't exist already. *)
+-  let input_disk =
+-    if Filename.check_suffix input_disk ".xz" then (
+-      let input_disk_uncomp = Filename.chop_suffix input_disk ".xz" in
+-      if not (Sys.file_exists input_disk_uncomp) then (
+-        let cmd = sprintf "unxz --keep %s" (quote input_disk) in
+-        printf "%s\n%!" cmd;
+-        if Sys.command cmd <> 0 then
+-          failwith "unxz command failed"
+-      );
+-      input_disk_uncomp
++  (* How we run virt-v2v depends on the extension of the input_disk. *)
++  let v2v_method =
++    (* Uncompress the input, if the uncompressed file doesn't exist already. *)
++    let input_disk =
++      if Filename.check_suffix input_disk ".xz" then (
++        let input_disk_uncomp = Filename.chop_suffix input_disk ".xz" in
++        if not (Sys.file_exists input_disk_uncomp) then (
++          let cmd = sprintf "unxz --keep %s" (quote input_disk) in
++          printf "%s\n%!" cmd;
++          if Sys.command cmd <> 0 then
++            failwith "unxz command failed"
++        );
++        input_disk_uncomp
++      )
++      else input_disk in
++
++    if Filename.check_suffix input_disk ".img" then (
++      let input_xml =
++        match input_xml with
++        | None -> test ^ ".xml"
++        | Some input_xml -> input_xml in
++      `V2v_method_libvirtxml input_xml
+     )
+-    else input_disk in
+-  ignore input_disk;
++    else if Filename.check_suffix input_disk ".ova" then
++      `V2v_method_ova input_disk
++    else
++      failwithf "don't know what to do with input disk '%s'" input_disk in
+ 
+   (* Run virt-v2v. *)
+-  let cmd = sprintf
+-    "virt-v2v -i libvirtxml %s -o local -of qcow2 -os . -on %s"
+-    (quote input_xml) (quote (test ^ "-converted")) in
++  let cmd_input =
++    match v2v_method with
++    | `V2v_method_libvirtxml input_xml ->
++      sprintf "-i libvirtxml %s" (quote input_xml)
++    | `V2v_method_ova input_disk ->
++      sprintf "-i ova %s" (quote input_disk) in
++  let cmd =
++    sprintf "virt-v2v %s -o local -of qcow2 -os . -on %s"
++      cmd_input (quote (test ^ "-converted")) in
+   printf "%s\n%!" cmd;
+   if Sys.command cmd <> 0 then
+     failwith "virt-v2v command failed";
+-- 
+2.3.1
+
diff --git a/libguestfs.spec b/libguestfs.spec
index 3f960ca..a27f39a 100644
--- a/libguestfs.spec
+++ b/libguestfs.spec
@@ -25,15 +25,17 @@ Summary:       Access and modify virtual machine disk images
 Name:          libguestfs
 Epoch:         1
 Version:       1.29.30
-Release:       4%{?dist}
+Release:       5%{?dist}
 License:       LGPLv2+
 
 # Source and patches.
 URL:           http://libguestfs.org/
 Source0:       http://libguestfs.org/download/1.29-development/%{name}-%{version}.tar.gz
 
+# Upstream patches to add/fix the virt-v2v test harness.
 Patch1:        0001-v2v-test-harness-Measure-similarity-between-images-w.patch
 Patch2:        0002-v2v-test-harness-Fix-boot-loop-so-it-detects-disk-in.patch
+Patch3:        0001-v2v-test-harness-Add-support-for-OVA.patch
 
 # Basic build requirements:
 BuildRequires: perl(Pod::Simple)
@@ -808,6 +810,7 @@ for %{name}.
 # Apply patches, if any, here.
 %patch1 -p1
 %patch2 -p1
+%patch3 -p1
 
 # For Python 3 we must build libguestfs twice.  This creates:
 #   %{name}-%{version}/
@@ -972,10 +975,10 @@ pushd python3
 make DESTDIR=$RPM_BUILD_ROOT INSTALLDIRS=vendor -C python install
 popd
 
-# Delete static libraries, libtool files.
-rm $(
-  find $RPM_BUILD_ROOT -path '*/ocaml/guestfs' -prune -o -name '*.a' -print
-)
+# Delete static libraries.
+rm $( find $RPM_BUILD_ROOT -name '*.a' | grep -v /ocaml/ )
+
+# Delete libtool files.
 find $RPM_BUILD_ROOT -name '*.la' -delete
 
 # Delete some bogus Perl files.
@@ -1366,6 +1369,10 @@ popd
 
 
 %changelog
+* Fri Mar 20 2015 Richard W.M. Jones <rjones at redhat.com> - 1:1.29.30-5
+- More upstream patches to fix virt-v2v test harness.
+- Do not delete OCaml *.a files, including ones in the virt-v2v test harness.
+
 * Sun Mar 15 2015 Richard W.M. Jones <rjones at redhat.com> - 1:1.29.30-4
 - Enable golang on various arches.
 


More information about the scm-commits mailing list