Francesco Romani has uploaded a new change for review. Change subject: v2v: dup commands.execCmd to allow redirection ......................................................................
v2v: dup commands.execCmd to allow redirection ***WIP*** - discussion material, not merge material. Change-Id: I9df138e2a64cbc2fd3f3c26363d1584d571983f2 Signed-off-by: Francesco Romani <from...@redhat.com> --- M lib/vdsm/v2v.py 1 file changed, 45 insertions(+), 10 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/60/60660/2 diff --git a/lib/vdsm/v2v.py b/lib/vdsm/v2v.py index c6a9943..5a53a92 100644 --- a/lib/vdsm/v2v.py +++ b/lib/vdsm/v2v.py @@ -32,7 +32,7 @@ import logging import os import re -import signal +import subprocess import tarfile import threading import xml.etree.ElementTree as ET @@ -40,12 +40,13 @@ import libvirt -from vdsm.commands import execCmd +from vdsm.commands import AsyncProc, execCmd from vdsm.common import zombiereaper +from vdsm.compat import CPopen from vdsm.constants import P_VDSM_RUN, EXT_KVM_2_OVIRT from vdsm.define import errCode, doneCode -from vdsm import libvirtconnection, response, concurrent -from vdsm.utils import traceback, CommandPath, NICENESS, IOCLASS +from vdsm import libvirtconnection, response, concurrent, cmdutils +from vdsm.utils import terminating, traceback, CommandPath, NICENESS, IOCLASS try: import ovirt_imageio_common @@ -389,12 +390,11 @@ raise NotImplementedError("Subclass must implement this") def _start_helper(self): - return execCmd(self._command(), - sync=False, - deathSignal=signal.SIGTERM, - nice=NICENESS.HIGH, - ioclass=IOCLASS.IDLE, - env=self._environment()) + return _exec_cmd(self._command(), + sync=False, + nice=NICENESS.HIGH, + ioclass=IOCLASS.IDLE, + env=self._environment()) def _get_disk_format(self): fmt = self._vminfo.get('format', 'raw').lower() @@ -1139,3 +1139,38 @@ else: net['type'] = 'interface' vm['networks'].append(net) + + +# FIXME: hack until we fix the main execCmd +def _exec_cmd(command, raw=False, env=None, sync=True, nice=None, ioclass=None, + stdout=subprocess.PIPE, stderr=subprocess.PIPE): + """ + Dumbed version of commands.execCmd, until the proper refactoring is + completed. + """ + command = cmdutils.wrap_command(command, with_ioclass=ioclass, + ioclassdata=None, with_nice=nice, + with_setsid=False, with_sudo=False, + reset_cpu_affinity=True) + + logging.debug(cmdutils.command_log_line(command, cwd=None)) + + p = CPopen(command, close_fds=True, cwd=None, env=env, + stdout=stdout, stderr=stderr) + if not sync: + return AsyncProc(p) + + with terminating(p): + (out, err) = p.communicate(None) + + if out is None: + # Prevent splitlines() from barfing later on + out = "" + + logging.debug(cmdutils.retcode_log_line(p.returncode, err=err)) + + if not raw: + out = out.splitlines(False) + err = err.splitlines(False) + + return p.returncode, out, err -- To view, visit https://gerrit.ovirt.org/60660 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9df138e2a64cbc2fd3f3c26363d1584d571983f2 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Francesco Romani <from...@redhat.com> Gerrit-Reviewer: Francesco Romani <from...@redhat.com> Gerrit-Reviewer: gerrit-hooks <automat...@ovirt.org> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org