Tomas Golembiovsky has uploaded a new change for review.

Change subject: v2v: Log detailed output of virt-v2v
......................................................................

v2v: Log detailed output of virt-v2v

The detailed log virt-v2v output is often necessary to debug conversion
failures. We provide '-v -x' arguments to virt-v2v to get the detailed
output and store the logs in the VDSM run directory.

Change-Id: I6a8d9284316a551edeaffdd66dfcd299fa02478e
Bug-Url: https://bugzilla.redhat.com/1350465
Signed-off-by: Tomáš Golembiovský <[email protected]>
---
M lib/vdsm/v2v.py
M tests/fake-virt-v2v
2 files changed, 63 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/34/59834/1

diff --git a/lib/vdsm/v2v.py b/lib/vdsm/v2v.py
index defbe14..0948741 100644
--- a/lib/vdsm/v2v.py
+++ b/lib/vdsm/v2v.py
@@ -384,6 +384,7 @@
         self._irs = irs
         self._prepared_volumes = []
         self._passwd_file = os.path.join(_V2V_DIR, "%s.tmp" % vmid)
+        self._base_command = [_VIRT_V2V.cmd, '-v', '-x']
 
     def execute(self):
         raise NotImplementedError("Subclass must implement this")
@@ -394,7 +395,10 @@
                        deathSignal=signal.SIGTERM,
                        nice=NICENESS.HIGH,
                        ioclass=IOCLASS.IDLE,
-                       env=self._environment())
+                       env=self._environment(),
+                       outLog=os.path.join(_V2V_DIR,
+                                           "%s.log" % self._vmid),
+                       errToOutLog=True)
 
     def _get_disk_format(self):
         fmt = self._vminfo.get('format', 'raw').lower()
@@ -490,11 +494,11 @@
         self._password = password
 
     def _command(self):
