Re: [KVM-AUTOTEST PATCH 7/8] Add new function, VM.clone() to clone an existing VM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2009-06-05 at 17:46 -0300, Lucas Meneghel Rodrigues wrote:
> This method will be useful when writing functional tests.
> 
> Risk: Low (new method of the kvm test API)
> Visibility: Low (kvm test developers will have an additional
> API to use)

Applied, but the commit was ammended to follow the coding style. Sorry I
have overlooked it when I rebased the patch:

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 3001648..eb9717b 100644
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -126,6 +126,33 @@ class VM:
                 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.
+
+        @param name: Optional new VM name
+        @param params: Optional new VM creation parameters
+        @param qemu_path: Optional new path to qemu
+        @param image_dir: Optional new image dir
+        @param iso_dir: Optional new iso directory
+        """
+        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. If .pid

> Signed-off-by: Michael Goldish <mgoldish@xxxxxxxxxx>
> ---
>  client/tests/kvm/kvm_vm.py |   19 +++++++++++++++++++
>  1 files changed, 19 insertions(+), 0 deletions(-)
> 
> diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
> index 3001648..b81c0df 100644
> --- a/client/tests/kvm/kvm_vm.py
> +++ b/client/tests/kvm/kvm_vm.py
> @@ -126,6 +126,25 @@ class VM:
>                  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. If .pid
-- 
Lucas Meneghel Rodrigues
Software Engineer (QE)
Red Hat - Emerging Technologies

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux