mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0084-p2v-show-error-dialog-if-virt-v2v-fails-RHBZ-1167601.patch

0d20ef
From 8e1ea1e5471bb96f8bd38e24da38f8d18effd1df Mon Sep 17 00:00:00 2001
0d20ef
From: John Eckersberg <jeckersb@redhat.com>
0d20ef
Date: Thu, 11 Dec 2014 08:38:49 -0500
0d20ef
Subject: [PATCH] p2v: show error dialog if virt-v2v fails (RHBZ#1167601)
0d20ef
0d20ef
Ensure the control connection exits with the same status code as
0d20ef
virt-v2v, and return an error from start_conversion if virt-v2v
0d20ef
failed.
0d20ef
0d20ef
(cherry picked from commit 841aa0faf3b1495fd167e32b8105b0bc6faaea60)
0d20ef
---
0d20ef
 p2v/conversion.c | 17 ++++++++++++++---
0d20ef
 1 file changed, 14 insertions(+), 3 deletions(-)
0d20ef
0d20ef
diff --git a/p2v/conversion.c b/p2v/conversion.c
0d20ef
index 9f5a3ad..4ff7ecc 100644
0d20ef
--- a/p2v/conversion.c
0d20ef
+++ b/p2v/conversion.c
0d20ef
@@ -100,6 +100,7 @@ start_conversion (struct config *config,
0d20ef
                   void (*notify_ui) (int type, const char *data))
0d20ef
 {
0d20ef
   int ret = -1;
0d20ef
+  int status;
0d20ef
   size_t i, len;
0d20ef
   size_t nr_disks = guestfs___count_strings (config->disks);
0d20ef
   struct data_conn data_conns[nr_disks];
0d20ef
@@ -276,7 +277,7 @@ start_conversion (struct config *config,
0d20ef
   if (mexp_printf (control_h, " ) | tee %s/virt-v2v-conversion-log.txt",
0d20ef
                    remote_dir) == -1)
0d20ef
     goto printf_fail;
0d20ef
-  if (mexp_printf (control_h, "; exit") == -1)
0d20ef
+  if (mexp_printf (control_h, "; exit $(< %s/status)", remote_dir) == -1)
0d20ef
     goto printf_fail;
0d20ef
   if (mexp_printf (control_h, "\n") == -1)
0d20ef
     goto printf_fail;
0d20ef
@@ -313,8 +314,18 @@ start_conversion (struct config *config,
0d20ef
 
0d20ef
   ret = 0;
0d20ef
  out:
0d20ef
-  if (control_h)
0d20ef
-    mexp_close (control_h);
0d20ef
+  if (control_h) {
0d20ef
+    if ((status = mexp_close (control_h)) == -1) {
0d20ef
+      set_conversion_error ("mexp_close: %m");
0d20ef
+      ret = -1;
0d20ef
+    } else if (ret == 0 &&
0d20ef
+               WIFEXITED (status) &&
0d20ef
+               WEXITSTATUS (status) != 0) {
0d20ef
+      set_conversion_error ("virt-v2v exited with status %d",
0d20ef
+                            WEXITSTATUS (status));
0d20ef
+      ret = -1;
0d20ef
+    }
0d20ef
+  }
0d20ef
   cleanup_data_conns (data_conns, nr_disks);
0d20ef
   return ret;
0d20ef
 }
0d20ef
-- 
0d20ef
1.8.3.1
0d20ef