virttest.aexpect: Close tail thread fd on thread end

When the aexpect "tail" thread is requested to stop, take the chance
and close the filedescriptor being used by that thread. This makes up
for a big decrease in the number of open fds over the course of a
default virt test set. Before the patch, in 10 migrations tests
executed, the evolution of fds open is:

26 -> 31 -> 36 -> 41 -> 46 -> 51 -> 56 -> 61 -> 66 -> 71

After the patch, the evolution goes:

23 -> 25 -> 27 -> 29 -> 31 -> 33 -> 35 -> 37 -> 39 -> 40

That's quite a nice cleanup.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virttest.qemu_vm: Make the qemu process a Tail object rather than Expect

Checking up the qemu vm code, I noticed that none of the
uses of vm.process actually requires it to be an Expect
object. By using a Tail object, we obtain the same features
we've been using the code for, and we get rid of an extra
expect reader pipe, that ends up accumulating over the course
of the tests.

So make a function aexpect.run_tail(), nearly identical to
aexpect.run_bg(), and make vm.process to be a tail object.
With this change,  we further reduce the open number of open
fds from:

23 -> 25 -> 27 -> 29 -> 31 -> 33 -> 35 -> 37 -> 39 -> 40

to:

22 -> 23 -> 24 -> 25 -> 26 -> 26 -> 28 -> 29 -> 30 -> 31

If you guys can see any disadvantages of simplifying things
here, let me know.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virttest.aexpect: Don't remove inpipe server side

The clients will do that on close() anyway.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virttest.aexpect: Introduce server side logging

Make the aexpect server able to log into a file. As it
is, we don't really have an easy way to tell what's going
on in there.

On later patches, we'll implement better ways to manage
files generated by aexpect, as well as debugging mechanisms.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virttest.aexpect: Change file/log directory structure

Instead of having a flat structure of files

BASE_DIR/[filename]-[aexpect_instance]

Make the aexpect instance the parent dir of the files

BASE_DIR/[aexpect_instance]/filename

That makes it easy to see the number of open aexpect
controlled process at any given point in time, while
keeping information available.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
Merge pull request #1098 from autotest/fd-leak

virttest.aexpect: FD leak fixes