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>
virttest:virt_vm: Do not raise VMAddressVerificationError when SR-IOV card used

SR-IOV card may not in same subnet with the card used by host by
default. So arp check cannot work.
At this situation verify_ip_address_ownership will raise
VMAddressVerificationError even IP and mac match.
So do not raise VMAddressVerificationError when SR-IOV used.

Signed-off-by: Feng Yang <fyang@redhat.com>
virttest.test_setup: Update the re used to filter eth name in host.

Signed-off-by: Feng Yang <fyang@redhat.com>
virttest.qemu_vm: Only use B:D.F format as pci_id when add VF/PF to VM

RHEL 6 guest do not support domain name when add VF/PF to VM.

Following command will raise error:
pci-assign,host=<domain>:<bus>:<slot>.<func>

Signed-off-by: Feng Yang <fyang@redhat.com>
virttest.test_setup: Remove commands module.

Python in my local pc will get following error:
>>> import commands
>>> commands.getstatus("lsmod | grep igb")
'ls: cannot access lsmod | grep igb: No such file or directory'
>>>

python version is Python 2.7.5 (default, Aug 20 2013, 06:42:55)

So remove commands module and use utils.system instead.

Signed-off-by: Feng Yang <fyang@redhat.com>
virttest.utils_net: Make update_mac_ip_address works in more linux guest.

ifconfig output is different among linux guest.

In rhel6 guest:
switch    Link encap:Ethernet  HWaddr 00:23:AE:8F:50:B4
          inet addr:10.66.8.107  Bcast:10.66.11.255  Mask:255.255.252.0
          inet6 addr: 1111:2222:3333:4444:5555:6666:7777:8889/64 Scope:Global
          inet6 addr: fe80::223:aeff:fe8f:50b4/64 Scope:Link

In other guest:
switch: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.66.73.190  netmask 255.255.254.0  broadcast 10.66.73.255
        inet6 fe80::4f4:dff:fee8:a4ba  prefixlen 64  scopeid 0x20<link>
        ether 06:f4:0d:e8:a4:ba  txqueuelen 1000  (Ethernet)

So we need update the way used to filter mac and ip from ifconfig output.

Signed-off-by: Feng Yang <fyang@redhat.com>
qemu.tests.sr_iov_hotplug: Make driver parameter configurable.

Signed-off-by: Feng Yang <fyang@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>
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>
libvirt: Fix vcpupin XML change

Test vcpupin doesn't backup and restore vm XML, making the XML change
when using '--config' option.

This commit:
* Backup and restore VM's XML using new_from_inactive_dumpxml and sync.

* Close the test block in 'try ... finally ...' to ensure VM recover in
  any case.

Signed-off-by: Hao Liu <hliu@redhat.com>
qemu.tests.cfg: use absolute path for saving file cmds

when launching a testcase the 2nd time w/o kill the alive VM,
the origin pwd dir which boot the VM is removed/differ(the name
could be same, but the inode isn't, lsof -p $PID will show),
thus cases use relevant path would fail as the path is not
longer valid. like qmp_command.memsave qmp_command.pmemsave.
Changelog:
use /var/tmp instead of /tmp

Signed-off-by: Xiaoqing Wei <xwei@redhat.com>
qemu: change test entry point method name to 'run(..)'

There's no need to have the name of the "run_" method (main
test entry point) depend on the test name. So, for simplicity sake,
let's just name the test entry point "run".

Note: Related to PR #1196.

Signed-off-by: Ruda Moura <rmoura@redhat.com>
qemu.tests: Update driver install timeout in win_virtio_update

In some guest the install command need longer time to finish. So
make it configurable and set up it an acceptable value.
Also update the cdrom filter string to fit different system,
fix a mistake that use check_cmds in the last step instead op_cmds
and update one error context to make the info log more clear.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
qemu_vm: Support netdev_extra_params when do nic hotplug

This patch make add_netdev support netdev_extra_params when do nic hotplug

Signed-off-by: Yunping Zheng <yunzheng@redhat.com>
qemu.test: Support hot plug vhost nics

This patch add hotplug vhost nics test

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