KVM test: add basic TAP support with static MAC-IP mapping

The network mode is specified by a NIC parameter named 'nic_mode'.
Currently two modes are supported: 'tap' and 'user'.

Other NIC parameters are now handled: nic_script, nic_downscript and
nic_ifname.  nic_ifname should usually not be specified (qemu chooses one
automatically).  nic_script and nic_downscript may specify a relative path,
e.g. 'qemu-ifup', which refers to a file in the KVM test local dir, or an
absolute path, e.g. '/etc/qemu-ifup'.

This patch mainly modifies VM.get_address(), VM.get_port() and
VM.make_qemu_command(), and adds a 'script_dir' parameter to several VM
routines.  'script_dir' should normally be the directory 'scripts' under the
main KVM test directory.

Signed-off-by: Michael Goldish <mgoldish@redhat.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@3530 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py
index 2e55b34..359f81d 100644
--- a/client/tests/kvm/kvm_preprocessing.py
+++ b/client/tests/kvm/kvm_preprocessing.py
@@ -53,6 +53,7 @@
     qemu_path = os.path.join(test.bindir, "qemu")
     image_dir = os.path.join(test.bindir, "images")
     iso_dir = os.path.join(test.bindir, "isos")
+    script_dir = os.path.join(test.bindir, "scripts")
 
     logging.debug("Preprocessing VM '%s'..." % name)
     vm = kvm_utils.env_get_vm(env, name)
@@ -60,7 +61,7 @@
         logging.debug("VM object found in environment")
     else:
         logging.debug("VM object does not exist; creating it")
-        vm = kvm_vm.VM(name, params, qemu_path, image_dir, iso_dir)
+        vm = kvm_vm.VM(name, params, qemu_path, image_dir, iso_dir, script_dir)
         kvm_utils.env_register_vm(env, name, vm)
 
     start_vm = False
@@ -81,14 +82,15 @@
         elif vm.make_qemu_command() != vm.make_qemu_command(name, params,
                                                             qemu_path,
                                                             image_dir,
-                                                            iso_dir):
+                                                            iso_dir,
+                                                            script_dir):
             logging.debug("VM's qemu command differs from requested one; "
                           "restarting it...")
             start_vm = True
 
     if start_vm:
         if not vm.create(name, params, qemu_path, image_dir, iso_dir,
-                         for_migration):
+                         script_dir, for_migration):
             message = "Could not start VM"
             logging.error(message)
             raise error.TestError(message)