'Executes qemu-img command wrapper.'

def _run_qemu_img(self, command, *params):

    addr = self.get_addr()
    cmd = ['env', 'LC_ALL=C', 'LANG=C', 'qemu-img', command]
    for param in params:
        if param.startswith(self.QEMU_SHEEPDOG_PREFIX):
            param = param.replace(self.QEMU_SHEEPDOG_PREFIX, ('%(prefix)s%(addr)s:%(port)s:' % {'prefix': self.QEMU_SHEEPDOG_PREFIX, 'addr': addr, 'port': self.port}), 1)
        cmd.append(param)
    try:
        return utils.execute(*cmd)
    except OSError as e:
        with excutils.save_and_reraise_exception():
            if (e.errno == errno.ENOENT):
                msg = 'Qemu-img    is    not    installed.    OSError:    command    is    %(cmd)s.'
            else:
                msg = 'OSError:    command    is    %(cmd)s.'
            LOG.error(msg, {'cmd': tuple(cmd)})
    except processutils.ProcessExecutionError as e:
        _stderr = e.stderr
        if (self.QEMU_IMG_RESP_CONNECTION_ERROR in _stderr):
            reason = (_('Failed    to    connect    to    sheep    daemon.    addr:    %(addr)s,    port:    %(port)s'), {'addr': addr, 'port': self.port})
            raise exception.SheepdogError(reason=reason)
        raise exception.SheepdogCmdError(cmd=e.cmd, exit_code=e.exit_code, stdout=e.stdout.replace('\n', '\\n'), stderr=e.stderr.replace('\n', '\\n'))
