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
This commit is contained in:
Richard W.M. Jones
2016-04-26 10:41:39 +01:00
parent b81e8ef162
commit 3a6636fc05
11 changed files with 38 additions and 82 deletions

View File

@@ -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 =

View File

@@ -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. *)
(**/**)

View File

@@ -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;

View File

@@ -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

View File

@@ -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. *)

View File

@@ -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

View File

@@ -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. *)

View File

@@ -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.

View File

@@ -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

View File

@@ -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. *)

View File

@@ -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.