v2v: ova: Move libvirt version test to input_ova.ml.

Updates commit 90521da5d4.
This commit is contained in:
Richard W.M. Jones
2017-02-24 08:50:22 +00:00
parent df2006b275
commit 94f44b9983
4 changed files with 17 additions and 22 deletions

View File

@@ -63,10 +63,10 @@ SOURCES_MLI = \
SOURCES_ML = \
types.ml \
uefi.ml \
domainxml.ml \
utils.ml \
name_from_disk.ml \
vCenter.ml \
domainxml.ml \
DOM.ml \
changeuid.ml \
OVF.ml \
@@ -175,9 +175,9 @@ virt_v2v_copy_to_local_CFLAGS = \
COPY_TO_LOCAL_BOBJECTS = \
uefi.cmo \
domainxml.cmo \
utils.cmo \
vCenter.cmo \
domainxml.cmo \
copy_to_local.cmo
COPY_TO_LOCAL_XOBJECTS = $(COPY_TO_LOCAL_BOBJECTS:.cmo=.cmx)
@@ -402,7 +402,6 @@ endif
v2v_unit_tests_BOBJECTS = \
types.cmo \
uefi.cmo \
domainxml.cmo \
utils.cmo \
DOM.cmo \
OVF.cmo \

View File

@@ -27,6 +27,21 @@ open Utils
open Xpath_helpers
open Name_from_disk
(* Return true if [libvirt] supports ["json:"] pseudo-URLs and accepts the
* ["raw"] driver. Function also returns true if [libvirt] backend is not
* used. This didn't work in libvirt < 3.1.0.
*)
let libvirt_supports_json_raw_driver () =
let libguestfs_backend = (open_guestfs ())#get_backend () in
let libguestfs_backend, _ = String.split ":" libguestfs_backend in
if libguestfs_backend = "libvirt" then (
let sup = Domainxml.libvirt_get_version () >= (3, 1, 0) in
debug "libvirt supports \"raw\" driver in json URL: %B" sup;
sup
)
else
true
class input_ova ova =
let tmpdir =
let base_dir = (open_guestfs ())#get_cachedir () in

View File

@@ -119,20 +119,6 @@ let qemu_img_supports_offset_and_size () =
debug "qemu-img supports \"offset\" and \"size\" in json URLs: %b" r;
r
(* Libvirt < 3.1.0 lacks enough support for json: pseudo-URLs we use as backing
* files, when importing OVAs directly without extracting them first.
*)
let libvirt_supports_json_raw_driver () =
let libguestfs_backend = (open_guestfs ())#get_backend () in
let libguestfs_backend, _ = String.split ":" libguestfs_backend in
if libguestfs_backend = "libvirt" then (
let sup = Domainxml.libvirt_get_version () >= (3, 1, 0) in
debug "libvirt supports \"raw\" driver in json URL: %B" sup;
sup
)
else
true
let find_file_in_tar tar filename =
let lines = external_command (sprintf "tar tRvf %s" (Filename.quote tar)) in
let rec loop lines =

View File

@@ -55,11 +55,6 @@ val qemu_img_supports_offset_and_size : unit -> bool
(** Return true iff [qemu-img] supports the ["offset"] and ["size"]
parameters to open a subset of a file. *)
val libvirt_supports_json_raw_driver : unit -> bool
(** Return true if [libvirt] supports ["json:"] pseudo-URLs and accepts the
["raw"] driver. Function also returns true if [libvirt] backend is not
used. *)
val find_file_in_tar : string -> string -> int64 * int64
(** [find_file_in_tar tar filename] looks up file in [tar] archive and returns
a tuple containing at which byte it starts and how long the file is.