mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0160-v2v-Dump-inspect-and-guestcaps-structs-when-running-.patch

ffd6ed
From 3c01371a9da481bcd16519df28462ff073a49b20 Mon Sep 17 00:00:00 2001
ffd6ed
From: "Richard W.M. Jones" <rjones@redhat.com>
ffd6ed
Date: Thu, 30 Apr 2015 14:26:30 +0100
ffd6ed
Subject: [PATCH] v2v: Dump inspect and guestcaps structs when running in
ffd6ed
 verbose mode.
ffd6ed
ffd6ed
This helps with debugging.
ffd6ed
ffd6ed
(cherry picked from commit 086f71c7d86b0321ebbf36e1fb77644e783a7491)
ffd6ed
---
ffd6ed
 v2v/types.ml  | 45 +++++++++++++++++++++++++++++++++++++++++++++
ffd6ed
 v2v/types.mli |  4 ++++
ffd6ed
 v2v/v2v.ml    | 16 +++++++++++-----
ffd6ed
 3 files changed, 60 insertions(+), 5 deletions(-)
ffd6ed
ffd6ed
diff --git a/v2v/types.ml b/v2v/types.ml
ffd6ed
index 9dbdac0..01c65a3 100644
ffd6ed
--- a/v2v/types.ml
ffd6ed
+++ b/v2v/types.ml
ffd6ed
@@ -233,6 +233,31 @@ type inspect = {
ffd6ed
   i_uefi : bool;
ffd6ed
 }
ffd6ed
 
ffd6ed
+let string_of_inspect inspect =
ffd6ed
+  sprintf "\
ffd6ed
+i_root = %s
ffd6ed
+i_type = %s
ffd6ed
+i_distro = %s
ffd6ed
+i_arch = %s
ffd6ed
+i_major_version = %d
ffd6ed
+i_minor_version = %d
ffd6ed
+i_package_format = %s
ffd6ed
+i_package_management = %s
ffd6ed
+i_product_name = %s
ffd6ed
+i_product_variant = %s
ffd6ed
+i_uefi = %b
ffd6ed
+" inspect.i_root
ffd6ed
+  inspect.i_type
ffd6ed
+  inspect.i_distro
ffd6ed
+  inspect.i_arch
ffd6ed
+  inspect.i_major_version
ffd6ed
+  inspect.i_minor_version
ffd6ed
+  inspect.i_package_format
ffd6ed
+  inspect.i_package_management
ffd6ed
+  inspect.i_product_name
ffd6ed
+  inspect.i_product_variant
ffd6ed
+  inspect.i_uefi
ffd6ed
+
ffd6ed
 type mpstat = {
ffd6ed
   mp_dev : string;
ffd6ed
   mp_path : string;
ffd6ed
@@ -251,6 +276,26 @@ and guestcaps_block_type = Virtio_blk | IDE
ffd6ed
 and guestcaps_net_type = Virtio_net | E1000 | RTL8139
ffd6ed
 and guestcaps_video_type = QXL | Cirrus
ffd6ed
 
ffd6ed
+let string_of_guestcaps gcaps =
ffd6ed
+  sprintf "\
ffd6ed
+gcaps_block_bus = %s
ffd6ed
+gcaps_net_bus = %s
ffd6ed
+gcaps_video = %s
ffd6ed
+gcaps_arch = %s
ffd6ed
+gcaps_acpi = %b
ffd6ed
+" (match gcaps.gcaps_block_bus with
ffd6ed
+   | Virtio_blk -> "virtio"
ffd6ed
+   | IDE -> "ide")
ffd6ed
+  (match gcaps.gcaps_net_bus with
ffd6ed
+   | Virtio_net -> "virtio-net"
ffd6ed
+   | E1000 -> "e1000"
ffd6ed
+   | RTL8139 -> "rtl8139")
ffd6ed
+  (match gcaps.gcaps_video with
ffd6ed
+   | QXL -> "qxl"
ffd6ed
+   | Cirrus -> "cirrus")
ffd6ed
+  gcaps.gcaps_arch
ffd6ed
+  gcaps.gcaps_acpi
ffd6ed
+
ffd6ed
 class virtual input verbose = object
ffd6ed
   method virtual as_options : string
ffd6ed
   method virtual source : unit -> source
