[Pkg-libvirt-commits] [libguestfs] 49/61: v2v: Add Utils.warning and Utils.info that don't require ~prog parameter.

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 31 19:09:41 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag debian/1%1.28.2-1
in repository libguestfs.

commit d3e1fcf6cefe418313b7c32fdc55f0d844c33253
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Sat Oct 25 15:06:08 2014 +0100

    v2v: Add Utils.warning and Utils.info that don't require ~prog parameter.
    
    (cherry picked from commit 7c9293fff02c9d71833c6914ad7a8d00c3b47bb1)
---
 v2v/OVF.ml                         |  6 +++---
 v2v/convert_linux.ml               | 19 +++++++++----------
 v2v/convert_windows.ml             | 12 ++++++------
 v2v/input_libvirt.ml               |  2 +-
 v2v/input_libvirt_vcenter_https.ml |  6 +++---
 v2v/input_libvirtxml.ml            |  8 ++++----
 v2v/output_glance.ml               |  2 +-
 v2v/output_libvirt.ml              |  4 ++--
 v2v/output_rhev.ml                 |  4 ++--
 v2v/utils.ml                       |  2 ++
 v2v/v2v.ml                         | 12 ++++++------
 11 files changed, 39 insertions(+), 38 deletions(-)

diff --git a/v2v/OVF.ml b/v2v/OVF.ml
index cbb8932..76e4640 100644
--- a/v2v/OVF.ml
+++ b/v2v/OVF.ml
@@ -145,7 +145,7 @@ and get_ostype = function
   | { i_type = typ; i_distro = distro;
       i_major_version = major; i_minor_version = minor;
       i_product_name = product } ->
-    warning ~prog (f_"unknown guest operating system: %s %s %d.%d (%s)")
+    warning (f_"unknown guest operating system: %s %s %d.%d (%s)")
       typ distro major minor product;
     "Unassigned"
 
@@ -292,7 +292,7 @@ let rec create_ovf verbose source targets guestcaps inspect
    *)
   (match source with
   | { s_display = Some { s_password = Some _ } } ->
-    warning ~prog (f_"This guest required a password for connection to its display, but this is not supported by RHEV.  Therefore the converted guest's display will not require a separate password to connect.");
+    warning (f_"This guest required a password for connection to its display, but this is not supported by RHEV.  Therefore the converted guest's display will not require a separate password to connect.");
     | _ -> ());
 
   (* Return the OVF document. *)
@@ -437,7 +437,7 @@ and add_networks nics guestcaps ovf =
         | E1000 -> "2"
         | Virtio_net -> "3"
       (*| bus ->
-        warning ~prog (f_"unknown NIC model %s for ethernet device %s.  This NIC will be imported as rtl8139 instead.")
+        warning (f_"unknown NIC model %s for ethernet device %s.  This NIC will be imported as rtl8139 instead.")
         bus dev;
         "1" *) in
 
diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
index 6c0c903..69e72d3 100644
--- a/v2v/convert_linux.ml
+++ b/v2v/convert_linux.ml
@@ -202,7 +202,7 @@ let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
              let files = List.sort cmp files in
              match files with
              | [] ->
-               warning ~prog (f_"no initrd was found in /boot matching %s %s.")
+               warning (f_"no initrd was found in /boot matching %s %s.")
                  name version;
                None
              | x :: _ -> Some ("/boot/" ^ x) in
@@ -524,7 +524,7 @@ let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
           Linux.augeas_reload verbose g
         with
           G.Error msg ->
-            warning ~prog (f_"VirtualBox Guest Additions were detected, but uninstallation failed.  The error message was: %s (ignored)")
+            warning (f_"VirtualBox Guest Additions were detected, but uninstallation failed.  The error message was: %s (ignored)")
               msg
     )
 
@@ -615,7 +615,7 @@ let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
         Linux.augeas_reload verbose g
       with
         G.Error msg ->
