diff mbox

[KVM-AUTOTEST] kvm_vm.py: add new function VM.clone() which returns a clone of the VM

Message ID fa70b62b45e06d2827ecc72fdeb033680c336d5c.1243179847.git.mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish May 24, 2009, 3:46 p.m. UTC
Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm_runtest_2/kvm_vm.py |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

Comments

Avi Kivity May 25, 2009, 12:01 p.m. UTC | #1
Michael Goldish wrote:
> Signed-off-by: Michael Goldish <mgoldish@redhat.com>
> ---
>  client/tests/kvm_runtest_2/kvm_vm.py |   18 ++++++++++++++++++
>  1 files changed, 18 insertions(+), 0 deletions(-)
>
> diff --git a/client/tests/kvm_runtest_2/kvm_vm.py b/client/tests/kvm_runtest_2/kvm_vm.py
> index af06693..9571a3b 100644
> --- a/client/tests/kvm_runtest_2/kvm_vm.py
> +++ b/client/tests/kvm_runtest_2/kvm_vm.py
> @@ -115,6 +115,24 @@ class VM:
>              if not os.path.exists(self.monitor_file_name):
>                  break
>  
> +    def clone(self, name=None, params=None, qemu_path=None, image_dir=None, iso_dir=None):
> +        """Return a clone of the VM object with optionally modified parameters.
> +
> +        The clone is initially not alive and needs to be started using create().
> +        Any parameters not passed to this function are copied from the source VM.
> +        """
> +        if name == None:
> +            name = self.name
> +        if params == None:
> +            params = self.params.copy()
> +        if qemu_path == None:
> +            qemu_path = self.qemu_path
> +        if image_dir == None:
> +            image_dir = self.image_dir
> +        if iso_dir == None:
> +            iso_dir = self.iso_dir
> +        return VM(name, params, qemu_path, image_dir, iso_dir)
> +
>   

    return VM(name or self.name, params or self.params.copy(), ...)
diff mbox

Patch

diff --git a/client/tests/kvm_runtest_2/kvm_vm.py b/client/tests/kvm_runtest_2/kvm_vm.py
index af06693..9571a3b 100644
--- a/client/tests/kvm_runtest_2/kvm_vm.py
+++ b/client/tests/kvm_runtest_2/kvm_vm.py
@@ -115,6 +115,24 @@  class VM:
             if not os.path.exists(self.monitor_file_name):
                 break
 
+    def clone(self, name=None, params=None, qemu_path=None, image_dir=None, iso_dir=None):
+        """Return a clone of the VM object with optionally modified parameters.
+
+        The clone is initially not alive and needs to be started using create().
+        Any parameters not passed to this function are copied from the source VM.
+        """
+        if name == None:
+            name = self.name
+        if params == None:
+            params = self.params.copy()
+        if qemu_path == None:
+            qemu_path = self.qemu_path
+        if image_dir == None:
+            image_dir = self.image_dir
+        if iso_dir == None:
+            iso_dir = self.iso_dir
+        return VM(name, params, qemu_path, image_dir, iso_dir)
+
     def verify_process_identity(self):
         """Make sure .pid really points to the original qemu process.