Pino Toscano
2016-Jul-20 09:26 UTC
[Libguestfs] [PATCH] v2v: make virsh command quiet if v2v is quiet (RHBZ#1358142)
Pass -q to virsh if virt-v2v was run with -q, to reduce its output in
quiet mode.
Unfortunately this does not currently work in virsh as it should, see
RHBZ#1358179, so only after that bug is fixed this change can actually
take effect.
---
v2v/output_libvirt.ml | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/v2v/output_libvirt.ml b/v2v/output_libvirt.ml
index d1e9346..1f66d6a 100644
--- a/v2v/output_libvirt.ml
+++ b/v2v/output_libvirt.ml
@@ -394,10 +394,12 @@ class output_libvirt oc output_pool = object
(* We copied directly into the final pool directory. However we
* have to tell libvirt.
*)
- let cmd - match oc with
- | None -> [ "virsh"; "pool-refresh"; output_pool ]
- | Some uri -> [ "virsh"; "-c"; uri;
"pool-refresh"; output_pool ] in
+ let cmd = [ "virsh" ] @
+ (if quiet () then [ "-q" ] else []) @
+ (match oc with
+ | None -> []
+ | Some uri -> [ "-c"; uri; ]) @
+ [ "pool-refresh"; output_pool ] in
if run_command cmd <> 0 then
warning (f_"could not refresh libvirt pool %s") output_pool;
@@ -425,10 +427,12 @@ class output_libvirt oc output_pool = object
);
(* Define the domain in libvirt. *)
- let cmd - match oc with
- | None -> [ "virsh"; "define"; tmpfile ]
- | Some uri -> [ "virsh"; "-c"; uri;
"define"; tmpfile ] in
+ let cmd = [ "virsh" ] @
+ (if quiet () then [ "-q" ] else []) @
+ (match oc with
+ | None -> []
+ | Some uri -> [ "-c"; uri; ]) @
+ [ "define"; tmpfile ] in
if run_command cmd = 0 then (
try Unix.unlink tmpfile with _ -> ()
) else (
--
2.7.4
Richard W.M. Jones
2016-Jul-20 11:25 UTC
Re: [Libguestfs] [PATCH] v2v: make virsh command quiet if v2v is quiet (RHBZ#1358142)
On Wed, Jul 20, 2016 at 11:26:04AM +0200, Pino Toscano wrote:> Pass -q to virsh if virt-v2v was run with -q, to reduce its output in > quiet mode. > > Unfortunately this does not currently work in virsh as it should, see > RHBZ#1358179, so only after that bug is fixed this change can actually > take effect. > --- > v2v/output_libvirt.ml | 20 ++++++++++++-------- > 1 file changed, 12 insertions(+), 8 deletions(-) > > diff --git a/v2v/output_libvirt.ml b/v2v/output_libvirt.ml > index d1e9346..1f66d6a 100644 > --- a/v2v/output_libvirt.ml > +++ b/v2v/output_libvirt.ml > @@ -394,10 +394,12 @@ class output_libvirt oc output_pool = object > (* We copied directly into the final pool directory. However we > * have to tell libvirt. > *) > - let cmd > - match oc with > - | None -> [ "virsh"; "pool-refresh"; output_pool ] > - | Some uri -> [ "virsh"; "-c"; uri; "pool-refresh"; output_pool ] in > + let cmd = [ "virsh" ] @ > + (if quiet () then [ "-q" ] else []) @ > + (match oc with > + | None -> [] > + | Some uri -> [ "-c"; uri; ]) @ > + [ "pool-refresh"; output_pool ] in > if run_command cmd <> 0 then > warning (f_"could not refresh libvirt pool %s") output_pool; > > @@ -425,10 +427,12 @@ class output_libvirt oc output_pool = object > ); > > (* Define the domain in libvirt. *) > - let cmd > - match oc with > - | None -> [ "virsh"; "define"; tmpfile ] > - | Some uri -> [ "virsh"; "-c"; uri; "define"; tmpfile ] in > + let cmd = [ "virsh" ] @ > + (if quiet () then [ "-q" ] else []) @ > + (match oc with > + | None -> [] > + | Some uri -> [ "-c"; uri; ]) @ > + [ "define"; tmpfile ] in > if run_command cmd = 0 then ( > try Unix.unlink tmpfile with _ -> () > ) else ( > -- > 2.7.4Looks good, ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Reasonably Related Threads
- [PATCH] v2v: -o libvirt: always write pool names (RHBZ#1141631)
- [PATCH] v2v: -o libvirt: dump XML for libvirt if verbose
- [v2v PATCH] -o libvirt: read pool name from object
- [PATCH] v2v: Add support for libosinfo metadata
- [PATCH v4 4/7] v2v: -o libvirt: use a Lazy for the connection