'run a command on the chroot.  This is only needed for implementing
put_file() get_file() so that we don\'t have to read the whole file
into memory.
compared to exec_command() it looses some niceties like being able to
return the process\'s exit code immediately.'

def _buffered_exec_command(self, cmd, stdin=subprocess.PIPE):

    executable = (C.DEFAULT_EXECUTABLE.split()[0] if C.DEFAULT_EXECUTABLE else '/bin/sh')
    local_cmd = [self.virsh, '-q', '-c', 'lxc:///', 'lxc-enter-namespace']
    if C.DEFAULT_LIBVIRT_LXC_NOSECLABEL:
        local_cmd += ['--noseclabel']
    local_cmd += [self.lxc, '--', executable, '-c', cmd]
    display.vvv(('EXEC    %s' % (local_cmd,)), host=self.lxc)
    local_cmd = [to_bytes(i, errors='surrogate_or_strict') for i in local_cmd]
    p = subprocess.Popen(local_cmd, shell=False, stdin=stdin, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    return p
