virttest.env_process: Tcpdump is stopped too early

Tcpdump is required to get ARP ip when calling wait_for_login.
Stopping it before wait_for_login will make wait_for_login hang for 240s

Signed-off-by: Hao Liu <hliu@redhat.com>
libvirt-tests: Backup inactive domain XML

* Added option to toggle saving active or inactive domain XML for
  libvirt_vm.backup_xml

* Added '--inactive' option when dumping xml for backup when calling
  virsh.dumpxml or libvirt_vm.backup_xml. Without this option, the new
  domain restored will change its inactive xml like following diff permanently.

* using vmXML.new_from_inactive_xml instead of vmXML.new_from_xml to
  backup domain.

```diff
@@ -41,7 +41,9 @@
       <target type='serial' port='0'/>
     </console>
     <input type='mouse' bus='ps2'/>
-    <graphics type='vnc' port='-1' autoport='yes'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'>
+      <listen type='address' address='127.0.0.1'/>
+    </graphics>
     <video>
       <model type='cirrus' vram='9216' heads='1'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x02'
function='0x0'/>
@@ -50,4 +52,5 @@
       <address type='pci' domain='0x0000' bus='0x00' slot='0x05'
function='0x0'/>
     </memballoon>
   </devices>
+  <seclabel type='dynamic' model='selinux' relabel='yes'/>
 </domain>
```

Signed-off-by: Hao Liu <hliu@redhat.com>
virttest.libvirt_vm: Fix one line cond-expr

Fix the one line conditional expression which is against PEP8.

Signed-off-by: Hao Liu <hliu@redhat.com>
libvirt.get_started: Added non-interactive option

* Added option —-non-interactive to disable yes/no prompt and suppress
  verbose output.

* Added option —-setup-selinux to force setup SELinux contexts for
  shared/data directory and restore them to defaults.

When running libvirt.get_started from scripts such as CI.  It is necessary
to make it non-interactive and keep things under control by using options.

Signed-off-by: Hao Liu <hliu@redhat.com>
Merge pull request #1127 from FengYang/update7

Some update and fix master tree - Update7
Merge pull request #1146 from Hao-Liu/non_interactive

libvirt.get_started: Added non-interactive option
Merge pull request #1115 from Hao-Liu/workbranch

Tcpdump is stopped too early & Backup inactive domain XML
virttest.utils_test: Fix undefined variable error

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virttest.standalone_test: Shut down all VMs at the end of ./run

In the early days, it was thought that keeping QEMU processes
up and running after each test suite execution was good to make
testing faster. In practice, it only confuses people to see that
after the suite is done, there are still a lot of aexpect
processes hanging around.

So let's just destroy the environment at the end of the test,
trying to shut down all vms in there nicely, so we won't have
any leftovers after ./run is done.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virttest.utils_net: Fix logging message

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
Merge pull request #1151 from autotest/shutdown-vms-post-run

Shutdown vms post run
virt: Add 'session' parameter to RemoteRunner class

If we already have a session, we can use it directly,
no need to pass so many parameters.

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
virttest: Close and re-establish serial console every test

In order to not pickle Expect and ShellSession objects,
that will lead to one fd leak average per test, make
sure they are closed and reopened at each test, making
the average fd leak on virt-tests to be effectively 0.

With this we've came a long way since the work of fixing
resource leakage on virt-test started. There are more
places to work on, let's keep on working.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virttest.aexpect: Put shell files on aexpect process dir

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virttest.aexpect: Remove the entire aexpect tmp dir on close()

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virttest.qemu_vm: Bugfix - make seabios file to be deleted on destroy

Turns out we were clearing self.logs even when there was
a previous vm state. This made the seabios file to not
be deleted during vm cleanup. Let's fix this by moving
initialization of the variable to the right block.

With this, now virt-test won't leave tons of /tmp/seabios*
sockets around even when it is done.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virttest.qemu_vm: Better naming and management of vm create lock file

First of all, the lock file wasn't updated since this
test suite was known as kvm-autotest, second, it wasn't
being properly cleaned up at the end of the creation
process, when it should. So let's fix both problems
at once.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virttest.aexpect: Simplify base dir name

The _spawn suffix is reminiscent of an implementation
detail, so it shouldn't be there.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virttest.utils_net: Make db filename a module constant and delete lock

One more step to clean up temporary files virt-test leaves
behind.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virttest.aexpect: Introduce clean_tmp_files utility function

It makes up for cleaner cleanup code in the stand alone
test suite code.

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