standalone_test: unset log level on root logger

Other modules may have messed with the root logger already, so if we
don't reset the root logger log level, messages go through the logger
even after we add the console and file handlers later.

This problem wasn't visible before because an autotest module was
unconditionally setting the root logger log level to DEBUG, but a recent
patch I sent to autotest removes that unconditional logging setup code.

This patch also renames configure_logging() to reset_logging(), as it
doesn't configure any handler, but just remove the existing logging
configuration).

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
virttest.virt_vm: Update regex pattern of check guest kernel panic

When kernel raise oops with BUG() macro, the oops message is
like following, so the pattern needs some update to match this
format of oops.

"""
------------[ cut here ]------------
kernel BUG at /root/module/test.c:9!
invalid opcode: 0000 [#1] SMP
Modules linked in: test(OF+) ipt_MASQUERADE tbios_ns  virtio_blk [last unloaded: test]
CPU 1
Pid: 2451, comm: insmod Tainted: GF          O 3.7.5-201.fc18.x86_64 #1 Bochs Bochs
RIP: 0010:[<ffffffffa00db009>]  [<ffffffffa00db009>] test_init+0x9/0x10 [test]
RSP: 0018:ffff88001c847f18  EFLAGS: 00010246
RAX: ffff88001c847fd8 RBX: ffffffffa00dd000 RCX: 0000000000000034
RDX: 00000000000006e0 RSI: 00000000000000fb RDI: ffffffffa00db000
RBP: ffff88001c847f18 R08: ffff88001fc14740 R09: 0000000000000080
R10: ffff88001e03ff98 R11: 0000000000000000 R12: ffffffffa00db000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
FS:  00007f24fd8f8740(0000) GS:ffff88001fd00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 00007fd595188000 CR3: 000000001bfd7000 CR4: 00000000000006e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Process insmod (pid: 2451, threadinfo ffff88001c846000, task ffff8800196d5c80)
Stack:
 ffff88001c847f48 ffffffff8100216a ffffffffa00dd000 0000000000014ba0
 0000003dcce103e1 0000000000000000 ffff88001c847f78 ffffffff810c2ce0
 0000003dcce103e1 00000000018ff350 0000003dcce103e1 00000000018fe090
Call Trace:
 [<ffffffff8100216a>] do_one_initcall+0x12a/0x180
 [<ffffffff810c2ce0>] sys_init_module+0xc0/0x220
 [<ffffffff8163e199>] system_call_fastpath+0x16/0x1b
Code: <0f> 0b 0f 1f 44 00 00 0f 1f 44 00 00 55 31 c0 48 89 e5 5d c3 0f 1f
RIP  [<ffffffffa00db009>] test_init+0x9/0x10 [test]
 RSP <ffff88001c847f18>
---[ end trace 2f1dfbcce63b1426 ]---
"""

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
virt-libvirt: add configuration for virsh vncdisplay

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
virt-libvirt: add virsh function for virsh vncdisplay

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
virt-libvirt: add test module for virsh vncdisplay

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
virt-libvirt: add configuration for virsh dominfo

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
virt-libvirt: modify virsh function for virsh dominfo

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
virt-libvirt: modify libvirt_vm where use virsh.dominfo

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
virt-libvirt: add test module for virsh dominfo

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
./run: make stdout redirect/restore API simpler

Today, if _restore_stdout() is called twice, stdout gets silenced again.
Instead of having API that requires the caller to remember what's the
internal state of the object to know what will happen, we can simply
have two separate methods to redirect and restore stdout.

The main problem with the current approach is that it makes it very
difficult to gradually disable the hack in various parts of the code[1],
as changing the moment we silence/restore stdout could break existing
parts of the code that calls the switch() method assuming stdout is
already silenced.

[1] In a perfect world we wouldn't need any stdout hacking at all, we
    would just need to ask the test runner and autotest to be more
    silent. But to achieve that, we need to do it gradually (e.g. trying
    to disable stdout/stderr only when actually running the tests, not
    when parsing configs or loading modules)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
bootstrap.py: fix log message formatting

The arguments for logging.info are the format string parameters
themselves, not a tuple. This was causing logging error tracebacks on my
tests.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
run: List all test types in --help output

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
./run: use imp module for AUTOTEST_PATH setup

Instead of hacking sys.path, just use the Python imp module to load the
module using the full path.

Also change the check for AUTOTEST_PATH to not rely on Exception
handling for flow control.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
./run: print clearer error message if AUTOTEST_PATH doesn't work

Error message before:

  $ ./run
  Traceback (most recent call last):
    File "./run", line 558, in <module>
      app = VirtTestApp()
    File "./run", line 271, in __init__
      self.option_parser = VirtTestRunParser()
    File "./run", line 151, in __init__
      _import_autotest_modules()
    File "./run", line 106, in _import_autotest_modules
      setup_modules_path)
  IOError: [Errno 2] No such file or directory
  $

Error message after:

  $ ./run
  Failed to import autotest modules from $AUTOTEST_PATH
  Could not load Python module /home/ehabkost/pessoal/proj/virt/autotestx/client/setup_modules.py
  $

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
./run: isolate initialization code that affects the whole process

The new system_setup() function will be used for the stuff that affects
the whole Python interpreter.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
./run: give AUTOTEST_PATH precedence over sys.path

If AUTOTEST_PATH is set, try to use it instead of the autotest modules
in sys.path.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
./run: try to import autotest modules at the very beginning

The _import_autotest_modules() function doesn't need to be called
multiple times, and calling it as early as possible will allow us to use
some autotest modules very early.

This also adds a workaround to an Autotest bug in some versions where it
enables debug logging as soon as the modules are imported.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
run: Get rid of the last places using standalone_test.print_stdout

Now the appropriate path is to call _restore_stdout() and
then use simple prints, rather than importing standalone_test
and then use print_stdout.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
run: Fix typo

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt-libvirt: Allow to return CmdResult in virsh.domuuid.

Signed-off-by: Yu Mingfei<yumingfei@cn.fujitsu.com>