mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0031-RHEL-7-v2v-Disable-the-virt-v2v-in-place-option.patch

491457
From 172bc9d8d9c1023485abfe1c466906caefa6cf29 Mon Sep 17 00:00:00 2001
4ebc84
From: "Richard W.M. Jones" <rjones@redhat.com>
4ebc84
Date: Thu, 14 Jan 2016 11:53:42 -0500
4ebc84
Subject: [PATCH] RHEL 7: v2v: Disable the virt-v2v --in-place option.
4ebc84
4ebc84
This disables the virt-v2v --in-place option which we do not
4ebc84
wish to support in RHEL.
4ebc84
(See commit d0069559a939e47e5f29973ed9a69a13f0b58301).
4ebc84
---
4ebc84
 v2v/Makefile.am          |   2 -
4ebc84
 v2v/cmdline.ml           |   8 +--
4ebc84
 v2v/test-v2v-docs.sh     |   1 +
4ebc84
 v2v/test-v2v-in-place.sh | 108 ---------------------------------------
4ebc84
 v2v/virt-v2v.pod         |  48 +----------------
4ebc84
 5 files changed, 7 insertions(+), 160 deletions(-)
4ebc84
 delete mode 100755 v2v/test-v2v-in-place.sh
4ebc84
4ebc84
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
4ebc84
index 2312812fb..946170b5d 100644
4ebc84
--- a/v2v/Makefile.am
4ebc84
+++ b/v2v/Makefile.am
4ebc84
@@ -457,7 +457,6 @@ if HAVE_LIBVIRT
4ebc84
 TESTS += \
4ebc84
 	test-v2v-cdrom.sh \
4ebc84
 	test-v2v-floppy.sh \
4ebc84
-	test-v2v-in-place.sh \
4ebc84
 	test-v2v-mac.sh \
4ebc84
 	test-v2v-networks-and-bridges.sh \
4ebc84
 	test-v2v-no-copy.sh \
4ebc84
@@ -609,7 +608,6 @@ EXTRA_DIST += \
4ebc84
 	test-v2v-i-vmx-3.vmx \
4ebc84
 	test-v2v-i-vmx-4.vmx \
4ebc84
 	test-v2v-i-vmx-5.vmx \
4ebc84
-	test-v2v-in-place.sh \
4ebc84
 	test-v2v-it-vddk-io-query.sh \
4ebc84
 	test-v2v-machine-readable.sh \
4ebc84
 	test-v2v-mac-expected.xml \
4ebc84
diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml
4ebc84
index aa89428c5..b7a7f9ad8 100644
4ebc84
--- a/v2v/cmdline.ml
4ebc84
+++ b/v2v/cmdline.ml
4ebc84
@@ -208,8 +208,7 @@ let parse_cmdline () =
4ebc84
                                     s_"Use password from file to connect to input hypervisor";
4ebc84
     [ M"it" ],       Getopt.String ("transport", set_string_option_once "-it" input_transport),
4ebc84
                                     s_"Input transport";
4ebc84
-    [ L"in-place" ], Getopt.Set in_place,
4ebc84
-                                    s_"Only tune the guest in the input VM";
4ebc84
+    [ L"in-place" ], Getopt.Set in_place, Getopt.hidden_option_description;
4ebc84
     [ L"mac" ],      Getopt.String ("mac:network|bridge:out", add_mac),
4ebc84
                                     s_"Map NIC to network or bridge";
4ebc84
     [ S 'n'; L"network" ], Getopt.String ("in:out", add_network),
4ebc84
@@ -346,7 +345,6 @@ read the man page virt-v2v(1).
4ebc84
     pr "vddk\n";
4ebc84
     pr "colours-option\n";
4ebc84
     pr "vdsm-compat-option\n";
4ebc84
-    pr "in-place\n";
4ebc84
     pr "io/oo\n";
4ebc84
     pr "mac-option\n";
4ebc84
     List.iter (pr "input:%s\n") (Modules_list.input_modules ());
4ebc84
@@ -509,6 +507,10 @@ read the man page virt-v2v(1).
4ebc84
            error (f_"only ‘-it ssh’ can be used here") in
4ebc84
       Input_vmx.input_vmx input_transport arg in
4ebc84
 
4ebc84
+  (* Prevent use of --in-place option in RHEL. *)
4ebc84
+  if in_place then
4ebc84
+    error (f_"--in-place cannot be used in RHEL 7");
4ebc84
+
4ebc84
   (* Common error message. *)
4ebc84
   let error_option_cannot_be_used_in_output_mode mode opt =
4ebc84
     error (f_"-o %s: %s option cannot be used in this output mode") mode opt
4ebc84
diff --git a/v2v/test-v2v-docs.sh b/v2v/test-v2v-docs.sh
4ebc84
index dfb12bb14..2e45705a3 100755
4ebc84
--- a/v2v/test-v2v-docs.sh
4ebc84
+++ b/v2v/test-v2v-docs.sh
4ebc84
@@ -26,6 +26,7 @@ $top_srcdir/podcheck.pl virt-v2v.pod virt-v2v \
4ebc84
 --debug-overlay,\
