mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0226-p2v-Clear-previous-version-and-driver-information-wh.patch

ffd6ed
From ba00d355b0721b3780482bdb7b8ab0f6c14c136b Mon Sep 17 00:00:00 2001
ffd6ed
From: "Richard W.M. Jones" <rjones@redhat.com>
ffd6ed
Date: Thu, 3 Sep 2015 16:12:22 +0100
ffd6ed
Subject: [PATCH] p2v: Clear previous version and driver information when
ffd6ed
 testing connection (RHBZ#1227609).
ffd6ed
ffd6ed
When calling test_connection to test the connection to a conversion
ffd6ed
server, we also query for the remote server's version and driver
ffd6ed
information (using 'virt-v2v --version' and
ffd6ed
'virt-v2v --machine-readable').
ffd6ed
ffd6ed
However we didn't clear the existing information from previous runs.
ffd6ed
ffd6ed
One consequence of this was that if you used the back button in the
ffd6ed
GUI, the list of output drivers would be repopulated two or more
ffd6ed
times.  https://bugzilla.redhat.com/show_bug.cgi?id=1227609
ffd6ed
ffd6ed
Another is that connecting to a different server could confuse
ffd6ed
test_connection into thinking the connection was successful (because
ffd6ed
of data from the previous run) when in fact it was not.
ffd6ed
ffd6ed
Thanks: Tingting Zheng for finding the original bug.
ffd6ed
(cherry picked from commit 6246bebf82e2bd097aa476dad101416faf03240f)
ffd6ed
---
ffd6ed
 p2v/ssh.c | 12 ++++++++++++
ffd6ed
 1 file changed, 12 insertions(+)
ffd6ed
ffd6ed
diff --git a/p2v/ssh.c b/p2v/ssh.c
ffd6ed
index 9a596ab..26e73ba 100644
ffd6ed
--- a/p2v/ssh.c
ffd6ed
+++ b/p2v/ssh.c
ffd6ed
@@ -345,6 +345,11 @@ test_connection (struct config *config)
ffd6ed
   if (h == NULL)
ffd6ed
     return -1;
ffd6ed
 
ffd6ed
+  /* Clear any previous version information since we may be connecting
ffd6ed
+   * to a different server.
ffd6ed
+   */
ffd6ed
+  v2v_major = v2v_minor = v2v_release = 0;
ffd6ed
+
ffd6ed
   /* Send 'virt-v2v --version' command and hope we get back a version string.
ffd6ed
    * Note old virt-v2v did not understand -V option.
ffd6ed
    */
ffd6ed
@@ -439,6 +444,13 @@ test_connection (struct config *config)
ffd6ed
     return -1;
ffd6ed
   }
ffd6ed
 
ffd6ed
+  /* Clear any previous driver information since we may be connecting
ffd6ed
+   * to a different server.
ffd6ed
+   */
ffd6ed
+  guestfs_int_free_string_list (input_drivers);
ffd6ed
+  guestfs_int_free_string_list (output_drivers);
ffd6ed
+  input_drivers = output_drivers = NULL;
ffd6ed
+
ffd6ed
   /* Get virt-v2v features.  See: v2v/cmdline.ml */
ffd6ed
   if (mexp_printf (h, "%svirt-v2v --machine-readable\n",
ffd6ed
                    config->sudo ? "sudo " : "") == -1) {
ffd6ed
-- 
ffd6ed
1.8.3.1
ffd6ed