Richard W.M. Jones
2016-Apr-26 12:16 UTC
[Libguestfs] v2v: Remove --no-trim, --vmtype options and other fixes.
The first two patches implement the change discussed here: https://www.redhat.com/archives/libguestfs/2016-April/msg00178.html The third patch fixes the mapping of inspection data to OVF VmType which was inherited directly from old virt-v2v and had never been changed. It had a number of problems. The fourth patch is only slightly related to the others. It adds an extra slow test to ensure that trimming doesn't regress, fixing https://bugzilla.redhat.com/show_bug.cgi?id=1264332 Rich.
Richard W.M. Jones
2016-Apr-26 12:16 UTC
[Libguestfs] [PATCH 1/4] v2v: Remove --no-trim option.
It will now print a warning but is otherwise ignored: virt-v2v: warning: the --no-trim option has been removed and now does nothing See: https://www.redhat.com/archives/libguestfs/2016-April/msg00178.html --- v2v/cmdline.ml | 25 ++++--------------------- v2v/cmdline.mli | 1 - v2v/v2v.ml | 45 +++++---------------------------------------- v2v/virt-v2v.pod | 24 ------------------------ 4 files changed, 9 insertions(+), 86 deletions(-) diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml index 2f0dace..d35e3ba 100644 --- a/v2v/cmdline.ml +++ b/v2v/cmdline.ml @@ -38,7 +38,6 @@ type cmdline = { do_copy : bool; in_place : bool; network_map : string NetworkMap.t; - no_trim : string list; output_alloc : output_allocation; output_format : string option; output_name : string option; @@ -109,23 +108,8 @@ let parse_cmdline () add_network, add_bridge in - let no_trim = ref [] in - let set_no_trim = function - | "all" | "ALL" | "*" -> - (* Note: this is a magic value tested in the main code. The - * no_trim list does NOT support wildcards. - *) - no_trim := ["*"] - | mps -> - let mps = String.nsplit "," mps in - List.iter ( - fun mp -> - if String.length mp = 0 then - error (f_"--no-trim: empty parameter"); - if mp.[0] <> '/' then - error (f_"--no-trim: %s: mountpoint/device name does not begin with '/'") mp; - ) mps; - no_trim := mps + let no_trim_warning _ + warning (f_"the --no-trim option has been removed and now does nothing") in let output_mode = ref `Not_set in @@ -199,7 +183,8 @@ let parse_cmdline () "-n", Arg.String add_network, "in:out " ^ s_"Map network 'in' to 'out'"; "--network", Arg.String add_network, "in:out " ^ ditto; "--no-copy", Arg.Clear do_copy, " " ^ s_"Just write the metadata"; - "--no-trim", Arg.String set_no_trim, "all|mp,mp,.." ^ " " ^ s_"Don't trim selected mounts"; + "--no-trim", Arg.String no_trim_warning, + "-" ^ " " ^ s_"Ignored for backwards compatibility"; "-o", Arg.String set_output_mode, o_options ^ " " ^ s_"Set output mode (default: libvirt)"; "-oa", Arg.String set_output_alloc, "sparse|preallocated " ^ s_"Set output allocation mode"; @@ -264,7 +249,6 @@ read the man page virt-v2v(1). let in_place = !in_place in let machine_readable = !machine_readable in let network_map = !network_map in - let no_trim = !no_trim in let output_alloc match !output_alloc with | `Not_set | `Sparse -> Sparse @@ -454,7 +438,6 @@ read the man page virt-v2v(1). { compressed = compressed; debug_overlays = debug_overlays; do_copy = do_copy; in_place = in_place; network_map = network_map; - no_trim = no_trim; output_alloc = output_alloc; output_format = output_format; output_name = output_name; print_source = print_source; root_choice = root_choice; diff --git a/v2v/cmdline.mli b/v2v/cmdline.mli index 2ae73fd..1095989 100644 --- a/v2v/cmdline.mli +++ b/v2v/cmdline.mli @@ -38,7 +38,6 @@ type cmdline = { do_copy : bool; in_place : bool; network_map : string NetworkMap.t; - no_trim : string list; output_alloc : Types.output_allocation; output_format : string option; output_name : string option; diff --git a/v2v/v2v.ml b/v2v/v2v.ml index 1b9e79c..e6ff8e2 100644 --- a/v2v/v2v.ml +++ b/v2v/v2v.ml @@ -98,14 +98,13 @@ let rec main () g#umount_all (); - if cmdline.no_trim <> ["*"] && - (cmdline.do_copy || cmdline.debug_overlays) then ( + if cmdline.do_copy || cmdline.debug_overlays then ( (* Doing fstrim on all the filesystems reduces the transfer size * because unused blocks are marked in the overlay and thus do * not have to be copied. *) message (f_"Mapping filesystem data to avoid copying unused and blank areas"); - do_fstrim g cmdline.no_trim inspect; + do_fstrim g inspect; ); (match conversion_mode with @@ -367,10 +366,8 @@ and check_free_space mpstats ) ) mpstats -(* Perform the fstrim. The trimming bit is easy. Dealing with the - * [--no-trim] parameter .. not so much. - *) -and do_fstrim g no_trim inspect +(* Perform the fstrim. *) +and do_fstrim g inspect (* Get all filesystems. *) let fses = g#list_filesystems () in @@ -378,39 +375,7 @@ and do_fstrim g no_trim inspect function (_, ("unknown"|"swap")) -> None | (dev, _) -> Some dev ) fses in - let fses - if no_trim = [] then fses - else ( - if verbose () then ( - printf "no_trim: %s\n" (String.concat " " no_trim); - printf "filesystems before considering no_trim: %s\n" - (String.concat " " fses) - ); - - (* Drop any filesystems that match a device name in the no_trim list. *) - let fses = List.filter ( - fun dev -> - not (List.mem (g#canonical_device_name dev) no_trim) - ) fses in - - (* Drop any mountpoints matching the no_trim list. *) - let dev_to_mp - List.map (fun (mp, dev) -> g#canonical_device_name dev, mp) - inspect.i_mountpoints in - let fses = List.filter ( - fun dev -> - try not (List.mem (List.assoc dev dev_to_mp) no_trim) - with Not_found -> true - ) fses in - - if verbose () then - printf "filesystems after considering no_trim: %s\n%!" - (String.concat " " fses); - - fses - ) in - - (* Trim the remaining filesystems. *) + (* Trim the filesystems. *) List.iter ( fun dev -> g#umount_all (); diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod index bce79c1..b654711 100644 --- a/v2v/virt-v2v.pod +++ b/v2v/virt-v2v.pod @@ -401,29 +401,6 @@ a faulty guest (one with no disks). This option is not compatible with I<-o glance> for technical reasons. -=item B<--no-trim all> - -=item B<--no-trim> mp[,mp...] - -By default virt-v2v runs L<fstrim(8)> to reduce the amount of data -that needs to be copied. This is known to break some buggy -bootloaders causing boot failures after conversion (see for example -L<https://bugzilla.redhat.com/show_bug.cgi?id=1141145#c27>). - -You can use I<--no-trim all> to disable all trimming. Note this will -greatly increase the amount of data that has to be copied and can make -virt-v2v run much more slowly. - -You can also disable trimming on selected filesystems only (specified -by a comma-separated list of their mount point(s) in the guest). -Typically you would use I<--no-trim /boot> to work around the grub bug -mentioned above. - -You can also disable trimming on partitions using the libguestfs -naming scheme for devices, eg: I<--no-trim /dev/sdb2> means do not -trim the second partition on the second block device. Use -L<virt-filesystems(1)> to list filesystem names in a guest. - =item B<-o disk> This is the same as I<-o local>. @@ -1947,7 +1924,6 @@ L<virt-sysprep(1)>, L<guestfs(3)>, L<guestfish(1)>, L<qemu-img(1)>, -L<fstrim(8)>, L<virt-v2v-copy-to-local(1)>, L<virt-v2v-test-harness(1)>, L<engine-image-uploader(8)>, -- 2.7.4
Richard W.M. Jones
2016-Apr-26 12:16 UTC
[Libguestfs] [PATCH 2/4] v2v: Remove the --vmtype option.
It will now print a warning but is otherwise ignored: virt-v2v: warning: the --vmtype option has been removed and now does nothing See: https://www.redhat.com/archives/libguestfs/2016-April/msg00178.html --- v2v/OVF.ml | 41 ++++++++++++++++++----------------------- v2v/OVF.mli | 2 +- v2v/cmdline.ml | 29 +++++++++-------------------- v2v/output_rhev.ml | 11 +++-------- v2v/output_rhev.mli | 4 ++-- v2v/output_vdsm.ml | 10 +++------- v2v/output_vdsm.mli | 2 +- v2v/test-v2v-o-vdsm-options.sh | 7 +------ v2v/types.ml | 2 -- v2v/types.mli | 3 --- v2v/virt-v2v.pod | 9 --------- 11 files changed, 38 insertions(+), 82 deletions(-) diff --git a/v2v/OVF.ml b/v2v/OVF.ml index 87ce561..84e4eb9 100644 --- a/v2v/OVF.ml +++ b/v2v/OVF.ml @@ -42,60 +42,58 @@ let iso_time (tm.tm_year + 1900) (tm.tm_mon + 1) tm.tm_mday tm.tm_hour tm.tm_min tm.tm_sec -(* Guess vmtype based on the guest inspection data. This is used - * when the [--vmtype] parameter is NOT passed. - *) +(* Guess vmtype based on the guest inspection data. *) let get_vmtype = function | { i_type = "linux"; i_distro = "rhel"; i_major_version = major; i_product_name = product } when major >= 5 && String.find product "Server" >= 0 -> - Server + `Server | { i_type = "linux"; i_distro = "rhel"; i_major_version = major } when major >= 5 -> - Desktop + `Desktop | { i_type = "linux"; i_distro = "rhel"; i_major_version = major; i_product_name = product } when major >= 3 && String.find product "ES" >= 0 -> - Server + `Server | { i_type = "linux"; i_distro = "rhel"; i_major_version = major; i_product_name = product } when major >= 3 && String.find product "AS" >= 0 -> - Server + `Server | { i_type = "linux"; i_distro = "rhel"; i_major_version = major } when major >= 3 -> - Desktop + `Desktop - | { i_type = "linux"; i_distro = "fedora" } -> Desktop + | { i_type = "linux"; i_distro = "fedora" } -> `Desktop | { i_type = "windows"; i_major_version = 5; i_minor_version = 1 } -> - Desktop (* Windows XP *) + `Desktop (* Windows XP *) | { i_type = "windows"; i_major_version = 5; i_minor_version = 2; i_product_name = product } when String.find product "XP" >= 0 -> - Desktop (* Windows XP *) + `Desktop (* Windows XP *) | { i_type = "windows"; i_major_version = 5; i_minor_version = 2 } -> - Server (* Windows 2003 *) + `Server (* Windows 2003 *) | { i_type = "windows"; i_major_version = 6; i_minor_version = 0; i_product_name = product } when String.find product "Server" >= 0 -> - Server (* Windows 2008 *) + `Server (* Windows 2008 *) | { i_type = "windows"; i_major_version = 6; i_minor_version = 0 } -> - Desktop (* Vista *) + `Desktop (* Vista *) | { i_type = "windows"; i_major_version = 6; i_minor_version = 1; i_product_name = product } when String.find product "Server" >= 0 -> - Server (* Windows 2008R2 *) + `Server (* Windows 2008R2 *) | { i_type = "windows"; i_major_version = 6; i_minor_version = 1 } -> - Server (* Windows 7 *) + `Server (* Windows 7 *) - | _ -> Server + | _ -> `Server (* Determine the ovf:OperatingSystemSection_Type from libguestfs * inspection. See ovirt-engine sources, file: @@ -252,16 +250,13 @@ let create_meta_files output_alloc sd_uuid image_uuids targets (* Create the OVF file. *) let rec create_ovf source targets guestcaps inspect - output_alloc vmtype sd_uuid image_uuids vol_uuids vm_uuid + output_alloc sd_uuid image_uuids vol_uuids vm_uuid assert (List.length targets = List.length vol_uuids); let memsize_mb = source.s_memory /^ 1024L /^ 1024L in - let vmtype - match vmtype with - | Some vmtype -> vmtype - | None -> get_vmtype inspect in - let vmtype = match vmtype with Desktop -> "0" | Server -> "1" in + let vmtype = get_vmtype inspect in + let vmtype = match vmtype with `Desktop -> "0" | `Server -> "1" in let ostype = get_ostype inspect in let origin diff --git a/v2v/OVF.mli b/v2v/OVF.mli index 626f0c3..3b260a5 100644 --- a/v2v/OVF.mli +++ b/v2v/OVF.mli @@ -26,7 +26,7 @@ val create_meta_files : Types.output_allocation -> string -> string list -> Type file is returned (one per target), and they must be written to [target_file ^ ".meta"]. *) -val create_ovf : Types.source -> Types.target list -> Types.guestcaps -> Types.inspect -> Types.output_allocation -> Types.vmtype option -> string -> string list -> string list -> string -> DOM.doc +val create_ovf : Types.source -> Types.target list -> Types.guestcaps -> Types.inspect -> Types.output_allocation -> string -> string list -> string list -> string -> DOM.doc (** Create the OVF file. *) (**/**) diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml index d35e3ba..c05dbe3 100644 --- a/v2v/cmdline.ml +++ b/v2v/cmdline.ml @@ -64,7 +64,7 @@ let parse_cmdline () let password_file = ref None in let vdsm_vm_uuid = ref None in let vdsm_ovf_output = ref None in (* default "." *) - let vmtype = ref None in + let set_string_option_once optname optref arg match !optref with | Some _ -> @@ -155,6 +155,10 @@ let parse_cmdline () let vdsm_vol_uuids = ref [] in let add_vdsm_vol_uuid s = vdsm_vol_uuids := s :: !vdsm_vol_uuids in + let vmtype_warning _ + warning (f_"the --vmtype option has been removed and now does nothing") + in + let i_options String.concat "|" (Modules_list.input_modules ()) and o_options @@ -207,8 +211,8 @@ let parse_cmdline () "uuid " ^ s_"Output VM UUID"; "--vdsm-ovf-output", Arg.String (set_string_option_once "--vdsm-ovf-output" vdsm_ovf_output), " " ^ s_"Output OVF file"; - "--vmtype", Arg.String (set_string_option_once "--vmtype" vmtype), - "server|desktop " ^ s_"Set vmtype (for RHEV)"; + "--vmtype", Arg.String vmtype_warning, + "- " ^ s_"Ignored for backwards compatibility"; ] in let argspec = set_standard_options argspec in let args = ref [] in @@ -267,13 +271,6 @@ read the man page virt-v2v(1). let vdsm_vm_uuid = !vdsm_vm_uuid in let vdsm_ovf_output match !vdsm_ovf_output with None -> "." | Some s -> s in - let vmtype - match !vmtype with - | Some "server" -> Some Server - | Some "desktop" -> Some Desktop - | None -> None - | _ -> - error (f_"unknown --vmtype option, must be \"server\" or \"desktop\"") in (* No arguments and machine-readable mode? Print out some facts * about what this binary supports. @@ -349,8 +346,6 @@ read the man page virt-v2v(1). error (f_"-o glance: -os option cannot be used in this output mode"); if qemu_boot then error (f_"-o glance: --qemu-boot option cannot be used in this output mode"); - if vmtype <> None then - error (f_"--vmtype option cannot be used with '-o glance'"); if not do_copy then error (f_"--no-copy and '-o glance' cannot be used at the same time"); Output_glance.output_glance () @@ -361,8 +356,6 @@ read the man page virt-v2v(1). match output_storage with None -> "default" | Some os -> os in if qemu_boot then error (f_"-o libvirt: --qemu-boot option cannot be used in this output mode"); - if vmtype <> None then - error (f_"--vmtype option cannot be used with '-o libvirt'"); if not do_copy then error (f_"--no-copy and '-o libvirt' cannot be used at the same time"); Output_libvirt.output_libvirt output_conn output_storage @@ -377,8 +370,6 @@ read the man page virt-v2v(1). | Some d -> d in if qemu_boot then error (f_"-o local: --qemu-boot option cannot be used in this output mode"); - if vmtype <> None then - error (f_"--vmtype option cannot be used with '-o local'"); Output_local.output_local os | `Null -> @@ -388,8 +379,6 @@ read the man page virt-v2v(1). error (f_"-o null: -os option cannot be used in this output mode"); if qemu_boot then error (f_"-o null: --qemu-boot option cannot be used in this output mode"); - if vmtype <> None then - error (f_"--vmtype option cannot be used with '-o null'"); Output_null.output_null () | `QEmu -> @@ -410,7 +399,7 @@ read the man page virt-v2v(1). | Some d -> d in if qemu_boot then error (f_"-o rhev: --qemu-boot option cannot be used in this output mode"); - Output_rhev.output_rhev os vmtype output_alloc + Output_rhev.output_rhev os output_alloc | `VDSM -> let os @@ -433,7 +422,7 @@ read the man page virt-v2v(1). vm_uuid = vdsm_vm_uuid; ovf_output = vdsm_ovf_output; } in - Output_vdsm.output_vdsm os vdsm_params vmtype output_alloc in + Output_vdsm.output_vdsm os vdsm_params output_alloc in { compressed = compressed; debug_overlays = debug_overlays; diff --git a/v2v/output_rhev.ml b/v2v/output_rhev.ml index b2a5617..b1c6850 100644 --- a/v2v/output_rhev.ml +++ b/v2v/output_rhev.ml @@ -102,7 +102,7 @@ and check_storage_domain domain_class os mp (* UID:GID required for files and directories when writing to ESD. *) let uid = 36 and gid = 36 -class output_rhev os vmtype output_alloc +class output_rhev os output_alloc (* Create a UID-switching handle. If we're not root, create a dummy * one because we cannot switch UIDs. *) @@ -115,12 +115,7 @@ class output_rhev os vmtype output_alloc object inherit output - method as_options - sprintf "-o rhev -os %s%s" os - (match vmtype with - | None -> "" - | Some Server -> " --vmtype server" - | Some Desktop -> " --vmtype desktop") + method as_options = sprintf "-o rhev -os %s" os method supported_firmware = [ TargetBIOS ] @@ -284,7 +279,7 @@ object (* Create the metadata. *) let ovf = OVF.create_ovf source targets guestcaps inspect - output_alloc vmtype esd_uuid image_uuids vol_uuids vm_uuid in + output_alloc esd_uuid image_uuids vol_uuids vm_uuid in (* Write it to the metadata file. *) let dir = esd_mp // esd_uuid // "master" // "vms" // vm_uuid in diff --git a/v2v/output_rhev.mli b/v2v/output_rhev.mli index bd9ae85..27df737 100644 --- a/v2v/output_rhev.mli +++ b/v2v/output_rhev.mli @@ -21,7 +21,7 @@ val mount_and_check_storage_domain : string -> string -> (string * string) (** This helper function is also used by the VDSM target. *) -val output_rhev : string -> Types.vmtype option -> Types.output_allocation -> Types.output -(** [output_rhev os vmtype output_alloc] creates and +val output_rhev : string -> Types.output_allocation -> Types.output +(** [output_rhev os output_alloc] creates and returns a new {!Types.output} object specialized for writing output to RHEV-M or oVirt Export Storage Domain. *) diff --git a/v2v/output_vdsm.ml b/v2v/output_vdsm.ml index 555f0b8..6619eee 100644 --- a/v2v/output_vdsm.ml +++ b/v2v/output_vdsm.ml @@ -33,22 +33,18 @@ type vdsm_params = { ovf_output : string; } -class output_vdsm os vdsm_params vmtype output_alloc +class output_vdsm os vdsm_params output_alloc 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" os (String.concat "" (List.map (sprintf " --vdsm-image-uuid %s") vdsm_params.image_uuids)) (String.concat "" (List.map (sprintf " --vdsm-vol-uuid %s") vdsm_params.vol_uuids)) vdsm_params.vm_uuid vdsm_params.ovf_output - (match vmtype with - | None -> "" - | Some Server -> " --vmtype server" - | Some Desktop -> " --vmtype desktop") method supported_firmware = [ TargetBIOS ] @@ -171,7 +167,7 @@ object (* Create the metadata. *) let ovf = OVF.create_ovf source targets guestcaps inspect - output_alloc vmtype dd_uuid + output_alloc dd_uuid vdsm_params.image_uuids vdsm_params.vol_uuids vdsm_params.vm_uuid in diff --git a/v2v/output_vdsm.mli b/v2v/output_vdsm.mli index 1a88eaa..532227a 100644 --- a/v2v/output_vdsm.mli +++ b/v2v/output_vdsm.mli @@ -26,7 +26,7 @@ type vdsm_params = { } (** Miscellaneous extra command line parameters used by VDSM. *) -val output_vdsm : string -> vdsm_params -> Types.vmtype option -> Types.output_allocation -> Types.output +val output_vdsm : string -> vdsm_params -> Types.output_allocation -> Types.output (** [output_vdsm os rhev_params output_alloc] creates and returns a new {!Types.output} object specialized for writing output to Data Domains directly under VDSM control. *) diff --git a/v2v/test-v2v-o-vdsm-options.sh b/v2v/test-v2v-o-vdsm-options.sh index 6ae5d56..866178c 100755 --- a/v2v/test-v2v-o-vdsm-options.sh +++ b/v2v/test-v2v-o-vdsm-options.sh @@ -16,7 +16,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# Test -o vdsm options: --vmtype and --vdsm-*-uuid +# Test -o vdsm options --vdsm-*-uuid unset CDPATH export LANG=C @@ -61,7 +61,6 @@ mkdir $d/12345678-1234-1234-1234-123456789abc/master/vms/VM $VG virt-v2v --debug-gc \ -i libvirt -ic "$libvirt_uri" windows \ -o vdsm -os $d/12345678-1234-1234-1234-123456789abc \ - --vmtype desktop \ --vdsm-image-uuid IMAGE \ --vdsm-vol-uuid VOL \ --vdsm-vm-uuid VM \ @@ -70,10 +69,6 @@ $VG virt-v2v --debug-gc \ # Test the OVF metadata was created. test -f $d/12345678-1234-1234-1234-123456789abc/master/vms/VM/VM.ovf -# Test the OVF metadata contains <VmType>0</VmType> (desktop). -grep '<VmType>0</VmType>' \ - $d/12345678-1234-1234-1234-123456789abc/master/vms/VM/VM.ovf - pushd $d/12345678-1234-1234-1234-123456789abc/images/IMAGE # Test the disk .meta was created. diff --git a/v2v/types.ml b/v2v/types.ml index 25e0e15..08e1631 100644 --- a/v2v/types.ml +++ b/v2v/types.ml @@ -448,8 +448,6 @@ type root_choice = AskRoot | SingleRoot | FirstRoot | RootDev of string type output_allocation = Sparse | Preallocated -type vmtype = Desktop | Server - class virtual input = object method virtual as_options : string method virtual source : unit -> source diff --git a/v2v/types.mli b/v2v/types.mli index 756665c..dacc991 100644 --- a/v2v/types.mli +++ b/v2v/types.mli @@ -312,9 +312,6 @@ type root_choice = AskRoot | SingleRoot | FirstRoot | RootDev of string type output_allocation = Sparse | Preallocated (** Type of [-oa] (output allocation) option. *) -type vmtype = Desktop | Server -(** Type of [--vmtype] option. *) - (** {2 Input object} There is one of these used for the [-i] option. *) diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod index b654711..f8d05ee 100644 --- a/v2v/virt-v2v.pod +++ b/v2v/virt-v2v.pod @@ -651,15 +651,6 @@ Enable verbose messages for debugging. Display version number and exit. -=item B<--vmtype desktop> - -=item B<--vmtype server> - -For the I<-o rhev> or I<-o vdsm> targets only, specify the type of -guest. You can set this to C<desktop> or C<server>. If the option is -not given, then a suitable default is chosen based on the detected -guest operating system. - =item B<-x> Enable tracing of libguestfs API calls. -- 2.7.4
Richard W.M. Jones
2016-Apr-26 12:16 UTC
[Libguestfs] [PATCH 3/4] v2v: OVF: Better mapping for inspection data to vmtype.
The old mapping code was directly copied from old virt-v2v, translated from Perl to OCaml. The new mapping code does a few things more accurately: - Use the i_product_variant field (Windows InstallationType) if available. - Simplify rules, so there is only one special case needed for RHEL 3/4. - Don't assume Fedora == Desktop. - Don't assume all later Windows variants are server. - Works for Windows > 7. --- v2v/OVF.ml | 55 +++++++++++++++++-------------------------------------- 1 file changed, 17 insertions(+), 38 deletions(-) diff --git a/v2v/OVF.ml b/v2v/OVF.ml index 84e4eb9..8a6f13e 100644 --- a/v2v/OVF.ml +++ b/v2v/OVF.ml @@ -44,55 +44,34 @@ let iso_time (* Guess vmtype based on the guest inspection data. *) let get_vmtype = function - | { i_type = "linux"; i_distro = "rhel"; i_major_version = major; + (* Special cases for RHEL 3 & RHEL 4. *) + | { i_type = "linux"; i_distro = "rhel"; i_major_version = (3|4); i_product_name = product } - when major >= 5 && String.find product "Server" >= 0 -> + when String.find product "ES" >= 0 -> `Server - | { i_type = "linux"; i_distro = "rhel"; i_major_version = major } - when major >= 5 -> - `Desktop - - | { i_type = "linux"; i_distro = "rhel"; i_major_version = major; - i_product_name = product } - when major >= 3 && String.find product "ES" >= 0 -> - `Server - - | { i_type = "linux"; i_distro = "rhel"; i_major_version = major; + | { i_type = "linux"; i_distro = "rhel"; i_major_version = (3|4); i_product_name = product } - when major >= 3 && String.find product "AS" >= 0 -> + when String.find product "AS" >= 0 -> `Server - | { i_type = "linux"; i_distro = "rhel"; i_major_version = major } - when major >= 3 -> + | { i_type = "linux"; i_distro = "rhel"; i_major_version = (3|4) } -> `Desktop - | { i_type = "linux"; i_distro = "fedora" } -> `Desktop - - | { i_type = "windows"; i_major_version = 5; i_minor_version = 1 } -> - `Desktop (* Windows XP *) + (* For Windows (and maybe Linux in future, but it is not set now), + * use the i_product_variant field. + *) + | { i_product_variant = ("Server"|"Server Core"|"Embedded") } -> `Server + | { i_product_variant = "Client" } -> `Desktop - | { i_type = "windows"; i_major_version = 5; i_minor_version = 2; - i_product_name = product } when String.find product "XP" >= 0 -> - `Desktop (* Windows XP *) - - | { i_type = "windows"; i_major_version = 5; i_minor_version = 2 } -> - `Server (* Windows 2003 *) - - | { i_type = "windows"; i_major_version = 6; i_minor_version = 0; - i_product_name = product } when String.find product "Server" >= 0 -> - `Server (* Windows 2008 *) - - | { i_type = "windows"; i_major_version = 6; i_minor_version = 0 } -> - `Desktop (* Vista *) - - | { i_type = "windows"; i_major_version = 6; i_minor_version = 1; - i_product_name = product } when String.find product "Server" >= 0 -> - `Server (* Windows 2008R2 *) + (* If the product name has "Server" or "Desktop" in it, use that. *) + | { i_product_name = product } when String.find product "Server" >= 0 -> + `Server - | { i_type = "windows"; i_major_version = 6; i_minor_version = 1 } -> - `Server (* Windows 7 *) + | { i_product_name = product } when String.find product "Desktop" >= 0 -> + `Desktop + (* Otherwise return server, a safe choice. *) | _ -> `Server (* Determine the ovf:OperatingSystemSection_Type from libguestfs -- 2.7.4
Richard W.M. Jones
2016-Apr-26 12:16 UTC
[Libguestfs] [PATCH 4/4] v2v: Add a slow test to ensure trimming doesn't regress (RHBZ#1264332).
--- v2v/Makefile.am | 3 +- v2v/test-v2v-trim.sh | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100755 v2v/test-v2v-trim.sh diff --git a/v2v/Makefile.am b/v2v/Makefile.am index c840a73..0203317 100644 --- a/v2v/Makefile.am +++ b/v2v/Makefile.am @@ -331,7 +331,8 @@ check-valgrind: $(MAKE) VG="$(abs_top_builddir)/run @VG@" check SLOW_TESTS = \ - test-v2v-real-conversions.sh + test-v2v-real-conversions.sh \ + test-v2v-trim.sh check-slow: $(real_guests:%=%.img) $(MAKE) check TESTS="$(SLOW_TESTS)" SLOW=1 diff --git a/v2v/test-v2v-trim.sh b/v2v/test-v2v-trim.sh new file mode 100755 index 0000000..6d3cb39 --- /dev/null +++ b/v2v/test-v2v-trim.sh @@ -0,0 +1,96 @@ +#!/bin/bash - +# libguestfs virt-v2v test script +# Copyright (C) 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# Test that trimming doesn't regress. Suggested by Ming Xie in +# https://bugzilla.redhat.com/show_bug.cgi?id=1264332 + +unset CDPATH +export LANG=C +set -e + +if [ -z "$SLOW" ]; then + echo "$0: use 'make check-slow' to run this test" + exit 77 +fi + +# This test is expected to fail on NFS. +if [ -n "$SKIP_TEST_V2V_TRIM_SH" ]; then + echo "$0: test skipped because environment variable is set" + exit 77 +fi + +if [ "$(guestfish get-backend)" = "uml" ]; then + echo "$0: skipping test because uml backend does not support discard" + exit 77 +fi + +# This should be created by Makefile.am when doing 'make check-slow'. +# If this fails it's probably because you're not running the test with +# 'make check-slow' but running it directly. +f="$(pwd)/fedora-20.img" +if ! test -f "$f" || ! test -s "$f"; then + echo "$0: Fedora 20 guest image was not created by Makefile" + exit 1 +fi + +d=test-v2v-trim.d +rm -rf $d +mkdir $d + +qemu-img create -f qcow2 -b "$f" $d/fedora.qcow2 + +guestfish -a $d/fedora.qcow2 -i <<EOF +fill 1 500M /big +fill 1 100M /boot/big +sync +rm /big +rm /boot/big +umount-all +EOF + +size_before=$(du -s "$f" | awk '{print $1}') +echo size_before=$size_before + +if [ $size_before -lt 800000 ]; then + echo "test virt-v2v trim: size_before ($size_before) too small" + exit 1 +fi + +virt-v2v --debug-gc \ + -i disk $d/fedora.qcow2 \ + -o local -os $d + +# Test the libvirt XML metadata and a disk was created. +test -f $d/fedora.xml +test -f $d/fedora-sda + +size_after=$(du -s $d/fedora-sda | awk '{print $1}') +echo size_after=$size_after + +# We're expecting the image to grow a bit because of the changes made +# by conversion (I observed growth of about 9MB). That's OK. If it +# grows by ~ 500 + 100 MB, then that's not OK. So choose a threshold +# of 300 MB. + +if [ $((size_after-size_before)) -gt 300000 ]; then + echo "test virt-v2v trim: size_after ($size_after) too large" + echo "trimming failed" + exit 1 +fi + +rm -r $d -- 2.7.4
Apparently Analagous Threads
- [PATCH] v2v: Rename OVF module to Create_ovf.
- [PATCH 0/4] Only tell people to use -v -x when reporting bugs if they're not using those flags.
- [PATCH v2 0/4] Only tell people to use -v -x when reporting bugs if they're not using those flags.
- [PATCH] v2v: adding --vdsm-ovf-output option
- [PATCH 0/3] Make generated OVF more conforming to standard