4ebc84
 --ic,\
4ebc84
 --if,\
4ebc84
+--in-place,\
4ebc84
 --io,\
4ebc84
 --ip,\
4ebc84
 --it,\
4ebc84
diff --git a/v2v/test-v2v-in-place.sh b/v2v/test-v2v-in-place.sh
4ebc84
deleted file mode 100755
4ebc84
index 6f7d78f39..000000000
4ebc84
--- a/v2v/test-v2v-in-place.sh
4ebc84
+++ /dev/null
4ebc84
@@ -1,108 +0,0 @@
4ebc84
-#!/bin/bash -
4ebc84
-# libguestfs virt-v2v test script
4ebc84
-# Copyright (C) 2014 Red Hat Inc.
4ebc84
-# Copyright (C) 2015 Parallels IP Holdings GmbH.
4ebc84
-#
4ebc84
-# This program is free software; you can redistribute it and/or modify
4ebc84
-# it under the terms of the GNU General Public License as published by
4ebc84
-# the Free Software Foundation; either version 2 of the License, or
4ebc84
-# (at your option) any later version.
4ebc84
-#
4ebc84
-# This program is distributed in the hope that it will be useful,
4ebc84
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
4ebc84
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4ebc84
-# GNU General Public License for more details.
4ebc84
-#
4ebc84
-# You should have received a copy of the GNU General Public License
4ebc84
-# along with this program; if not, write to the Free Software
4ebc84
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
4ebc84
-
4ebc84
-# Test --in-place.
4ebc84
-
4ebc84
-unset CDPATH
4ebc84
-export LANG=C
4ebc84
-set -e
4ebc84
-
4ebc84
-$TEST_FUNCTIONS
4ebc84
-skip_if_skipped
4ebc84
-skip_if_backend uml
4ebc84
-skip_unless_phony_guest windows.img
4ebc84
-
4ebc84
-img_base="$abs_top_builddir/test-data/phony-guests/windows.img"
4ebc84
-
4ebc84
-export VIRT_TOOLS_DATA_DIR="$top_srcdir/test-data/fake-virt-tools"
4ebc84
-export VIRTIO_WIN="$top_srcdir/test-data/fake-virtio-win"
4ebc84
-
4ebc84
-d=$PWD/test-v2v-in-place.d
4ebc84
-rm -rf $d
4ebc84
-mkdir $d
4ebc84
-
4ebc84
-img="$d/test.qcow2"
4ebc84
-rm -f $img
4ebc84
-qemu-img create -f qcow2 -b $img_base -o compat=1.1,backing_fmt=raw $img
4ebc84
-md5="$(do_md5 $img_base)"
4ebc84
-
4ebc84
-libvirt_xml="$d/test.xml"
4ebc84
-rm -f $libvirt_xml
4ebc84
-n=windows-overlay
4ebc84
-cat > $libvirt_xml <
4ebc84
-<node>
4ebc84
-  <domain type='test'>
4ebc84
-    <name>$n</name>
4ebc84
-    <memory>1048576</memory>
4ebc84
-    <os>
4ebc84
-      <type>hvm</type>
4ebc84
-      <boot dev='hd'/>
4ebc84
-    </os>
4ebc84
-    <devices>
4ebc84
-      <disk type='file' device='disk'>
4ebc84
-        <driver name='qemu' type='qcow2'/>
4ebc84
-        <source file='$img'/>
4ebc84
-        <target dev='vda' bus='virtio'/>
4ebc84
-      </disk>
4ebc84
-    </devices>
4ebc84
-  </domain>
4ebc84
-</node>
4ebc84
-EOF
4ebc84
-
4ebc84
-$VG virt-v2v --debug-gc -i libvirt -ic "test://$libvirt_xml" $n --in-place
4ebc84
-
4ebc84
-# Test that the drivers have been copied over into the guest
4ebc84
-script="$d/test.fish"
4ebc84
-expected="$d/expected"
4ebc84
-response="$d/response"
4ebc84
-
4ebc84
-mktest ()
4ebc84
-{
4ebc84
-    local cmd="$1" exp="$2"
4ebc84
-
4ebc84
-    echo "echo '$cmd'" >> "$script"
4ebc84
-    echo "$cmd" >> "$expected"
4ebc84
-
4ebc84
-    echo "$cmd" >> "$script"
4ebc84
-    echo "$exp" >> "$expected"
4ebc84
-}
4ebc84
-
4ebc84
-:> "$script"
4ebc84
-:> "$expected"
4ebc84
-
4ebc84
-firstboot_dir="/Program Files/Guestfs/Firstboot"
4ebc84
-mktest "is-dir \"$firstboot_dir\"" true
4ebc84
-mktest "is-file \"$firstboot_dir/firstboot.bat\"" true
4ebc84
-mktest "is-dir \"$firstboot_dir/scripts\"" true
4ebc84
-virtio_dir="/Windows/Drivers/VirtIO"
4ebc84
-mktest "is-dir \"$virtio_dir\"" true
4ebc84
-for drv in netkvm qxl vioscsi viostor; do
4ebc84
-    for sfx in cat inf sys; do
4ebc84
-        mktest "is-file \"$virtio_dir/$drv.$sfx\"" true
4ebc84
-    done
4ebc84
-done
4ebc84
-
4ebc84
-guestfish --ro -a "$img" -i < "$script" > "$response"
4ebc84
-diff -u "$expected" "$response"
4ebc84
-
4ebc84
-# Test the base image remained untouched
4ebc84
-test "$md5" = "$(do_md5 $img_base)"
4ebc84
-
4ebc84
-# Clean up.
4ebc84
-rm -r $d
4ebc84
diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod
4ebc84
index 0e9627829..fdaaecfc5 100644
4ebc84
--- a/v2v/virt-v2v.pod
4ebc84
+++ b/v2v/virt-v2v.pod
4ebc84
@@ -8,10 +8,6 @@ virt-v2v - Convert a guest to use KVM
4ebc84
           [-o mode] [other -o* options]
