virt: Repair bug in speed limiting of scp.

Signed-off-by: Jiří Župka <jzupka@redhat.com>
virt.kvm_installer: Don't fail a test if virtfs_proxy is not defined

This userspace program is not shipped on a regular qemu source
code checkout, so its absence doesn't need to fail a test.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt.virt_env_process: Reorganize screendump thread termination

Simplify the check for screendump termination thread event,
and also avoid a bug where we try to set a delay to a None
object.

Fixes the following bug that happens when running the
multi-disk test:

 Exception in thread Thread-1:
 Traceback (most recent call last):
   File "/usr/lib64/python2.7/threading.py", line 551, in
__bootstrap_inner
     self.run()
   File "/usr/lib64/python2.7/threading.py", line 504, in run
     self.__target(*self.__args, **self.__kwargs)
   File
"/home/lmr/Code/autotest.git/autotest/client/virt/virt_env_process.py",
line 549, in _take_screendumps
     _screendump_thread_termination_event.wait(delay)
 AttributeError: 'NoneType' object has no attribute 'wait'

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
contrib/install-autotest-server.sh: Fetch autotest instead of cloning it

Ray Spear <ray.spear@hp.com> reported that
f541fd43601f64205c990765db15870cdc86461c introduced a
regression when installing the autotest server from
scratch:

15:14:48 INFO | Setting autotest user password
15:14:48 INFO | Cloning autotest repo in /usr/local
15:14:48 INFO | Trying clone via git
fatal: destination path 'autotest' already exists and is not an empty
directory.

So, instead of just clone the tree using git clone, init
a git repo in there and fetch from upstream. Later on if
people want, we could make the tree/branch configurable.

Thanks to Ray for having reported the problem.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
contrib/install-autotest-server.sh: Fix autotest dir permissions

Since now we're using /usr/local/autotest as a home dir,
it is created by default with permissions 700. Change it
to 775 so apache can stat and serve its contents.

Tested on an F16, from scratch install of the autotest
server, worked fine.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
KVM Test: subtests.cfg.sample: Split virtio_console into multiple variants

Splits virtio_console test into smaller logical bundles of test variants.

Added variants:
* smoke (should always work)
* basic (should always work)
* performance (needed only for perf regression testing)
* destructive (those are tricky)
* migration (migration-related tests)
* hotplug (hotplug-related tests)

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virt/tests add negative_create.py for qemu/spice negative testing

* pass when vm.create() raises VMCreateError, otherwise raises
  VMCreateSuccess

* required by spiceqa negative testing

Signed-off-by: Lubos Kocman <lkocman@redhat.com>
tests/kvm/tests-spice.cfg: added bad values for spice.* variants

* used by virt/tests/negative_create.py
* removed spice_port duplicate definition from file which could
  cause unexpected behaviour

Signed-off-by: Lubos Kocman <lkocman@redhat.com>
virt: fix localhost migration

Autotest always uses "-incoming tcp:0:$port" to start dest vm,
and migrate with "migrate -d tcp:localhost:$port",
or "migrate -d tcp:$dest_host:$port"

Upstream qemu already supports IPv6 migration, current autotest
would fail to migrate in localhost.

'localhost' has multiple aliases (::1 and 127.0.0.1) in /etc/hosts.
getaddrinfo() returns an address list, "::1" is the first item
of the list, "127.0.0.1" is the second item. First available
addr will be choosen to connect. But "0" will be parsed to 127.0.0.1
It caused localhost migration fails, multiple host migration
is fine.

For resolving localhost migration issue, we can listen by
'-incoming tcp:localhost:$port' and migrate by 'migrate
-d tcp:localhost:$port'. Or listen by '-incoming tcp:0:$port'
and migrate by 'migrate -d tcp:0:$port'
This patch uses second resolution.

Signed-off-by: Amos Kong <akong@redhat.com>
boottool: Don't even try to build if popt.h is missing

Boottool does require popt.h at build time. So, if this
include is not present, don't even bother trying to build
grubby.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt.trans_hugepage_swapping: Update env method

The test was still using an old API and needed update.

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

If we do not pass a profile to install_host(), we end up un-setting the
host's profile in cobbler, which causes subsequent sync's to throw
exceptions. It makes sense in this situation to use the existing profile
from the system. But rather than call this repeatedly, pull it up before
we start the install.

Found during verify/repair testing.

Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
Fix boottool on ppc64

When trying to run a simple job with the new boottool, I get:

  Traceback (most recent call last):
    File "/usr/local/autotest/job.py", line 1082, in _run_step_fn
      exec('__ret = %s(*__args, **__dargs)' % fn, local_vars, local_vars)
    File "<string>", line 1, in <module>
    File "/usr/local/autotest/control.autoserv", line 16, in boot_kernel
      host.cleanup_kernels()
    File "/usr/local/autotest/shared/hosts/base_classes.py", line 656, in cleanup_kernels
      boot_info = self.bootloader.get_entries()
    File "/usr/local/autotest/tools/boottool", line 998, in get_entries
      entries[entry["index"]] = entry
  KeyError: 'index'

This is because boottool::get_entries() does:

  raw = self.get_info()
  ...
  for entry_str in raw.split("\nindex"):

Which doesn't split off the first entry if the raw string starts off with
"index". This then results in "indexindex 0" being the first string, causing
the parse error above.

If I change that split to be regex based off starting with index, I get
further, but then still error out:

  Traceback (most recent call last):
    File "/usr/local/autotest/job.py", line 1082, in _run_step_fn
      exec('__ret = %s(*__args, **__dargs)' % fn, local_vars, local_vars)
    File "<string>", line 1, in <module>
    File "/usr/local/autotest/control.autoserv", line 16, in boot_kernel
      host.cleanup_kernels()
    File "/usr/local/autotest/shared/hosts/base_classes.py", line 658, in cleanup_kernels
      for boot in boot_info.itervalues()]
  KeyError: 'kernel'

This is because my grubby --info outputs:

index=1
non linux entry
...
index=4
non linux entry
index=5
non linux entry

And boottool seems to assume that all entries are valid.

I think it is appropriate to skip these entries explicitly.

Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>