From: Lukas Doktor Subject: [PATCH 1/4] [KVM-autotest] virt.kvm_vm: Make snapshot and boot params optional Date: Mon, 27 Feb 2012 19:42:40 +0100 Message-ID: <1330368163-18384-2-git-send-email-ldoktor@redhat.com> References: <1330368163-18384-1-git-send-email-ldoktor@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: autotest@test.kernel.org, kvm@vger.kernel.org, kvm-autotest@redhat.com, ldoktor@redhat.com, jzupka@redhat.com Return-path: In-Reply-To: <1330368163-18384-1-git-send-email-ldoktor@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: autotest-bounces@test.kernel.org Errors-To: autotest-bounces@test.kernel.org List-Id: kvm.vger.kernel.org Currently boot and snapshot parameters are either 'yes' or not present. This patch enables specify 'yes', 'no' or not present. 'no' option is necessarily eg. when -snapshot is present and we want to override the 'snapshot=off' value on one device. Signed-off-by: Lukas Doktor --- client/virt/kvm_vm.py | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-) diff --git a/client/virt/kvm_vm.py b/client/virt/kvm_vm.py index cc181d7..fcbdde4 100644 --- a/client/virt/kvm_vm.py +++ b/client/virt/kvm_vm.py @@ -201,11 +201,8 @@ class VM(virt_vm.BaseVM): Add option to qemu parameters. """ fmt=",%s=%s" - if value and isinstance(value, bool): - if value: - return fmt % (option, "on") - else: - return fmt % (option, "off") + if isinstance(value, bool): + return fmt % (option, "on" if value else "off") elif value and isinstance(value, str): # "EMPTY_STRING" and "NULL_STRING" is used for testing illegal # foramt of option. @@ -301,7 +298,7 @@ class VM(virt_vm.BaseVM): return " -cdrom '%s'" % filename def add_drive(help, filename, index=None, format=None, cache=None, - werror=None, rerror=None, serial=None, snapshot=False, + werror=None, rerror=None, serial=None, snapshot=None, boot=False, blkdebug=None, bus=None, port=None, bootindex=None, removable=None, min_io_size=None, opt_io_size=None, physical_block_size=None, @@ -648,8 +645,12 @@ class VM(virt_vm.BaseVM): image_params.get("drive_werror"), image_params.get("drive_rerror"), image_params.get("drive_serial"), - image_params.get("image_snapshot") == "yes", - image_params.get("image_boot") == "yes", + True if image_params.get("image_snapshot") == "yes" else ( + False if image_params.get("image_snapshot") == "no" else + None), + True if image_params.get("image_boot") == "yes" else ( + False if image_params.get("image_boot") == "no" else + None), virt_vm.get_image_blkdebug_filename(image_params, self.virt_dir), bus, -- 1.7.7.6