From b7a00e7b473add0fa94776292be45a25b31c1407 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Wed, 30 Nov 2016 16:52:42 +0000
Subject: [PATCH] v2v: -o vdsm: Add --vdsm-compat flag. -o rhev: Drop support
for RHV < 4.1 (RHBZ#1400205).
Support for RHEV with RHEL 6 nodes required us to output the old style
qcow2 compat=0.10 images. Since RHEV 3.6 GA, RHEL 6 has not been
supported as a RHEV node type. Since RHV 4.1, compat=1.1 is
supported. (Support for compat=1.1 is uncertain in RHV 4.0 even on
RHEL 7 nodes.)
There are significant downsides to using qcow2 compat=0.10 instead of
the modern default (compat=1.1).
Therefore this patch does two things:
For -o rhev, it drops support for compat=0.10 completely. You must
use RHV 4.1.
For -o vdsm, it adds an interim flag (--vdsm-compat=0.10 or
--vdsm-compat=1.1) which controls the compat level of the qcow2 output
file. VDSM should use --vdsm-compat=1.1 when it is known that modern
qemu is available. We can make this the default later when all RHV
instances have moved to 4.1.
It also adds:
vdsm-compat-option
to the `virt-v2v --machine-readable' output to indicate that this flag
can be used.
Thanks: Yaniv Kaul, Michal Skrivanek.
(cherry picked from commit bdaeeb4e606f3828887da87ad5acb4f7b49cfed5)
---
v2v/cmdline.ml | 8 ++++++++
v2v/output_rhev.ml | 4 ----
v2v/output_vdsm.ml | 11 ++++++++---
v2v/output_vdsm.mli | 1 +
v2v/test-v2v-o-vdsm-options.sh | 9 ++++++++-
v2v/virt-v2v.pod | 19 +++++++++++++++++++
6 files changed, 44 insertions(+), 8 deletions(-)
diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml
index b9992eb..f5fb3b3 100644
--- a/v2v/cmdline.ml
+++ b/v2v/cmdline.ml
@@ -66,6 +66,10 @@ let parse_cmdline () =
let vdsm_vm_uuid = ref None in
let vdsm_ovf_output = ref None in (* default "." *)
let vmtype = ref None in
+
+ let vdsm_compat = ref "0.10" in
+ let set_vdsm_compat s = vdsm_compat := s in
+
let set_string_option_once optname optref arg =
match !optref with
| Some _ ->
@@ -215,6 +219,7 @@ let parse_cmdline () =
"file " ^ s_"Use password from file";
"--print-source", Arg.Set print_source, " " ^ s_"Print source and stop";
"--root", Arg.String set_root_choice,"ask|... " ^ s_"How to choose root filesystem";
+ "--vdsm-compat", Arg.Symbol (["0.10"; "1.1"], set_vdsm_compat), " " ^ s_"Write qcow2 with compat=0.10|1.1";
"--vdsm-image-uuid", Arg.String add_vdsm_image_uuid, "uuid " ^ s_"Output image UUID(s)";
"--vdsm-vol-uuid", Arg.String add_vdsm_vol_uuid, "uuid " ^ s_"Output vol UUID(s)";
"--vdsm-vm-uuid", Arg.String (set_string_option_once "--vdsm-vm-uuid" vdsm_vm_uuid),
@@ -277,6 +282,7 @@ read the man page virt-v2v(1).
let print_source = !print_source in
let qemu_boot = !qemu_boot in
let root_choice = !root_choice in
+ let vdsm_compat = !vdsm_compat in
let vdsm_image_uuids = List.rev !vdsm_image_uuids in
let vdsm_vol_uuids = List.rev !vdsm_vol_uuids in
let vdsm_vm_uuid = !vdsm_vm_uuid in
@@ -297,6 +303,7 @@ read the man page virt-v2v(1).
printf "virt-v2v\n";
printf "libguestfs-rewrite\n";
printf "colours-option\n";
+ printf "vdsm-compat-option\n";
List.iter (printf "input:%s\n") (Modules_list.input_modules ());
List.iter (printf "output:%s\n") (Modules_list.output_modules ());
List.iter (printf "convert:%s\n") (Modules_list.convert_modules ());
@@ -454,6 +461,7 @@ read the man page virt-v2v(1).
vol_uuids = vdsm_vol_uuids;
vm_uuid = vdsm_vm_uuid;
ovf_output = vdsm_ovf_output;
+ compat = vdsm_compat;
} in
Output_vdsm.output_vdsm os vdsm_params vmtype output_alloc in
diff --git a/v2v/output_rhev.ml b/v2v/output_rhev.ml
index ae37a3f..7bd94df 100644
--- a/v2v/output_rhev.ml
+++ b/v2v/output_rhev.ml
@@ -253,10 +253,6 @@ object
Changeuid.func changeuid_t (
fun () ->
let g = open_guestfs ~identifier:"rhev_disk_create" () in
- (* For qcow2, override v2v-supplied compat option, because RHEL 6
- * nodes cannot handle qcow2 v3 (RHBZ#1145582).
- *)
- let compat = if format <> "qcow2" then compat else Some "0.10" in
g#disk_create ?backingfile ?backingformat ?preallocation ?compat
?clustersize path format size;
(* Make it sufficiently writable so that possibly root, or
diff --git a/v2v/output_vdsm.ml b/v2v/output_vdsm.ml
index 7bb28a9..57b5352 100644
--- a/v2v/output_vdsm.ml
+++ b/v2v/output_vdsm.ml
@@ -30,6 +30,7 @@ type vdsm_params = {
vol_uuids : string list;
vm_uuid : string;
ovf_output : string;
+ compat : string;
}
class output_vdsm os vdsm_params vmtype output_alloc =
@@ -37,7 +38,7 @@ object
inherit output
method as_options =
- sprintf "-o vdsm -os %s%s%s --vdsm-vm-uuid %s --vdsm-ovf-output %s%s" os
+ sprintf "-o vdsm -os %s%s%s --vdsm-vm-uuid %s --vdsm-ovf-output %s%s%s" os
(String.concat ""
(List.map (sprintf " --vdsm-image-uuid %s") vdsm_params.image_uuids))
(String.concat ""
@@ -48,6 +49,9 @@ object
| None -> ""
| Some Server -> " --vmtype server"
| Some Desktop -> " --vmtype desktop")
+ (match vdsm_params.compat with
+ | "0.10" -> "" (* currently this is the default, so don't print it *)
+ | s -> sprintf " --vdsm-compat=%s" s)
method supported_firmware = [ TargetBIOS ]
@@ -153,9 +157,10 @@ object
?clustersize path format size =
let g = open_guestfs ~identifier:"vdsm_disk_create" () in
(* For qcow2, override v2v-supplied compat option, because RHEL 6
- * nodes cannot handle qcow2 v3 (RHBZ#1145582).
+ * nodes cannot handle qcow2 v3 (RHBZ#1145582, RHBZ#1400205).
*)
- let compat = if format <> "qcow2" then compat else Some "0.10" in
+ let compat =
+ if format <> "qcow2" then compat else Some vdsm_params.compat in
g#disk_create ?backingfile ?backingformat ?preallocation ?compat
?clustersize path format size
diff --git a/v2v/output_vdsm.mli b/v2v/output_vdsm.mli
index 1a88eaa..40eceee 100644
--- a/v2v/output_vdsm.mli
+++ b/v2v/output_vdsm.mli
@@ -23,6 +23,7 @@ type vdsm_params = {
vol_uuids : string list; (* --vdsm-vol-uuid (multiple) *)
vm_uuid : string; (* --vdsm-vm-uuid *)
ovf_output : string; (* --vdsm-ovf-output *)
+ compat : string; (* --vdsm-compat=0.10|1.1 *)
}
(** Miscellaneous extra command line parameters used by VDSM. *)
diff --git a/v2v/test-v2v-o-vdsm-options.sh b/v2v/test-v2v-o-vdsm-options.sh
index 6ae5d56..de07b9c 100755
--- a/v2v/test-v2v-o-vdsm-options.sh
+++ b/v2v/test-v2v-o-vdsm-options.sh
@@ -1,6 +1,6 @@
#!/bin/bash -
# libguestfs virt-v2v test script
-# Copyright (C) 2014 Red Hat Inc.
+# Copyright (C) 2014-2016 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,6 +21,7 @@
unset CDPATH
export LANG=C
set -e
+set -x
if [ -n "$SKIP_TEST_V2V_O_VDSM_OPTIONS_SH" ]; then
echo "$0: test skipped because environment variable is set"
@@ -62,10 +63,12 @@ $VG virt-v2v --debug-gc \
-i libvirt -ic "$libvirt_uri" windows \
-o vdsm -os $d/12345678-1234-1234-1234-123456789abc \
--vmtype desktop \
+ -of qcow2 \
--vdsm-image-uuid IMAGE \
--vdsm-vol-uuid VOL \
--vdsm-vm-uuid VM \
--vdsm-ovf-output $d/12345678-1234-1234-1234-123456789abc/master/vms/VM \
+ --vdsm-compat=1.1
# Test the OVF metadata was created.
test -f $d/12345678-1234-1234-1234-123456789abc/master/vms/VM/VM.ovf
@@ -82,6 +85,10 @@ test -f VOL.meta
# Test the disk file was created.
test -f VOL
+# Test that a qcow2 file with compat=1.1 was generated.
+test "$(guestfish disk-format VOL)" = "qcow2"
+qemu-img info VOL | grep 'compat: 1.1'
+
popd
rm -r $d
diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod
index 32085c1..fb00e82 100644
--- a/v2v/virt-v2v.pod
+++ b/v2v/virt-v2v.pod
@@ -495,6 +495,25 @@ boot an operating system from the first VirtIO disk. Specifically,
F</boot> must be on the first VirtIO disk, and it cannot chainload an
OS which is not in the first VirtIO disk.
+=item B<--vdsm-compat=0.10>
+
+=item B<--vdsm-compat=1.1>
+
+If I<-o vdsm> and the output format is qcow2, then we add the qcow2
+I<compat=0.10> option to the output file for compatibility with RHEL 6
+(see L<https://bugzilla.redhat.com/1145582>).
+
+If I<--vdsm-compat=1.1> is used then modern qcow2 (I<compat=1.1>)
+files are generated instead.
+
+Currently I<--vdsm-compat=0.10> is the default, but this will change
+to I<--vdsm-compat=1.1> in a future version of virt-v2v (when we can
+assume that everyone is using a modern version of qemu).
+
+B<Note this option only affects I<-o vdsm> output>. All other output
+modes (including I<-o rhev>) generate modern qcow2 I<compat=1.1>
+files, always.
+
=item B<--vdsm-image-uuid> UUID
=item B<--vdsm-vol-uuid> UUID
--
1.8.3.1