Skip to contentSkip to conversation

Add custom install option for kvm_install

PATCH In review Mike Burns 2 participants 2 messages May 11, 2009 KVM

lore
Share & tools
lore

Mike Burns

author
#0 lore raw

PATCH 1/1 Add custom install option for kvm_install

From: Michael Burns <[email protected]>

---
 client/tests/kvm_runtest_2/control        |   17 ++++++++++++++++-
 client/tests/kvm_runtest_2/kvm_install.py |   13 +++++++++++++
 2 files changed, 29 insertions(+), 1 deletions(-)
client/tests/kvm_runtest_2/control +16 -1
index fd68e94..5d022b5 100644
@@ -41,6 +41,18 @@ link_if_not_exist(pwd, qemu_img, 'qemu-img')
 
 # ---------------------
 # Build and install kvm
+#
+# Details of Install options
+#   Mode: custom
+#   Description:  install from custom install script
+#   Parameters needed:
+#     install_script: 
+#       location of script relative to the 
+#       kvm-autotest/client directory
+#   Note:  For custom parameters for your script, define them as params below.
+#       They will be available as KVM_INSTALL_<name> in the OS environment
+#       Example: install_script will be available as KVM_INSTALL_install_script
+#
 # ---------------------
 params = {
     "name": "kvm_install",
@@ -57,7 +69,10 @@ params = {
 
     ## Install from git
     "git_repo": 'git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm.git',
-    "user_git_repo": 'git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm-userspace.git'
+    "user_git_repo": 'git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm-userspace.git',
+    
+    ## Custom install
+    "install_script": 'tests/kvm_runtest_2/custom_kvm_install.sh'
 }
 
 # Comment the job.run_test line if you do not want to install kvm on the host.
client/tests/kvm_runtest_2/kvm_install.py +13 -0
index 8be5a93..bb664b3 100755
@@ -77,6 +77,19 @@ def run_kvm_install(test, params, env):
     elif install_mode == "localsrc":
         __install_kvm(test, srcdir)
 
+    # install from custom script
+    elif install_mode == "custom":
+        install_script = params.get("install_script")
+        script = os.path.join(os.environ['AUTODIR'],install_script)
+        if not install_script:
+            message = "Custom script filename not specified"
+            kvm_log.error(message)
+            raise error.TestError, message
+        for k in params.keys():
+          os.putenv("KVM_INSTALL_%s" % (k), str(params[k]))
+	kvm_log.info("Running " + script + " to install kvm")
+        os.system(script)
+
     # invalid installation mode
     else:
         message = "Invalid installation mode: '%s'" % install_mode
Signature · 1 line
1.6.0.6
#1 lore raw

Hi Mike

Quoted 1 line · Mike Burns

From: Michael Burns <[email protected]>

The comments I had to make were pretty much covered by Eduardo and Mike Goldish...

1 - We should support passing parameters by both environment variables
and command line arguments
2 - test.bindir sounds like a better choice of path than the env
variable AUTODIR

Quoted 56 lines
---
 client/tests/kvm_runtest_2/control        |   17 ++++++++++++++++-
 client/tests/kvm_runtest_2/kvm_install.py |   13 +++++++++++++
 2 files changed, 29 insertions(+), 1 deletions(-)
client/tests/kvm_runtest_2/control +16 -1
index fd68e94..5d022b5 100644
@@ -41,6 +41,18 @@ link_if_not_exist(pwd, qemu_img, 'qemu-img')
 
 # ---------------------
 # Build and install kvm
+#
+# Details of Install options
+#   Mode: custom
+#   Description:  install from custom install script
+#   Parameters needed:
+#     install_script: 
+#       location of script relative to the 
+#       kvm-autotest/client directory
+#   Note:  For custom parameters for your script, define them as params below.
+#       They will be available as KVM_INSTALL_<name> in the OS environment
+#       Example: install_script will be available as KVM_INSTALL_install_script
+#
 # ---------------------
 params = {
     "name": "kvm_install",
@@ -57,7 +69,10 @@ params = {
 
     ## Install from git
     "git_repo": 'git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm.git',
-    "user_git_repo": 'git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm-userspace.git'
+    "user_git_repo": 'git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm-userspace.git',
+    
+    ## Custom install
+    "install_script": 'tests/kvm_runtest_2/custom_kvm_install.sh'
 }
 
 # Comment the job.run_test line if you do not want to install kvm on the host.
client/tests/kvm_runtest_2/kvm_install.py +6 -0
index 8be5a93..bb664b3 100755
@@ -77,6 +77,19 @@ def run_kvm_install(test, params, env):
     elif install_mode == "localsrc":
         __install_kvm(test, srcdir)
 
+    # install from custom script
+    elif install_mode == "custom":
+        install_script = params.get("install_script")
+        script = os.path.join(os.environ['AUTODIR'],install_script)
+        if not install_script:
+            message = "Custom script filename not specified"

client/tests/kvm_runtest_2/kvm_install.py def run_kvm_install(test, params, env): · line 95

Quoted 10 lines
client/tests/kvm_runtest_2/kvm_install.py +7 -0
+            kvm_log.error(message)
+            raise error.TestError, message
+        for k in params.keys():
+          os.putenv("KVM_INSTALL_%s" % (k), str(params[k]))
+	kvm_log.info("Running " + script + " to install kvm")
+        os.system(script)
+
     # invalid installation mode
     else:
         message = "Invalid installation mode: '%s'" % install_mode

Lucas