mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
v2v: ova: check libvirt version before OVA import
Libvirt < 3.1.0 lacks enough support for json: pseudo-URLs. Notably it does not allow use of "raw" driver that we need. Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
This commit is contained in:
committed by
Richard W.M. Jones
parent
2dbf6bd7b7
commit
90521da5d4
@@ -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,6 +402,7 @@ endif
|
||||
v2v_unit_tests_BOBJECTS = \
|
||||
types.cmo \
|
||||
uefi.cmo \
|
||||
domainxml.cmo \
|
||||
utils.cmo \
|
||||
DOM.cmo \
|
||||
OVF.cmo \
|
||||
|
||||
@@ -91,7 +91,8 @@ object
|
||||
match detect_file_type ova with
|
||||
| `Tar ->
|
||||
(* Normal ovas are tar file (not compressed). *)
|
||||
if qemu_img_supports_offset_and_size () then (
|
||||
if qemu_img_supports_offset_and_size () &&
|
||||
libvirt_supports_json_raw_driver () then (
|
||||
(* In newer QEMU we don't have to extract everything.
|
||||
* We can access disks inside the tar archive directly.
|
||||
*)
|
||||
|
||||
14
v2v/utils.ml
14
v2v/utils.ml
@@ -119,6 +119,20 @@ 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 =
|
||||
|
||||
@@ -55,6 +55,11 @@ 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.
|
||||
|
||||
Reference in New Issue
Block a user