[PATCH 1/4] [KVM-autotest] virt.kvm_vm: Make snapshot and boot params optional

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

 



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 <ldoktor@xxxxxxxxxx>
---
 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

--
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