[Libguestfs] [PATCH 2/4] v2v: chmod original OVA file if running as root (RHBZ#1430680).

Richard W.M. Jones rjones at redhat.com
Mon Mar 13 14:47:43 UTC 2017


In the case where we are going to read the disk directly from the OVA
file (partial = true), we will create a qcow2 image backed by the OVA.
If running as root, libvirt will run qemu as a non-root user (because
of no qemu:///session support for root, which is a libvirt bug).  qemu
will not be able to read the backing file and thus will fail.

To work around this problem, chmod the backing (OVA) file.

This isn't a complete fix since (eg) the OVA might be located in a
directory which isn't accessible by root, but there's only so much we
can do here until libvirt is fixed.

Thanks: Kun Wei.
---
 v2v/input_ova.ml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml
index fb6b286..e80ec82 100644
--- a/v2v/input_ova.ml
+++ b/v2v/input_ova.ml
@@ -171,7 +171,8 @@ object
      *)
     if Unix.geteuid () = 0 && backend_is_libvirt () then (
       warning (f_"making OVA directory public readable to work around libvirt bug https://bugzilla.redhat.com/1045069");
-      let cmd = [ "chmod"; "-R"; "go=u,go-w"; exploded ] in
+      let cmd = [ "chmod"; "-R"; "go=u,go-w"; exploded ] @
+                if partial then [ ova ] else [] in
       ignore (run_command cmd)
     );
 
-- 
2.9.3




More information about the Libguestfs mailing list