-          warning ~prog (f_"VMware tools was detected, but uninstallation failed.  The error message was: %s (ignored)")
+          warning (f_"VMware tools was detected, but uninstallation failed.  The error message was: %s (ignored)")
             msg
     )
 
@@ -1034,9 +1034,9 @@ let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
     match paths with
     | [] ->
       if not remove then
-        warning ~prog (f_"could not add grub2 serial console (ignored)")
+        warning (f_"could not add grub2 serial console (ignored)")
       else
-        warning ~prog (f_"could not remove grub2 serial console (ignored)")
+        warning (f_"could not remove grub2 serial console (ignored)")
     | path :: _ ->
       let grub_cmdline = g#aug_get path in
       if Str.string_match rex grub_cmdline 0 then (
@@ -1052,7 +1052,7 @@ let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
           ignore (g#command [| "grub2-mkconfig"; "-o"; grub_config |])
         with
           G.Error msg ->
-            warning ~prog (f_"could not rebuild grub2 configuration file (%s).  This may mean that grub output will not be sent to the serial port, but otherwise should be harmless.  Original error message: %s")
+            warning (f_"could not rebuild grub2 configuration file (%s).  This may mean that grub output will not be sent to the serial port, but otherwise should be harmless.  Original error message: %s")
               grub_config msg
       )
 
@@ -1104,8 +1104,7 @@ let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
     if !updated &&
       not (g#is_file ~followsymlinks:true "/usr/bin/X") &&
       not (g#is_file ~followsymlinks:true "/usr/bin/X11/X") then
-      warning ~prog
-        (f_"The display driver was updated to '%s', but X11 does not seem to be installed in the guest.  X may not function correctly.")
+      warning (f_"The display driver was updated to '%s', but X11 does not seem to be installed in the guest.  X may not function correctly.")
         video_driver
 
   and configure_kernel_modules virtio =
@@ -1160,7 +1159,7 @@ let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
       fun path ->
         let device = g#aug_get path in
         let module_ = g#aug_get (path ^ "/modulename") in
-        warning ~prog (f_"don't know how to update %s which loads the %s module")
+        warning (f_"don't know how to update %s which loads the %s module")
           device module_;
     ) paths;
 
@@ -1315,7 +1314,7 @@ let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
       with Not_found ->
         if string_find device "md" = -1 && string_find device "fd" = -1 &&
           device <> "cdrom" then
-          warning ~prog (f_"%s references unknown device \"%s\".  You may have to fix this entry manually after conversion.")
+          warning (f_"%s references unknown device \"%s\".  You may have to fix this entry manually after conversion.")
             path device;
         device
     in
diff --git a/v2v/convert_windows.ml b/v2v/convert_windows.ml
index e5afbc9..e37c6b8 100644
--- a/v2v/convert_windows.ml
+++ b/v2v/convert_windows.ml
@@ -58,7 +58,7 @@ let convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
       Some rhev_apt_exe
     with
       Sys_error msg ->
-        warning ~prog (f_"'%s' is missing.  Unable to install RHEV-APT (RHEV guest agent).  Original error: %s")
+        warning (f_"'%s' is missing.  Unable to install RHEV-APT (RHEV guest agent).  Original error: %s")
           rhev_apt_exe msg;
         None in
 
@@ -107,7 +107,7 @@ let convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
       let uninstkey = "UninstallString" in
       let valueh = g#hivex_node_get_value node uninstkey in
       if valueh = 0L then (
-        warning ~prog (f_"cannot uninstall Xen PV drivers: registry key 'HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s' does not contain an '%s' key")
+        warning (f_"cannot uninstall Xen PV drivers: registry key 'HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s' does not contain an '%s' key")
           xenpvreg uninstkey;
         raise Not_found
       );
@@ -263,7 +263,7 @@ echo uninstalling Xen PV driver
 
     match path with
     | None ->
-      warning ~prog (f_"there are no virtio drivers available for this version of Windows (%d.%d %s %s).  virt-v2v looks for drivers in %s\n\nThe guest will be configured to use slower emulated devices.")
+      warning (f_"there are no virtio drivers available for this version of Windows (%d.%d %s %s).  virt-v2v looks for drivers in %s\n\nThe guest will be configured to use slower emulated devices.")
         inspect.i_major_version inspect.i_minor_version
         inspect.i_arch inspect.i_product_variant
         virtio_win_dir;
@@ -274,7 +274,7 @@ echo uninstalling Xen PV driver
       let block : guestcaps_block_type =
         let block_path = path // "viostor.sys" in
         if not (Sys.file_exists block_path) then (
-          warning ~prog (f_"there is no viostor (virtio block device) driver for this version of Windows (%d.%d %s).  virt-v2v looks for this driver here: %s\n\nThe guest will be configured to use a slower emulated device.")
+          warning (f_"there is no viostor (virtio block device) driver for this version of Windows (%d.%d %s).  virt-v2v looks for this driver here: %s\n\nThe guest will be configured to use a slower emulated device.")
             inspect.i_major_version inspect.i_minor_version
             inspect.i_arch block_path;
           IDE
@@ -291,7 +291,7 @@ echo uninstalling Xen PV driver
       let net : guestcaps_net_type =
         let net_path = path // "netkvm.inf" in
         if not (Sys.file_exists net_path) then (
-          warning ~prog (f_"there is no virtio network driver for this version of Windows (%d.%d %s).  virt-v2v looks for this driver here: %s\n\nThe guest will be configured to use a slower emulated device.")
+          warning (f_"there is no virtio network driver for this version of Windows (%d.%d %s).  virt-v2v looks for this driver here: %s\n\nThe guest will be configured to use a slower emulated device.")
             inspect.i_major_version inspect.i_minor_version
             inspect.i_arch net_path;
           RTL8139
@@ -412,7 +412,7 @@ echo uninstalling Xen PV driver
       in
       loop values
     with Not_found ->
-      warning ~prog (f_"could not find registry key HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion")
+      warning (f_"could not find registry key HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion")
 
   and fix_ntfs_heads () =
     (* NTFS hardcodes the number of heads on the drive which created
diff --git a/v2v/input_libvirt.ml b/v2v/input_libvirt.ml
index 60e88ac..5d5c39f 100644
--- a/v2v/input_libvirt.ml
+++ b/v2v/input_libvirt.ml
@@ -61,7 +61,7 @@ let input_libvirt verbose libvirt_uri guest =
      *)
 
     | Some _, Some _ ->             (* Unknown remote scheme. *)
-      warning ~prog (f_"no support for remote libvirt connections to '-ic %s'.  The conversion may fail when it tries to read the source disks.")
+      warning (f_"no support for remote libvirt connections to '-ic %s'.  The conversion may fail when it tries to read the source disks.")
         orig_uri;
       Input_libvirt_other.input_libvirt_other verbose libvirt_uri guest
 
diff --git a/v2v/input_libvirt_vcenter_https.ml b/v2v/input_libvirt_vcenter_https.ml
index 56097e0..c7a6012 100644
--- a/v2v/input_libvirt_vcenter_https.ml
+++ b/v2v/input_libvirt_vcenter_https.ml
@@ -102,7 +102,7 @@ let get_session_cookie =
       ) lines;
       if !session_cookie = "" then (
         dump_response stderr;
-        warning ~prog (f_"esx: could not read session cookie from the vCenter Server, conversion may consume all sessions on the server and fail part way through");
+        warning (f_"esx: could not read session cookie from the vCenter Server, conversion may consume all sessions on the server and fail part way through");
         None
       )
       else
@@ -116,7 +116,7 @@ let get_datacenter uri scheme =
   | "vpx" ->           (* Hopefully the first part of the path. *)
     (match uri.uri_path with
     | None ->
-      warning ~prog (f_"esx: URI (-ic parameter) contains no path, so we cannot determine the datacenter name");
+      warning (f_"esx: URI (-ic parameter) contains no path, so we cannot determine the datacenter name");
       default_dc
     | Some path ->
       let path =
@@ -288,7 +288,7 @@ object
           (quote backing_qemu_uri) (quote overlay.ov_overlay_file) in
       if verbose then printf "%s\n%!" cmd;
       if Sys.command cmd <> 0 then
-        warning ~prog (f_"qemu-img rebase failed (ignored)")
+        warning (f_"qemu-img rebase failed (ignored)")
 end
 
 let input_libvirt_vcenter_https = new input_libvirt_vcenter_https
diff --git a/v2v/input_libvirtxml.ml b/v2v/input_libvirtxml.ml
index c71260f..85582fa 100644
--- a/v2v/input_libvirtxml.ml
+++ b/v2v/input_libvirtxml.ml
@@ -102,10 +102,10 @@ let parse_libvirt_xml ~verbose xml =
         Some { s_display_type = `Spice;
                s_keymap = keymap; s_password = password }
       | "sdl"|"desktop" as t ->
-        warning ~prog (f_"virt-v2v does not support local displays, so <graphics type='%s'> in the input libvirt XML was ignored") t;
+        warning (f_"virt-v2v does not support local displays, so <graphics type='%s'> in the input libvirt XML was ignored") t;
         None
       | t ->
-        warning ~prog (f_"display <graphics type='%s'> in the input libvirt XML was ignored") t;
+        warning (f_"display <graphics type='%s'> in the input libvirt XML was ignored") t;
         None
     ) in
 
@@ -174,11 +174,11 @@ let parse_libvirt_xml ~verbose xml =
           )
         | "" -> ()
         | protocol ->
-          warning ~prog (f_"network <disk> with <source protocol='%s'> was ignored")
+          warning (f_"network <disk> with <source protocol='%s'> was ignored")
             protocol
         )
       | disk_type ->
-        warning ~prog (f_"<disk type='%s'> was ignored") disk_type
+        warning (f_"<disk type='%s'> was ignored") disk_type
     done;
     get_disks () in
 
diff --git a/v2v/output_glance.ml b/v2v/output_glance.ml
index c2b1a32..3697541 100644
--- a/v2v/output_glance.ml
+++ b/v2v/output_glance.ml
@@ -114,7 +114,7 @@ object
         (quote source.s_name) in
     if verbose then printf "%s\n%!" cmd;
     if Sys.command cmd <> 0 then (
-      warning ~prog (f_"glance: failed to set image properties (ignored)");
+      warning (f_"glance: failed to set image properties (ignored)");
       (* Dump out the image properties so the user can set them. *)
       printf "Image properties:\n";
       printf "  --min-ram %Ld\n" min_ram;
diff --git a/v2v/output_libvirt.ml b/v2v/output_libvirt.ml
index 59a390f..305ce35 100644
--- a/v2v/output_libvirt.ml
+++ b/v2v/output_libvirt.ml
@@ -251,7 +251,7 @@ class output_libvirt verbose oc output_pool = object
         sprintf "virsh -c %s pool-refresh %s"
           (quote uri) (quote output_pool) in
     if Sys.command cmd <> 0 then
-      warning ~prog (f_"could not refresh libvirt pool %s") output_pool;
+      warning (f_"could not refresh libvirt pool %s") output_pool;
 
     (* Create the metadata. *)
     let doc = create_libvirt_xml ~pool:output_pool source targets guestcaps in
@@ -269,7 +269,7 @@ class output_libvirt verbose oc output_pool = object
     if Sys.command cmd = 0 then (
       try Unix.unlink tmpfile with _ -> ()
     ) else (
-      warning ~prog (f_"could not define libvirt domain.  The libvirt XML is still available in '%s'.  Try running 'virsh define %s' yourself instead.")
+      warning (f_"could not define libvirt domain.  The libvirt XML is still available in '%s'.  Try running 'virsh define %s' yourself instead.")
         tmpfile tmpfile
     );
 end
diff --git a/v2v/output_rhev.ml b/v2v/output_rhev.ml
index 0671e14..7e89743 100644
--- a/v2v/output_rhev.ml
+++ b/v2v/output_rhev.ml
@@ -180,9 +180,9 @@ object
           actual_uid actual_gid;
       if uid <> actual_uid || gid <> actual_gid then (
         if running_as_root then
-          warning ~prog (f_"cannot write files to the NFS server as %d:%d, even though we appear to be running as root. This probably means the NFS client or idmapd is not configured properly.\n\nYou will have to chown the files that virt-v2v creates after the run, otherwise RHEV-M will not be able to import the VM.") uid gid
+          warning (f_"cannot write files to the NFS server as %d:%d, even though we appear to be running as root. This probably means the NFS client or idmapd is not configured properly.\n\nYou will have to chown the files that virt-v2v creates after the run, otherwise RHEV-M will not be able to import the VM.") uid gid
         else
-          warning ~prog (f_"cannot write files to the NFS server as %d:%d. You might want to stop virt-v2v (^C) and rerun it as root.") uid gid
+          warning (f_"cannot write files to the NFS server as %d:%d. You might want to stop virt-v2v (^C) and rerun it as root.") uid gid
       ) in
 
     (* Create unique UUIDs for everything *)
diff --git a/v2v/utils.ml b/v2v/utils.ml
index 7757be5..c97914f 100644
--- a/v2v/utils.ml
+++ b/v2v/utils.ml
@@ -27,6 +27,8 @@ open Types
 
 let prog = Filename.basename Sys.executable_name
 let error ?exit_code fs = error ~prog ?exit_code fs
+let warning fs = warning ~prog fs
+let info fs = info ~prog fs
 
 let quote = Filename.quote
 
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index 48fb8c6..148f0be 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -267,9 +267,9 @@ let rec main () =
   (* Did we manage to install virtio drivers? *)
   if not quiet then (
     if guestcaps.gcaps_block_bus = Virtio_blk then
-      info ~prog (f_"This guest has virtio drivers installed.")
+      info (f_"This guest has virtio drivers installed.")
     else
-      info ~prog (f_"This guest does not have virtio drivers installed.");
+      info (f_"This guest does not have virtio drivers installed.");
   );
 
   g#umount_all ();
@@ -471,7 +471,7 @@ and inspect_source g root_choice =
 
       | `First ->
         let root = List.hd roots in
-        info ~prog (f_"Picked %s because '--root first' was used.") root;
+        info (f_"Picked %s because '--root first' was used.") root;
         root
 
       | `Dev dev ->
@@ -480,7 +480,7 @@ and inspect_source g root_choice =
           else
             error (f_"root device %s not found.  Roots found were: %s")
               dev (String.concat " " roots) in
-        info ~prog (f_"Picked %s because '--root %s' was used.") root dev;
+        info (f_"Picked %s because '--root %s' was used.") root dev;
         root in
 
   (* Reject this OS if it doesn't look like an installed image. *)
@@ -504,7 +504,7 @@ and inspect_source g root_choice =
             error "%s" msg
         )
         else
-          warning ~prog (f_"%s (ignored)") msg
+          warning (f_"%s (ignored)") msg
   ) mps;
 
   (* Get list of applications/packages installed. *)
@@ -615,7 +615,7 @@ and do_fstrim ~verbose g no_trim inspect =
       let mounted = try g#mount dev "/"; true with G.Error _ -> false in
       if mounted then (
         try g#fstrim "/"
-        with G.Error msg -> warning ~prog (f_"%s (ignored)") msg
+        with G.Error msg -> warning (f_"%s (ignored)") msg
       )
   ) fses
 

-- 
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