4ebc84
           [guest|filename]
4ebc84
 
4ebc84
- virt-v2v --in-place
4ebc84
-          [-i mode] [other -i* options]
4ebc84
-          [guest|filename]
4ebc84
-
4ebc84
 =head1 DESCRIPTION
4ebc84
 
4ebc84
 Virt-v2v converts a single guest from a foreign hypervisor to run on
4ebc84
@@ -39,9 +35,6 @@ these sides of virt-v2v are documented separately in this manual.
4ebc84
 
4ebc84
 Virt-v2v normally copies from the input to the output, called "copying
4ebc84
 mode".  In this case the source guest is always left unchanged.
4ebc84
-In-place conversion (I<--in-place>) only uses the I<-i*> options and
4ebc84
-modifies the source guest in-place.  (See L</In-place conversion>
4ebc84
-below.)
4ebc84
 
4ebc84
 =head2 Other virt-v2v topics
4ebc84
 
4ebc84
@@ -255,20 +248,6 @@ For I<-i disk> only, this specifies the format of the input disk
4ebc84
 image.  For other input methods you should specify the input
4ebc84
 format in the metadata.
4ebc84
 
4ebc84
-=item B<--in-place>
4ebc84
-
4ebc84
-Do not create an output virtual machine in the target hypervisor.
4ebc84
-Instead, adjust the guest OS in the source VM to run in the input
4ebc84
-hypervisor.
4ebc84
-
4ebc84
-This mode is meant for integration with other toolsets, which take the
4ebc84
-responsibility of converting the VM configuration, providing for
4ebc84
-rollback in case of errors, transforming the storage, etc.
4ebc84
-
4ebc84
-See L</In-place conversion> below.
4ebc84
-
4ebc84
-Conflicts with all I<-o *> options.
4ebc84
-
4ebc84
 =item B<-io> OPTION=VALUE
4ebc84
 
4ebc84
 Set input option(s) related to the current input mode or transport.
4ebc84
@@ -1270,7 +1249,7 @@ Minimum free space: 10 MB
4ebc84
 =head3 Minimum free space check in the host
4ebc84
 
4ebc84
 You must have sufficient free space in the host directory used to
4ebc84
-store temporary overlays (except in I<--in-place> mode).  To find out
4ebc84
+store temporary overlays.  To find out
4ebc84
 which directory this is, use:
4ebc84
 
4ebc84
  $ df -h "`guestfish get-cachedir`"
4ebc84
@@ -1373,31 +1352,6 @@ that instead.
4ebc84
    </devices>
4ebc84
  </domain>
4ebc84
 
4ebc84
-=head2 In-place conversion
4ebc84
-
4ebc84
-It is also possible to use virt-v2v in scenarios where a foreign VM
4ebc84
-has already been imported into a KVM-based hypervisor, but still needs
4ebc84
-adjustments in the guest to make it run in the new virtual hardware.
4ebc84
-
4ebc84
-In that case it is assumed that a third-party tool has created the
4ebc84
-target VM in the supported KVM-based hypervisor based on the source VM
4ebc84
-configuration and contents, but using virtual devices more appropriate
4ebc84
-for KVM (e.g. virtio storage and network, etc.).
4ebc84
-
4ebc84
-Then, to make the guest OS boot and run in the changed environment,
4ebc84
-one can use:
4ebc84
-
4ebc84
- virt-v2v -ic qemu:///system converted_vm --in-place
4ebc84
-
4ebc84
-Virt-v2v will analyze the configuration of C<converted_vm> in the
4ebc84
-C<qemu:///system> libvirt instance, and apply various fixups to the
4ebc84
-guest OS configuration to make it match the VM configuration.  This
4ebc84
-may include installing virtio drivers, configuring the bootloader, the
4ebc84
-mountpoints, the network interfaces, and so on.
4ebc84
-
4ebc84
-Should an error occur during the operation, virt-v2v exits with an
4ebc84
-error code leaving the VM in an undefined state.
4ebc84
-
4ebc84
 =head2 Machine readable output
4ebc84
 
4ebc84
 The I<--machine-readable> option can be used to make the output more
4ebc84
-- 
4ebc84
2.21.0
4ebc84