From patchwork Fri Jun 5 20:46:33 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: 28306 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 n55Kks2U016169 for ; Fri, 5 Jun 2009 20:46:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753079AbZFEUqv (ORCPT ); Fri, 5 Jun 2009 16:46:51 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753091AbZFEUqu (ORCPT ); Fri, 5 Jun 2009 16:46:50 -0400 Received: from mx2.redhat.com ([66.187.237.31]:59803 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753024AbZFEUqu (ORCPT ); Fri, 5 Jun 2009 16:46:50 -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 n55KkqhK003270; Fri, 5 Jun 2009 16:46:52 -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 n55KknBE017621; Fri, 5 Jun 2009 16:46:50 -0400 Received: from localhost.localdomain (vpn-10-165.bos.redhat.com [10.16.10.165]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n55KkZ47015832; Fri, 5 Jun 2009 16:46:48 -0400 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues , Michael Goldish Subject: [KVM-AUTOTEST PATCH 7/8] Add new function, VM.clone() to clone an existing VM Date: Fri, 5 Jun 2009 17:46:33 -0300 Message-Id: <1244234794-7844-8-git-send-email-lmr@redhat.com> In-Reply-To: <1244234794-7844-7-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> 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 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) 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