[Pkg-libvirt-commits] [libguestfs] 148/266: v2v: Print log message when opening the source.
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 d1c8240b76d4c900ddb61e4a9c3e0e8d9f4907b3
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Thu Aug 21 13:27:09 2014 +0100
v2v: Print log message when opening the source.
---
v2v/input_disk.ml | 7 +++++++
v2v/input_libvirt.ml | 17 ++++++++++++++---
v2v/test-v2v-print-source.sh | 12 ++++++++----
v2v/types.ml | 1 +
v2v/types.mli | 3 +++
v2v/v2v.ml | 1 +
6 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/v2v/input_disk.ml b/v2v/input_disk.ml
index 85418ce..c0b2541 100644
--- a/v2v/input_disk.ml
+++ b/v2v/input_disk.ml
@@ -27,6 +27,13 @@ open Utils
class input_disk input_format disk = object
inherit input
+ method as_options =
+ sprintf "-i disk%s %s"
+ (match input_format with
+ | None -> ""
+ | Some fmt -> " -if " ^ fmt)
+ disk
+
method source () =
(* What name should we use for the guest? We try to derive it from
* the filename passed in. Users can override this using the
diff --git a/v2v/input_libvirt.ml b/v2v/input_libvirt.ml
index 3a3d2ba..017bc48 100644
--- a/v2v/input_libvirt.ml
+++ b/v2v/input_libvirt.ml
@@ -27,10 +27,12 @@ open Utils
let identity x = x
class input_libvirt
- ?(map_source_file = identity) ?(map_source_dev = identity) xml =
+ options ?(map_source_file = identity) ?(map_source_dev = identity) xml =
object
inherit input
+ method as_options = options
+
method source () =
let doc = Xml.parse_memory xml in
let xpathctx = Xml.xpath_new_context doc in
@@ -244,6 +246,8 @@ end
(* -i libvirtxml *)
let input_libvirtxml file =
+ let options = "-i libvirtxml " ^ file in
+
let xml = read_whole_file file in
(* When reading libvirt XML from a file (-i libvirtxml) we allow
@@ -257,10 +261,17 @@ let input_libvirtxml file =
if not (Filename.is_relative path) then path else dir // path
in
- new input_libvirt ~map_source_file xml
+ new input_libvirt options ~map_source_file xml
(* -i libvirt [-ic libvirt_uri] *)
let input_libvirt libvirt_uri guest =
+ let options =
+ sprintf "-i libvirt%s %s"
+ (match libvirt_uri with
+ | None -> ""
+ | Some uri -> " -ic " ^ uri)
+ guest in
+
(* Depending on the libvirt URI we may need to convert <source/>
* paths so we can access them remotely (if that is possible). This
* is only true for remote, non-NULL URIs. (We assume the user
@@ -301,4 +312,4 @@ let input_libvirt libvirt_uri guest =
let lines = external_command ~prog cmd in
let xml = String.concat "\n" lines in
- new input_libvirt ?map_source_file ?map_source_dev xml
+ new input_libvirt options ?map_source_file ?map_source_dev xml
diff --git a/v2v/test-v2v-print-source.sh b/v2v/test-v2v-print-source.sh
index 39119a0..b769dac 100755
--- a/v2v/test-v2v-print-source.sh
+++ b/v2v/test-v2v-print-source.sh
@@ -45,9 +45,14 @@ $VG ./virt-v2v --debug-gc \
-o local -os $d \
--print-source > $d/output
-if [ "$(cat $d/output)" != "Source guest information (--print-source option):
+mv $d/output $d/output.orig
+< $d/output.orig \
+grep -v 'Opening the source' |
+grep -v 'Source guest information' |
+grep -v '^$' \
+> $d/output
- source name: windows
+if [ "$(cat $d/output)" != " source name: windows
hypervisor type: test
memory: 1073741824 (bytes)
nr vCPUs: 1
@@ -57,10 +62,9 @@ hypervisor type: test
disks:
/home/rjones/d/libguestfs/tests/guests/windows.img (raw) [vda]
removable media:
-
NICs:" ]; then
echo "$0: unexpected output from test:"
- cat $d/output
+ cat $d/output.orig
exit 1
fi
diff --git a/v2v/types.ml b/v2v/types.ml
index 795ac08..ab0e921 100644
--- a/v2v/types.ml
+++ b/v2v/types.ml
@@ -180,6 +180,7 @@ type output_rhev_params = {
}
class virtual input = object
+ method virtual as_options : string
method virtual source : unit -> source
end
diff --git a/v2v/types.mli b/v2v/types.mli
index b8d867a..20bf526 100644
--- a/v2v/types.mli
+++ b/v2v/types.mli
@@ -115,6 +115,9 @@ type guestcaps = {
(** Guest capabilities after conversion. eg. Was virtio found or installed? *)
class virtual input : object
+ method virtual as_options : string
+ (** Converts the input object back to the equivalent command line options.
+ This is just used for pretty-printing log messages. *)
method virtual source : unit -> source
(** Examine the source hypervisor and create a source struct. *)
end
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index a5d4d75..b820138 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -39,6 +39,7 @@ let rec main () =
let msg fs = make_message_function ~quiet fs in
+ msg (f_"Opening the source %s") input#as_options;
let source = input#source () in
(* Print source and stop. *)
--
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