libvirt-test: numatune: Fix some bugs

* VM XML omit numa entry when the placement is auto and mode is strict.
  So we need to set numa_params manually when exception happens.

* Fix typo in cfg file which causes duplicated test name. s/config/live/

* Fix typo. s/KeyError()/KeyError/

* Move restoration of cgroup to finally section to make sure cgroup can
  be restored even when exception happens.

Signed-off-by: Hao Liu <hliu@redhat.com>
virttest: Make macvtap support hotplug

This patch add support of hotplug/unplug nic with macvtap

Signed-off-by: Yunping Zheng <yunzheng@redhat.com>
libvirt-test: Fix cpu-stats cgroup problem

* This fix use utils_cgroup to get cgroup path instead of using
  hard-coded path which causes compatibility problem.

* Built in python module is used to get processors' count instead
  of hard-coded command line.

* These tests is still failing because of a bug of return values.

Signed-off-by: Hao Liu <hliu@redhat.com>
qemu.tests.pci_devices: Get firmware time to initialize

Before "info qtree" returns the correct values, firmware initialization
has to finish. 10s should be enough (in case we won't define 1000
devices)

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
qemu.tests.pci_devices: Add virtio_disk testing devices

This patch adds the possibility to use virtio_disks for testing.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
qemu.tests.pci_devices: Add support for uhci test device

Make it possible to use ich9-usb-uhci controller for pci_devices testing

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.qemu_devices: Fix the bug with overwritten bus for virtio disk

The bus property of virtio disks is set by pci_bus and is set during
device insertion via parent_bus.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
qemu.tests.pci_devices: Major config update

Original setups were only for developing the test and some of them
were invalid (impossible for real hw and thus unsupported by kernel).
These setups were checked with pci device developer and they should be
working properly.
virsh_migrate_multi_vms: SKIP if srcuri and desturi not defined

Issue #1014, SKIP this test if we haven't adjusted the cfg to have
real source and destination URI's
libvirt: Fix memtune cgroup bug

The original code use 'cat' to get the content of a cgroup file. This
will cause problem if the file name contains slash '\' in it. This
fix change it by using 'open' to read.

BTW, This commit also merged some repeat helper functions.

Signed-off-by: Hao Liu <hliu@redhat.com>
libvirt: Fix schedinfo cgroup bug

This fix use 'open' instead of 'cat' to access cgroup file to prevent
problem if slash ('\') exist in file path.

If the cgroup path has a 'emulator' sub-directory. We need to trim it to
get the desired cgroup file.

Signed-off-by: Hao Liu <hliu@redhat.com>
tests.nicdriver_unload: Make the guest nic also named eth0

When run nicdriver_unload test, will raise error like:
013-04-16 21:35:55: modprobe virtio_net
2013-04-16 21:35:56: [root@unused ~]#
2013-04-16 21:35:56: echo $?
2013-04-16 21:35:56: 0
2013-04-16 21:35:56: [root@unused ~]#
2013-04-16 21:35:56: ifconfig eth4 up
2013-04-16 21:35:56: eth4: unknown interface: No such device
2013-04-16 21:35:56: [root@unused ~]#
2013-04-16 21:35:56: echo $?
2013-04-16 21:35:56: 255
2013-04-16 21:35:56: [root@unused ~]#
2013-04-16 21:35:56: udev: renamed network interface eth0 to eth4

the root cause of this cause is after the nic driver loaded,
the nic name not changed immediately by udev rules, because
the guest is under heavy working pressure.

This patch modify the guest udev net rules before test,
make guest nic always nemed eth0.

Signed-off-by: Yunping Zheng <yunzheng@redhat.com>
utils_cgroup: fix the regexp in get_cgroup_mountpoint()

The last patch done by me has a bug in the regexp that it also takes
the " cgroup" or " type" from the cgroup mounts. This patch fix the
issue by updating the regexp.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
utils_cgroup: Fix get cgroup mount point

Checking get_all_controller is no longer needed since the controller
must be invalid if it's not in mount table.

get_all_controller in another function is also not needed because it is
followed by a get_cgroup_mountpoint which will raise exception if
controller is invalid.

Unit test is also added for get_cgroup_mountpoint.

Signed-off-by: Hao Liu <hliu@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
virsh_migrate: remove static mac address for "xml" test

We are using static mac address "ff:ff:ff:ff:ff:ff" which is broadcast
address, but libvirt neads unicast address. Instead of using static mac
address we can leave libvirt to generate one and then obtain that mac
address for further checking in the code.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
virsh_migrate: skip direct migration for driver different from xen

Direct migration is supported only for xen in libvirt and therefore
we should skip this test for all other drivers instead of failing.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
virsh.migrate: fix the connect uri

The src uri for migration tests should be gotten from the cfg file
instead from the vm object.

Also change the "connect_uri" into the "virsh_migrate_connect_uri"
and instead of "logging.warning()" that the src_uri or dest_uri aren't
updated use "error.TestNAError()" which will skip the test.
virsh.migrate: Update the "there_migrateuri" test case

By this update we can tell the user that he needs to setup the
migrateuri.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
virsh.migrate: change the current storage into the shared storage

The migration requires shared storage. By this patch we will detach
all existing storages from the existing guest and we will attach
one shared storage defined in the config file. It can be on
whatever backend you want.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
qemu.test: Not create test file when it is not necessary

Not create test file when it is not necessary

Signed-off-by: Yunping Zheng <yunzheng@redhat.com>