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>