[Pkg-libvirt-commits] [libguestfs] 142/266: v2v: Let source.s_name be the renamed guest name (in case we use -on option).
Hilko Bengen
bengen at moszumanska.debian.org
Fri Oct 3 14:41:53 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 e787c7f213f67cc53e41774f2f6b363b517fe7c1
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Thu Aug 21 09:12:04 2014 +0100
v2v: Let source.s_name be the renamed guest name (in case we use -on option).
The original guest name is saved in s_orig_name, although I checked
all uses of s_name and nothing needs it at the moment.
---
v2v/source_disk.ml | 2 +-
v2v/source_libvirt.ml | 2 +-
v2v/types.ml | 1 +
v2v/types.mli | 3 +++
v2v/v2v.ml | 42 +++++++++++++++++++++---------------------
5 files changed, 27 insertions(+), 23 deletions(-)
diff --git a/v2v/source_disk.ml b/v2v/source_disk.ml
index 50270f4..4f29f97 100644
--- a/v2v/source_disk.ml
+++ b/v2v/source_disk.ml
@@ -65,7 +65,7 @@ let create input_format disk =
let source = {
s_dom_type = "kvm";
- s_name = name;
+ s_name = name; s_orig_name = name;
s_memory = 2048L *^ 1024L *^ 1024L; (* 2048 MB *)
s_vcpu = 1; (* 1 vCPU is a safe default *)
s_arch = Config.host_cpu;
diff --git a/v2v/source_libvirt.ml b/v2v/source_libvirt.ml
index 6ca8120..9e33332 100644
--- a/v2v/source_libvirt.ml
+++ b/v2v/source_libvirt.ml
@@ -225,7 +225,7 @@ let create_xml ?(map_source_file = identity) ?(map_source_dev = identity) xml =
{
s_dom_type = dom_type;
- s_name = name;
+ s_name = name; s_orig_name = name;
s_memory = memory;
s_vcpu = vcpu;
s_arch = arch;
diff --git a/v2v/types.ml b/v2v/types.ml
index fc3253e..bd8db11 100644
--- a/v2v/types.ml
+++ b/v2v/types.ml
@@ -60,6 +60,7 @@ let output_as_options = function
type source = {
s_dom_type : string;
s_name : string;
+ s_orig_name : string;
s_memory : int64;
s_vcpu : int;
s_arch : string;
diff --git a/v2v/types.mli b/v2v/types.mli
index 0307664..565156a 100644
--- a/v2v/types.mli
+++ b/v2v/types.mli
@@ -44,6 +44,9 @@ val output_as_options : output -> string
type source = {
s_dom_type : string; (** Source domain type, eg "kvm" *)
s_name : string; (** Guest name. *)
+ s_orig_name : string; (** Original guest name (if we rename
+ the guest using -on, original is
+ still saved here). *)
s_memory : int64; (** Memory size (bytes). *)
s_vcpu : int; (** Number of CPUs. *)
s_arch : string; (** Architecture. *)
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index 8aa6c15..36dcd7a 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -49,6 +49,15 @@ let rec main () =
if verbose then printf "%s%!" (string_of_source source);
+ (* Map source name. *)
+ let source =
+ match output_name with
+ | None -> source
+ (* Note the s_orig_name field retains the original name in case we
+ * need it for some reason.
+ *)
+ | Some name -> { source with s_name = name } in
+
(* Create a qcow2 v3 overlay to protect the source image(s). There
* is a specific reason to use the newer qcow2 variant: Because the
* L2 table can store zero clusters efficiently, and because
@@ -194,20 +203,15 @@ let rec main () =
(* Create output metadata. *)
msg (f_"Creating output metadata");
- let () =
- (* Are we going to rename the guest? *)
- let renamed_source =
- match output_name with
- | None -> source
- | Some name -> { source with s_name = name } in
- match output with
- | OutputLibvirt (oc, os) ->
- Target_libvirt.create_metadata oc os renamed_source overlays guestcaps
- | OutputLocal dir ->
- Target_local.create_metadata dir renamed_source overlays guestcaps
- | OutputRHEV (os, rhev_params) ->
- Target_RHEV.create_metadata os rhev_params renamed_source output_alloc
- overlays inspect guestcaps in
+ (match output with
+ | OutputLibvirt (oc, os) ->
+ Target_libvirt.create_metadata oc os source overlays guestcaps
+ | OutputLocal dir ->
+ Target_local.create_metadata dir source overlays guestcaps
+ | OutputRHEV (os, rhev_params) ->
+ Target_RHEV.create_metadata os rhev_params source output_alloc
+ overlays inspect guestcaps
+ );
msg (f_"Finishing off");
delete_target_on_exit := false; (* Don't delete target on exit. *)
@@ -250,17 +254,13 @@ and initialize_target ~verbose g
ov_vol_uuid = "" }
) overlays in
let overlays =
- let renamed_source =
- match output_name with
- | None -> source
- | Some name -> { source with s_name = name } in
match output with
| OutputLibvirt (oc, os) ->
- Target_libvirt.initialize oc os renamed_source overlays
- | OutputLocal dir -> Target_local.initialize dir renamed_source overlays
+ Target_libvirt.initialize oc os source overlays
+ | OutputLocal dir -> Target_local.initialize dir source overlays
| OutputRHEV (os, rhev_params) ->
Target_RHEV.initialize ~verbose
- os rhev_params renamed_source output_alloc overlays in
+ os rhev_params source output_alloc overlays in
overlays
and inspect_source g root_choice =
--
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