KVM users always use bridge network, there are also some limits in userspace
network, and userspace network is not officially supported by some companys.
This patchset only use private bridge for three tests, we can replace user net
with private bridge if this setup is stable and general enough.

Configure parameters:
  bridge = private
  priv_brname = atbr0
  priv_subnet = 192.168.58

Signed-off-by: Amos Kong <ak...@redhat.com>
---
 client/tests/kvm/kvm_preprocessing.py |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/kvm_preprocessing.py 
b/client/tests/kvm/kvm_preprocessing.py
index f679be0..d8f1736 100644
--- a/client/tests/kvm/kvm_preprocessing.py
+++ b/client/tests/kvm/kvm_preprocessing.py
@@ -194,6 +194,17 @@ def preprocess(test, params, env):
     @param env: The environment (a dict-like object).
     """
     error.context("preprocessing")
+
+    if params.get("bridge") == "private":
+        priv_brname = params.get("priv_brname", 'atbr0')
+        priv_subnet = params.get("priv_subnet", '192.168.58')
+        script = os.path.join(test.bindir, "scripts/set_private_br.sh")
+        cmd = "%s add %s %s" % (script, priv_brname, priv_subnet)
+        logging.info("Setup private bridge: %s", cmd)
+        s,o = commands.getstatusoutput(cmd)
+        if s != 0:
+            raise error.TestError("Fail to setup private bridge. %s" % o)
+
     # Start tcpdump if it isn't already running
     if "address_cache" not in env:
         env["address_cache"] = {}
@@ -363,6 +374,14 @@ def postprocess(test, params, env):
                         int(params.get("post_command_timeout", "600")),
                         params.get("post_command_noncritical") == "yes")
 
+    if params.get("bridge") == "private":
+        priv_brname = params.get("priv_brname", 'atbr0')
+        script = os.path.join(test.bindir, "scripts/set_private_br.sh")
+        if priv_brname not in commands.getoutput("ps aux|grep -v grep"):
+            cmd = "%s del %s" % (script, priv_brname)
+            logging.info("Remove private bridge: %s", cmd)
+            commands.getstatusoutput(cmd)
+
 
 def postprocess_on_error(test, params, env):
     """

_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to