-        cmd = [_VIRT_V2V.cmd,
-               '-ic', self._uri,
-               '-o', 'vdsm',
-               '-of', self._get_disk_format(),
-               '-oa', self._vminfo.get('allocation', 'sparse').lower()]
+        cmd = self._base_command
+        cmd.extend(['-ic', self._uri,
+                    '-o', 'vdsm',
+                    '-of', self._get_disk_format(),
+                    '-oa', self._vminfo.get('allocation', 'sparse').lower()])
         cmd.extend(self._disk_parameters())
         cmd.extend(['--password-file',
                     self._passwd_file,
@@ -521,19 +525,19 @@
         self._ova_path = ova_path
 
     def _command(self):
-        cmd = [_VIRT_V2V.cmd,
-               '-i', 'ova', self._ova_path,
-               '-o', 'vdsm',
-               '-of', self._get_disk_format(),
-               '-oa', self._vminfo.get('allocation', 'sparse').lower(),
-               '--vdsm-vm-uuid',
-               self._vmid,
-               '--vdsm-ovf-output',
-               _V2V_DIR,
-               '--machine-readable',
-               '-os',
-               self._get_storage_domain_path(
-                   self._prepared_volumes[0]['path'])]
+        cmd = self._base_command
+        cmd.extend(['-i', 'ova', self._ova_path,
+                    '-o', 'vdsm',
+                    '-of', self._get_disk_format(),
+                    '-oa', self._vminfo.get('allocation', 'sparse').lower(),
+                    '--vdsm-vm-uuid',
+                    self._vmid,
+                    '--vdsm-ovf-output',
+                    _V2V_DIR,
+                    '--machine-readable',
+                    '-os',
+                    self._get_storage_domain_path(
+                        self._prepared_volumes[0]['path'])])
         cmd.extend(self._disk_parameters())
         return cmd
 
@@ -559,11 +563,11 @@
         self._ssh_agent = SSHAgent()
 
     def _command(self):
-        cmd = [_VIRT_V2V.cmd,
-               '-ic', self._uri,
-               '-o', 'vdsm',
-               '-of', self._get_disk_format(),
-               '-oa', self._vminfo.get('allocation', 'sparse').lower()]
+        cmd = self._base_command
+        cmd.extend(['-ic', self._uri,
+                    '-o', 'vdsm',
+                    '-of', self._get_disk_format(),
+                    '-oa', self._vminfo.get('allocation', 'sparse').lower()])
         cmd.extend(self._disk_parameters())
         cmd.extend(['--vdsm-vm-uuid',
                     self._vmid,
@@ -782,7 +786,8 @@
                                      description)
                 for chunk in self._iter_progress(stream):
                     progress = self._parse_progress(chunk)
-                    yield DiskProgress(progress)
+                    if progress is not None:
+                        yield DiskProgress(progress)
                     if progress == 100:
                         break
 
@@ -807,8 +812,7 @@
     def _parse_progress(self, chunk):
         m = self.DISK_PROGRESS_RE.match(chunk)
         if m is None:
-            raise OutputParserError('error parsing progress, chunk: %r'
-                                    % chunk)
+            return None
         try:
             return int(m.group(1))
         except ValueError:
diff --git a/tests/fake-virt-v2v b/tests/fake-virt-v2v
index 67aeab8..df9e5a2 100755
--- a/tests/fake-virt-v2v
+++ b/tests/fake-virt-v2v
@@ -47,6 +47,12 @@
 parser.add_argument('--machine-readable', dest='machineReadable',
                     action='store_true',
                     help='Set the terminal output to be readable')
+parser.add_argument('-v', dest='verbose',
+                    action='store_true',
+                    help='Enable verbose messages for debugging.')
+parser.add_argument('-x', dest='libguestfsTrace',
+                    action='store_true',
+                    help='Enable tracing of libguestfs API calls.')
 parser.add_argument('vmname')
 
 options = parser.parse_args(sys.argv)
@@ -56,6 +62,11 @@
 def write_output(msg):
     sys.stdout.write(msg)
     sys.stdout.flush()
+
+def write_trace(msg):
+    sys.stderr.write(msg)
+    sys.stderr.flush()
+
 
 
 def write_progress():
@@ -69,10 +80,31 @@
 write_output('[   %d.0] Creating an overlay to protect\n' % elapsed_time)
 elapsed_time = elapsed_time + 1
 
+
+# Immitate some libguestfs trace messages
+if options.libguestfsTrace:
+    write_trace("libguestfs: trace: internal_autosync = 0")
+    write_trace("libguestfs: sending SIGTERM to process 7053")
+    write_trace("libguestfs: trace: shutdown = 0")
+    write_trace("libguestfs: trace: close")
+    write_trace("libguestfs: closing guestfs handle 0x1e265f0 (state 0)")
+    write_trace("libguestfs: command: run: rm")
+    write_trace("libguestfs: command: run: \ -rf /tmp/libguestfs1lFBAz")
+
 for i, o in enumerate(options.vdsmImageId):
     write_output('[  %d.0] Copying disk %d/2 to %s/%s/images/%s\n' %
                  (elapsed_time, i+1, options.outputStorage,
                   options.vdsmVmId, o))
+
+    # Immitate some verbose messages
+    # NOTE: Most verbose messages go to stderr, but some go to stdout. This can
+    # potentialy mess with out parsing routine.
+    if options.verbose:
+        write_output("target_file = %s" % options.vdsmVolId)
+        write_output("target_format = raw")
+        write_output("target_estimated_size = 3827919137")
+        write_output("target_overlay = /var/tmp/v2vovl344e53.qcow2")
+
     write_progress()
     write_output('[ %d.0] Creating output metadata\n' % elapsed_time)
     write_output('[ %d.0] Finishing off\n' % elapsed_time)


-- 
To view, visit https://gerrit.ovirt.org/59834
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6a8d9284316a551edeaffdd66dfcd299fa02478e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Tomas Golembiovsky <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/admin/lists/[email protected]

Reply via email to