From 3a6636fc05b7b91375c8fb2d755e8418f80b4d87 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 26 Apr 2016 10:41:39 +0100 Subject: [PATCH] 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 87ce561b0..84e4eb99f 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 626f0c3da..3b260a519 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 d35e3ba2a..c05dbe3d9 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 b2a561709..b1c685097 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 bd9ae8538..27df73762 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 555f0b840..6619eeed2 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 1a88eaa6f..532227a3c 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 6ae5d562c..866178c1e 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 0 (desktop). -grep '0' \ - $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 25e0e1533..08e1631e2 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 756665c7d..dacc99194 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 b65471152..f8d05ee99 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 or C. 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.