Blame SOURCES/0033-p2v-Ensure-we-are-using-virt-v2v-1.28.patch

0d20ef
From 82435225e29889f0e84739e22703354e454860bd Mon Sep 17 00:00:00 2001
0d20ef
From: "Richard W.M. Jones" <rjones@redhat.com>
0d20ef
Date: Tue, 28 Oct 2014 08:51:06 +0000
0d20ef
Subject: [PATCH] p2v: Ensure we are using virt-v2v >= 1.28.
0d20ef
0d20ef
Must NOT use:
0d20ef
0d20ef
- One of the interim versions of virt-v2v (1.27.x) that we published
0d20ef
  during development.
0d20ef
0d20ef
- Old virt-v2v (0.9.x).
0d20ef
0d20ef
Also use the --version option (instead of -V) since old virt-v2v
0d20ef
required it:
0d20ef
0d20ef
  $ virt-v2v -V
0d20ef
  Option v is ambiguous (version, vmtype)
0d20ef
  Usage:
0d20ef
  [...]
0d20ef
  $ virt-v2v --version
0d20ef
  0.9.1
0d20ef
0d20ef
(cherry picked from commit cb291d7e4642547da5551f8686bbc46a911377af)
0d20ef
---
0d20ef
 p2v/ssh.c | 40 ++++++++++++++++++++++++++++++++++------
0d20ef
 1 file changed, 34 insertions(+), 6 deletions(-)
0d20ef
0d20ef
diff --git a/p2v/ssh.c b/p2v/ssh.c
0d20ef
index f3bfcf9..d593451 100644
0d20ef
--- a/p2v/ssh.c
0d20ef
+++ b/p2v/ssh.c
0d20ef
@@ -345,8 +345,12 @@ test_connection (struct config *config)
0d20ef
   if (h == NULL)
0d20ef
     return -1;
0d20ef
 
0d20ef
-  /* Send 'virt-v2v -V' command and hope we get back a version string. */
0d20ef
-  if (mexp_printf (h, "%svirt-v2v -V\n", config->sudo ? "sudo " : "") == -1) {
0d20ef
+  /* Send 'virt-v2v --version' command and hope we get back a version string.
0d20ef
+   * Note old virt-v2v did not understand -V option.
0d20ef
+   */
0d20ef
+  if (mexp_printf (h,
0d20ef
+                   "%svirt-v2v --version\n",
0d20ef
+                   config->sudo ? "sudo " : "") == -1) {
0d20ef
     set_ssh_error ("mexp_printf: %m");
0d20ef
     mexp_close (h);
0d20ef
     return -1;
0d20ef
@@ -370,9 +374,12 @@ test_connection (struct config *config)
0d20ef
       fprintf (stderr, "%s: remote virt-v2v version: %d.%d.%d\n",
0d20ef
                program_name, v2v_major, v2v_minor, v2v_release);
0d20ef
 #endif
0d20ef
-      if (v2v_major < 1 || v2v_major > 1) {
0d20ef
+      /* This is an internal error.  Need to check this here so we
0d20ef
+       * don't confuse it with the no-version case below.
0d20ef
+       */
0d20ef
+      if (v2v_major < 1) {
0d20ef
         mexp_close (h);
0d20ef
-        set_ssh_error ("invalid version major (%d)", v2v_major);
0d20ef
+        set_ssh_error ("could not parse version string");
0d20ef
         return -1;
0d20ef
       }
0d20ef
       break;
0d20ef
@@ -382,12 +389,12 @@ test_connection (struct config *config)
0d20ef
 
0d20ef
     case MEXP_EOF:
0d20ef
       mexp_close (h);
0d20ef
-      set_ssh_error ("unexpected end of file waiting virt-v2v -V output");
0d20ef
+      set_ssh_error ("unexpected end of file waiting virt-v2v --version output");
0d20ef
       return -1;
0d20ef
 
0d20ef
     case MEXP_TIMEOUT:
0d20ef
       mexp_close (h);
0d20ef
-      set_ssh_error ("timeout waiting for virt-v2v -V output");
0d20ef
+      set_ssh_error ("timeout waiting for virt-v2v --version output");
0d20ef
       return -1;
0d20ef
 
0d20ef
     case MEXP_ERROR:
0d20ef
@@ -411,6 +418,27 @@ test_connection (struct config *config)
0d20ef
     return -1;
0d20ef
   }
0d20ef
 
0d20ef
+  /* The major version must always be 1. */
0d20ef
+  if (v2v_major != 1) {
0d20ef
+    mexp_close (h);
0d20ef
+    set_ssh_error ("virt-v2v major version is not 1 (major = %d), "
0d20ef
+                   "this version of virt-p2v is not compatible", v2v_major);
0d20ef
+    return -1;
0d20ef
+  }
0d20ef
+
0d20ef
+  /* The version of virt-v2v must be >= 1.28, just to make sure
0d20ef
+   * someone isn't (a) using one of the experimental 1.27 releases
0d20ef
+   * that we published during development, nor (b) using old virt-v2v.
0d20ef
+   * We should remain compatible with any virt-v2v after 1.28.
0d20ef
+   */
0d20ef
+  if (v2v_minor < 28) {
0d20ef
+    mexp_close (h);
0d20ef
+    set_ssh_error ("virt-v2v version is < 1.28 (major = %d, minor = %d), "
0d20ef
+                   "you must upgrade to virt-v2v >= 1.28 on "
0d20ef
+                   "the conversion server", v2v_major, v2v_minor);
0d20ef
+    return -1;
0d20ef
+  }
0d20ef
+
0d20ef
   /* Get virt-v2v features.  See: v2v/cmdline.ml */
0d20ef
   if (mexp_printf (h, "%svirt-v2v --machine-readable\n",
0d20ef
                    config->sudo ? "sudo " : "") == -1) {
0d20ef
-- 
0d20ef
1.8.3.1
0d20ef