From patchwork Mon Jun 8 15:20:59 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 28648 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n58FLbqc000834 for ; Mon, 8 Jun 2009 15:21:38 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755609AbZFHPVE (ORCPT ); Mon, 8 Jun 2009 11:21:04 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755527AbZFHPVD (ORCPT ); Mon, 8 Jun 2009 11:21:03 -0400 Received: from mx2.redhat.com ([66.187.237.31]:48707 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755361AbZFHPVB (ORCPT ); Mon, 8 Jun 2009 11:21:01 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n58FL30j009398; Mon, 8 Jun 2009 11:21:03 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n58FL23o029620; Mon, 8 Jun 2009 11:21:03 -0400 Received: from [10.16.10.92] (vpn-10-92.bos.redhat.com [10.16.10.92]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n58FL02N019784; Mon, 8 Jun 2009 11:21:01 -0400 Subject: Re: [KVM-AUTOTEST PATCH 7/8] Add new function, VM.clone() to clone an existing VM From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Michael Goldish In-Reply-To: <1244234794-7844-8-git-send-email-lmr@redhat.com> References: <1244234794-7844-1-git-send-email-lmr@redhat.com> <1244234794-7844-2-git-send-email-lmr@redhat.com> <1244234794-7844-3-git-send-email-lmr@redhat.com> <1244234794-7844-4-git-send-email-lmr@redhat.com> <1244234794-7844-5-git-send-email-lmr@redhat.com> <1244234794-7844-6-git-send-email-lmr@redhat.com> <1244234794-7844-7-git-send-email-lmr@redhat.com> <1244234794-7844-8-git-send-email-lmr@redhat.com> Date: Mon, 08 Jun 2009 12:20:59 -0300 Message-Id: <1244474459.2849.64.camel@localhost.localdomain> Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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: > Signed-off-by: Michael Goldish > --- > 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 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