mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone
Blob Blame History Raw
From d1f7ebc29a819c4ff1156169fa3a04efa7046685 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 20 Jun 2016 09:56:48 +0100
Subject: [PATCH] p2v: Display up to 50 lines of the virt-v2v conversion log on
 failure.

For some failures, 30 lines was not sufficient and only part of the
error was shown.  Increase the number of lines shown to 50.

This also colourizes the failure message, and prominently displays the
location of the full log.  The following message is now shown:

  *** virt-v2v command failed ***

  The full log is available on the conversion server in:
      /tmp/virt-p2v-20160620-sga9rhk7/virt-v2v-conversion-log.txt
  Only the last 50 lines are shown below.

  [followed by up to 50 lines of log]

Updates and fixes commit 7447fe2478e49f5121a40db973f8a1fb1daaec53.

(cherry picked from commit 6f5abc9539a4d47c98898b4c491d6b017d9abbbb)
---
 p2v/conversion.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/p2v/conversion.c b/p2v/conversion.c
index a7d1f11..fe18b4a 100644
--- a/p2v/conversion.c
+++ b/p2v/conversion.c
@@ -1045,9 +1045,19 @@ generate_wrapper_script (struct config *config, const char *remote_dir)
            "    echo\n"
            "    echo\n"
            "    echo\n"
-           "    echo '*** virt-v2v command failed ***'\n"
-           "    tail -30 $log\n"
-           "fi\n");
+           "    echo -ne '\\e[1;31m'\n"
+           "    echo '***' virt-v2v command failed '***'\n"
+           "    echo\n"
+           "    echo The full log is available on the conversion server in:\n"
+           "    echo '   ' %s/$log\n"
+           "    echo Only the last 50 lines are shown below.\n"
+           "    echo -ne '\\e[0m'\n"
+           "    echo\n"
+           "    echo\n"
+           "    echo\n"
+           "    tail -50 $log\n"
+           "fi\n",
+           remote_dir);
 
   fclose (fp);
 
-- 
1.8.3.1