virt.kvm_vm: Add nw interfaces to bridge unconditionally

This is a solution for issue #441.

In kvm_vm.create(), the process of attaching each one
of the nics on kvm_vm.virtnet currently happens only
if the nic doesn't have a tapfd key. However, on test
failure (and consequent vm destruction), this field
will continue to be filled up, therefore a new connection
to the bridge will never be stablished, making all
subsequent tests to fail.

However, the old networking code used to stablish the
network interface-bridge connection regardless of the
state of the nic, when create() is called. Applying the
same logic proved to be an effective solution for the
problem, therefore it's implemented on this patch.

CC: Chris Evich <cevich@redhat.com>
CC: Lukas Doktor <ldoktor@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt: Update kvm_control

To ignore the case failed caused by the auto check if the system
support kvm when run case inside a guest or submit job in server.
Remove the line that will call get_kvm_arch even when just import
this module. Also update the code format.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
Fixing Bad playback variant, Replacing RHEL 6.3 beta with the released version of RHEL 6.3 64bit and 32bit, and other minor fixes Signed-off-by: Vimal Patel <vipatel@redhat.com>
RHEL 6.3 released version support, and dropping RHEL 6.3 beta Signed-off-by: Vimal Patel <vipatel@redhat.com>
Support for the released version of RHEL 6.3 and dropping RHEL 6.3 beta. Signed-off-by: Vimal Patel <vipatel@redhat.com>
KVM-test: And check the cpu vendor_id in physical_resources_check

Since we do not have a simple way to identify the vendor_id
in the Windows guests, this test is limited to linux guests
for now.

Changes from v4:
 - Add a default cpu model in case qemu can't get cpu model
   from host's /proc/cpuinfo.
 - Add checking cpu vendor id cmd for win guest.
 - Rollback the cmd for checking vendor id in linux to
   'grep vendor_id /proc/cpuinfo', to make this case can also
   work on the guest without 'lscpu' cmd, eg, RHEL5.

Changes from v3:
 - Use 'lscpu' to check cpu vendor id.

Changes from v2:
 - The default vendor of cpu64-rhel6, qemu64 is AuthenticAMD,
   change vendor id to "AuthenticAMD", to make guest can get
   correct cores, threads, sockets

Changes from v1:
1. limit customized vendor_id to Linux guests.
2. test vendor_id in physical_resources_check, rather than in a
new testcase.

Signed-off-by: Chen Cao <kcao@redhat.com>
Signed-off-by: Suqin Huang <shuang@redhat.com>
Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
KVM-test: check if the MS Windows VirtIO driver is digital signed

Changes from v3:
 - Fix typo.
 - Convert 'chk_timeout' to integer type.

Changes from v2:
 - Update error log message, using a list to store error message.

Changes from v1:
 - The default 30s timeout sometimes is too short to get the result,
   change the timeout to 240

Signed-off-by: Chen Cao <kcao@redhat.com>
Signed-off-by: Suqin Huang <shuang@redhat.com>
Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
virt.virt_vm: Create CpuInfo struct for virt_vm class

This patch creates a CpuInfo class for virt_vm, this class
stores VM's cpu information, we can access cpu info in test
cases easily with it.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
virt.kvm_vm: Generate cpu topology info as qemu's way

The existed code for generate cpu topology info (sockets/
cores/threads) may generate a invalid config. This patch
Update this part of code with qemu's way.

This patch also add the support for 'maxcpus' option.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
KVM-Test: physical_resouces_check: Add sockets/cores/threads check

Add sockets, cores, threads number checking test

Changes from v5:
 - Get cpu topology info from vm.cpuinfo class directly.

Changes from v4:
 - Update the code for getting chk_cmd parameter in
   check_cpu_number() function
 - Give default value to chk_timeout.

Changes from v3:
 - Verify regex search result for cpu check, avoid list out of
   index error.

Changes from v2:
 - Putting actul checking steps into a sub-function called
   check_cpu_number
 - Update default values for sockets/cores/threads configuration,
   make them same as configs in kvm_vm file.

Changes from v1:
 - Change timeout to int(timeout)
 - Add timeout while checking cores, threads, sockets

Signed-off-by: Suqin Huang <shuang@redhat.com>
Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
KVM-Test: Add cores/threads/sockets checking cmd in cfg file

Add cores/threads/sockets check cmd in cfg file

Changes from v3:
 - Update cores/threads checking cmd for windows guest.

Changes from v2:
 - Move configs for linux guest into subtests.cfg file.
 - Use 'lscpu' cmd to check cpu info instead of /proc/cpuinfo

Changes from v1:
 - Update "check cpu cmds" for windows guest

Signed-off-by: Suqin Huang <shuang@redhat.com>
Signed-off-by: Golita Yue <gyue@redhat.com>
Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
KVM-test: Add punctuation to random string generate chars

Add punctuation to generate_random_string. Also add two parameters
to this function:
    - ignore_str: string that will not include in string that generated
    - convert_str: stirng that need to be covered with /
Make this function can cover more conditions.

changes from v1:
  - wrong docstring fix
  - use string.replace() to delete or substitute ignore_str and
    convert_str
changes from v2:
  - clean up code and make it simpler
changes from v3:
  - Check ignore_str and convert_str before using them.
chanages from v4:
  - Update docstring.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
Acked-by: Qingtang Zhou <qzhou@redhat.com>
Acked-by: Feng Yang <fyang@redhat.com>
virt.libvirt_vm: Fix get_pid() method

This is a fix for issue #473.

The current implementation of get_pid() in libvirt_vm is
reminiscent of the kvm_vm implementation, where self.process
is an expect object. In libvirt_vm, process is a PID (int),
therefore the same rules can't be applied. Re-create the
implementation in a cleaner way.

Signed-off-by: Satheesh Rajendran <sathnaga@linux.vnet.ibm.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt.cfg: Update config of phyical_resources_check

RHEL5 guest doesn't have 'lscpu' cmd, so add special cpu info
checking cmd for it.

This patch also fixes a typo in cpu sockets checking cmd.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
virt.kvm_vm: Fix a bug in cpu info generating code

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
virt.physical_resources_check: Fix typo

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
kvm test: Separate virtio port class to library

* this patch separates class Port (handles virtio_console and
  virtio_serial_port) to framework library.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virt: Add support for virtio_serialport and console to framework

This patch adds support for virtio_serialport and virtio_console
to framework. Also it modifies virtio_console test to use this
framework.

params:
virtio_ports  -- space sepparated port names [""]
virtio_port_spread  -- spread consoles across multiple pcis [0]
                       when 0 it uses values from "virtio_port_bus"
                       when >0 it creates virtio_serial_pci for every
                       n-th virtual port
virtio_port_bus  -- which bus to use (integer) [0]

it extends VM structure:
self.virtio_ports  -- adds kvm_virtio_port objects during vm.create()

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virt: Move kvm_virtio_port related helpers from test to library

* This patch moves virtio_port related helpers from virtio_console test
  to kvm_virtio_port library.
* It also changes the way of VM handling and avoids unnecessarily VM
  recreation.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virt.kvm_virtio_port: Add GuestWorker (virtio_console_guest helper)

Class for executing virtio_console_guest on guest.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>