[Pkg-libvirt-commits] [libguestfs] 151/266: v2v: Remove ov_vol_uuid hack.
Hilko Bengen
bengen at moszumanska.debian.org
Fri Oct 3 14:41:54 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to annotated tag debian/1%1.27.35-1
in repository libguestfs.
commit f5fda273b18380f44d399dae230ec622335e9f23
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Thu Aug 21 15:00:53 2014 +0100
v2v: Remove ov_vol_uuid hack.
Now that we're using classes for outputs, we can hide the RHEV volume
UUIDs in the output_rhev class.
---
v2v/output_RHEV.ml | 74 +++++++++++++++++++++++++++++-------------------------
v2v/types.ml | 3 ---
v2v/types.mli | 3 ---
v2v/v2v.ml | 3 +--
4 files changed, 41 insertions(+), 42 deletions(-)
diff --git a/v2v/output_RHEV.ml b/v2v/output_RHEV.ml
index 41eafad..fec9a74 100644
--- a/v2v/output_RHEV.ml
+++ b/v2v/output_RHEV.ml
@@ -79,11 +79,17 @@ object
(* Export Storage Domain mountpoint. *)
val mutable esd = { mp = ""; uuid = "" }
+
(* Target image directory, UUID. *)
val mutable image_dir = ""
val mutable image_uuid = ""
+
(* Target VM UUID. *)
val mutable vm_uuid = ""
+
+ (* Map overlay to volume UUID. Key is [ov.ov_sd] field which is unique. *)
+ val vol_uuid = Hashtbl.create 13
+
(* Flag to indicate if the target image (image_dir) should be
* deleted. This is set to false once we know the conversion was
* successful.
@@ -189,34 +195,34 @@ object
* line parameters or else we invent them here.
*)
let create_uuids () =
- let image_uuid =
- match rhev_params.image_uuid with
+ image_uuid <-
+ (match rhev_params.image_uuid with
| Some uuid -> uuid
- | None -> uuidgen ~prog () in
- let vm_uuid =
- match rhev_params.vm_uuid with
+ | None -> uuidgen ~prog ());
+ vm_uuid <-
+ (match rhev_params.vm_uuid with
| Some uuid -> uuid
- | None -> uuidgen ~prog () in
-
- (* ... and for volumes. *)
- let overlays =
- match rhev_params.vol_uuids with
- | [] ->
- List.map (
- fun ov ->
- let uuid = uuidgen ~prog () in
- { ov with ov_vol_uuid = uuid }
- ) overlays
- | uuids ->
- try
- List.map (
- fun (ov, uuid) -> { ov with ov_vol_uuid = uuid }
- ) (List.combine overlays uuids)
- with Invalid_argument _ ->
- error (f_"the number of '--rhev-vol-uuid' parameters passed on the command line has to match the number of guest disk images (for this guest: %d)")
- (List.length overlays) in
-
- image_uuid, vm_uuid, overlays
+ | None -> uuidgen ~prog ());
+
+ (match rhev_params.vol_uuids with
+ | [] ->
+ (* Generate random volume UUIDs for each overlay. *)
+ List.iter (
+ fun ov ->
+ let uuid = uuidgen ~prog () in
+ Hashtbl.replace vol_uuid ov.ov_sd uuid
+ ) overlays
+ | uuids ->
+ (* Use the volume UUIDs passed to us on the command line. *)
+ try
+ List.iter (
+ fun (ov, uuid) ->
+ Hashtbl.replace vol_uuid ov.ov_sd uuid
+ ) (List.combine overlays uuids)
+ with Invalid_argument _ ->
+ error (f_"the number of '--rhev-vol-uuid' parameters passed on the command line has to match the number of guest disk images (for this guest: %d)")
+ (List.length overlays)
+ )
in
esd <- mount_and_check_export_storage_domain ();
@@ -224,11 +230,7 @@ object
eprintf "RHEV: ESD mountpoint: %s\nRHEV: ESD UUID: %s\n%!"
esd.mp esd.uuid;
- let overlays =
- let _image_uuid, _vm_uuid, overlays = create_uuids () in
- image_uuid <- _image_uuid;
- vm_uuid <- _vm_uuid;
- overlays in
+ create_uuids ();
(* We need to create the target image directory so there's a place
* for the main program to copy the images to. However if image
@@ -265,7 +267,10 @@ object
List.map (
fun ov ->
- let target_file = image_dir // ov.ov_vol_uuid in
+ let vol_uuid =
+ try Hashtbl.find vol_uuid ov.ov_sd
+ with Not_found -> assert false in
+ let target_file = image_dir // vol_uuid in
if verbose then
eprintf "RHEV: will export %s to %s\n%!" ov.ov_sd target_file;
@@ -441,8 +446,9 @@ object
fun i ov ->
let is_boot_drive = i == 0 in
- let vol_uuid = ov.ov_vol_uuid in
- assert (vol_uuid <> "");
+ let vol_uuid =
+ try Hashtbl.find vol_uuid ov.ov_sd
+ with Not_found -> assert false in
let fileref = image_uuid // vol_uuid in
diff --git a/v2v/types.ml b/v2v/types.ml
index d364e07..0d7238c 100644
--- a/v2v/types.ml
+++ b/v2v/types.ml
@@ -125,7 +125,6 @@ type overlay = {
ov_preallocation : string option;
ov_source_file : string;
ov_source_format : string option;
- ov_vol_uuid : string;
}
let string_of_overlay ov =
@@ -138,7 +137,6 @@ ov_virtual_size = %Ld
ov_preallocation = %s
ov_source_file = %s
ov_source_format = %s
-ov_vol_uuid = %s
"
ov.ov_overlay
ov.ov_target_file
@@ -148,7 +146,6 @@ ov_vol_uuid = %s
(match ov.ov_preallocation with None -> "None" | Some s -> s)
ov.ov_source_file
(match ov.ov_source_format with None -> "None" | Some s -> s)
- ov.ov_vol_uuid
type inspect = {
i_root : string;
diff --git a/v2v/types.mli b/v2v/types.mli
index daa8360..5778a11 100644
--- a/v2v/types.mli
+++ b/v2v/types.mli
@@ -79,9 +79,6 @@ type overlay = {
*)
ov_source_file : string; (** qemu URI for source file. *)
ov_source_format : string option; (** Source file format, if known. *)
-
- (* Only used by RHEV. XXX Should be parameterized type. *)
- ov_vol_uuid : string; (** RHEV volume UUID *)
}
(** Disk overlays and destination disks. *)
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index b820138..66bdb72 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -264,8 +264,7 @@ and initialize_target ~verbose g
ov_target_file = "";
ov_target_format = format;
ov_sd = sd; ov_virtual_size = vsize; ov_preallocation = preallocation;
- ov_source_file = qemu_uri; ov_source_format = backing_format;
- ov_vol_uuid = "" }
+ ov_source_file = qemu_uri; ov_source_format = backing_format }
) overlays in
let overlays = output#prepare_output source overlays in
overlays
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git
More information about the Pkg-libvirt-commits
mailing list