ffd6ed
diff --git a/v2v/types.mli b/v2v/types.mli
ffd6ed
index 16f5808..9fc9e29 100644
ffd6ed
--- a/v2v/types.mli
ffd6ed
+++ b/v2v/types.mli
ffd6ed
@@ -154,6 +154,8 @@ type inspect = {
ffd6ed
 }
ffd6ed
 (** Inspection information. *)
ffd6ed
 
ffd6ed
+val string_of_inspect : inspect -> string
ffd6ed
+
ffd6ed
 type guestcaps = {
ffd6ed
   gcaps_block_bus : guestcaps_block_type;
ffd6ed
   gcaps_net_bus : guestcaps_net_type;
ffd6ed
@@ -173,6 +175,8 @@ and guestcaps_block_type = Virtio_blk | IDE
ffd6ed
 and guestcaps_net_type = Virtio_net | E1000 | RTL8139
ffd6ed
 and guestcaps_video_type = QXL | Cirrus
ffd6ed
 
ffd6ed
+val string_of_guestcaps : guestcaps -> string
ffd6ed
+
ffd6ed
 class virtual input : bool -> object
ffd6ed
   method virtual as_options : string
ffd6ed
   (** Converts the input object back to the equivalent command line options.
ffd6ed
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
ffd6ed
index 3c0c4aa..eb1c66e 100644
ffd6ed
--- a/v2v/v2v.ml
ffd6ed
+++ b/v2v/v2v.ml
ffd6ed
@@ -215,7 +215,7 @@ let rec main () =
ffd6ed
 
ffd6ed
   (* Inspection - this also mounts up the filesystems. *)
ffd6ed
   msg (f_"Inspecting the overlay");
ffd6ed
-  let inspect = inspect_source g root_choice in
ffd6ed
+  let inspect = inspect_source ~verbose g root_choice in
ffd6ed
 
ffd6ed
   (* The guest free disk space check and the target free space
ffd6ed
    * estimation both require statvfs information from mountpoints, so
ffd6ed
@@ -262,7 +262,9 @@ let rec main () =
ffd6ed
         error (f_"virt-v2v is unable to convert this guest type (%s/%s)")
ffd6ed
           inspect.i_type inspect.i_distro in
ffd6ed
     if verbose then printf "picked conversion module %s\n%!" conversion_name;
ffd6ed
-    convert ~verbose ~keep_serial_console g inspect source in
ffd6ed
+    let guestcaps = convert ~verbose ~keep_serial_console g inspect source in
ffd6ed
+    if verbose then printf "%s%!" (string_of_guestcaps guestcaps);
ffd6ed
+    guestcaps in
ffd6ed
 
ffd6ed
   (* Did we manage to install virtio drivers? *)
ffd6ed
   if not quiet then (
ffd6ed
@@ -426,7 +428,7 @@ let rec main () =
ffd6ed
   if debug_gc then
ffd6ed
     Gc.compact ()
ffd6ed
 
ffd6ed
-and inspect_source g root_choice =
ffd6ed
+and inspect_source ~verbose g root_choice =
ffd6ed
   let roots = g#inspect_os () in
ffd6ed
   let roots = Array.to_list roots in
ffd6ed
 
ffd6ed
@@ -538,7 +540,8 @@ and inspect_source g root_choice =
ffd6ed
     let devices = Array.to_list (g#list_devices ()) in
ffd6ed
     List.exists is_uefi_bootable_device devices in
ffd6ed
 
ffd6ed
-  { i_root = root;
ffd6ed
+  let inspect = {
ffd6ed
+    i_root = root;
ffd6ed
     i_type = g#inspect_get_type root;
ffd6ed
     i_distro = g#inspect_get_distro root;
ffd6ed
     i_arch = g#inspect_get_arch root;
ffd6ed
@@ -551,7 +554,10 @@ and inspect_source g root_choice =
ffd6ed
     i_mountpoints = mps;
ffd6ed
     i_apps = apps;
ffd6ed
     i_apps_map = apps_map;
ffd6ed
-    i_uefi = uefi; }
ffd6ed
+    i_uefi = uefi
ffd6ed
+  } in
ffd6ed
+  if verbose then printf "%s%!" (string_of_inspect inspect);
ffd6ed
+  inspect
ffd6ed
 
ffd6ed
 (* Conversion can fail if there is no space on the guest filesystems
ffd6ed
  * (RHBZ#1139543).  To avoid this situation, check there is some
ffd6ed
-- 
ffd6ed
1.8.3.1
ffd6ed