virttest.env_process: Support image backup, restore before and after testing.

Support
backup_image_before_testing = yes
restore_image_after_testing = yes

changes from v1:
  Update the directory from test.bindir to base_dir.

Signed-off-by: Feng Yang <fyang@redhat.com>
Signed-off-by: Yiqiao Pu <ypu@redhat.com>
virttest.env_process: Do private bridge setup and clean up

Do private bridge setup and clean up in pre_process and post_process.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
virttest.env_process: Fix AttributeError when nics parameter is undefined

Some cases don't use nics parameter, but the preprocess
function in env_process module would read nics config and
init network in every case.

This patch is a workaround when nics is undefined. It makes
autotest ignore network initiation process in bridge env.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
virttest.test_setup: Adding framework code to control bridge creation

Provide in framework utility code to control the creation
of a bridge, in order to provide TAP functionality for
autotest users without relying on previous setup made by
the user.

This is a reimplementation of Amos's code, the differences
are:

 * Implemented as a setup class, taking advantage of object
internal state to use in different places of the code
 * Split up the operations to make it easier to understand
the steps and why we are doing them
 * Use of autotest API instead of commands

Changes from v2:
 * Changed firewall rules to match libvirt rules,
made the rules to be added with -I, which will place
them before exclusion rules
 * Safer cleanup, always try to cleanup when something
wrong happens during setup.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
Signed-off-by: Amos Kong <akong@redhat.com>

git-svn-id: svn://test.kernel.org/autotest/trunk@5399 592f7852-d20e-0410-864c-8624ca9c26a4
(cherry picked from commit 0e78eaac9942611dbe589978401b78b81e270661)
Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
virttest.test_setup: Add more flexible way to specify comm ports host -> guest

When running the virt guest windows tests using the (now default)
autotest private bridge, noticed that some ports needed for host
and guest communication weren't specified. So, add a config file
knob to allow people to specify additional ports to be added to
the default firewall configuration. The config tracks some important
ports used on tests, such as the remote shell ports and remote
shell file transfer ports.

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

git-svn-id: svn://test.kernel.org/autotest/trunk@5481 592f7852-d20e-0410-864c-8624ca9c26a4
(cherry picked from commit 41f2396c55725e9e802fc346adcc020018b7b757)

Conflicts:

	client/tests/kvm/tests_base.cfg.sample
Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
virttest.test_setup: private bridge improve

Make physical nic can be add as the interface of private bridge.
This is an optional parameter:
  physical_nic = $nic_name
Also add a parameter for let user select if the bridge should be
create forced.
  bridge_force_create = yes|no
The default vaule is no.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
virttest.test_setup: Update iptables command in PrivateBridgeConfig.

Signed-off-by: Feng Yang <fyang@redhat.com>
virttest.test_setup: Up the physical nic after private bridge setup

The physical nic always turns down after setup. Need bring it back.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
virttest.test_setup: Increase the overhead of qemu process

Now the overhead of qemu process is more than 64M. So increase it
to 128M.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
virttest.test_setup: Small bugs fix in PciAssignable

Signed-off-by: Feng Yang <fyang@redhat.com>