Skip to contentSkip to conversation

Introduce blkdebug support to KVM autotest + migration test

PATCH New Lucas Meneghel Rodrigues 1 participant 4 messages Sep 8, 2011 KVM

lore
Share & tools
lore
#0 lore raw

cover Introduce blkdebug support to KVM autotest + migration test

In order to solve task:

http://autotest.kernel.org/ticket/50

Implemented support to providing blkdebug files to arbitrary guest images in autotest. Also, modified a bit the migrate test and introduced the variant migrate.with_blkdebug variant, that tries to mimic as much as possible the testcase described in ticket 50. Kevin, sorry that I took too long to work on this, let me know if you see any obvious problems on the implementation.

With this we can have people reproducing the test case mentioned with a stock autotest clone. Indeed we see state migration mismatch problems running the testcase:

Test                                                  Status     Seconds  Info
----                                                  ------     -------  ----
        (Result file: ../../results/default/status)
Fedora.15.64.migrate.with_blkdebug.tcp.smp2           FAIL       35       Unhandled VMMigrateStateMismatchError: Mismatch of VM state before and after migration (cd739e82e72179821b0599169432729c != 39920fecc39325cca5deab4e0c54792d)    [context: migrating 'vm1' --> after migration]
Fedora.15.64.migrate.with_blkdebug.unix.smp2          FAIL       46       Unhandled VMMigrateStateMismatchError: Mismatch of VM state before and after migration (9482fb1523f15e708b0e46058b22196c != 60f7757c88e8a3a656f701fa97501a97)    [context: migrating 'vm1' --> after migration]
Fedora.15.64.migrate.with_blkdebug.exec.smp2          FAIL       44       Unhandled VMMigrateStateMismatchError: Mismatch of VM state before and after migration (7f5d1cce87383c001a83d0d3a6529c68 != 76549ae93fc0b3d270dbf51e8cb49dd6)    [context: migrating 'vm1' --> after migration]
Fedora.15.64.migrate.with_blkdebug.mig_cancel.smp2    FAIL       101      Unhandled VMMigrateCancelError: Cannot cancel migration    [context: migrating 'vm1']
----                                                  GOOD       261 

Cheers!

Lucas Meneghel Rodrigues (3):
KVM test: Introduce blkdebug param to images
KVM test: migration subtest - Introduce migration_living_guest param KVM test: Introduce migrate.with_blkdebug variant

 client/tests/kvm/base.cfg.sample       |    9 ++++
 client/tests/kvm/blkdebug/default.conf |   16 +++++++
 client/tests/kvm/subtests.cfg.sample   |    6 +++
 client/tests/kvm/tests/migration.py    |   78 ++++++++++++++++++-------------
 client/virt/kvm_vm.py                  |   14 +++++-
 client/virt/virt_vm.py                 |   21 +++++++++
 6 files changed, 108 insertions(+), 36 deletions(-)
 create mode 100644 client/tests/kvm/blkdebug/default.conf
Signature · 1 line
1.7.6
#1 lore raw

PATCH 1/3 KVM test: Introduce blkdebug param to images

blkdebug files allow to inject errors in the block subsystem, allowing more types of tests to be executed. Now it is possible to set a blkdebug file for an arbitrary image 'imagefoo' used just like this

drive_blkdebug_imagefoo = blkdebug/default.conf

The blkdebug files can be stored on the specific location:

client/tests/kvm/blkdebug

And then specified like the above. An example of debug file can be seen here:

[inject-error]
state = "2"
event = "read_aio"
errno = "7"
immediately = "off"
once = "on"

[set-state]
state = "1"
event = "read_aio"
new_state = "2"

[set-state]
state = "2"
event = "read_aio"
new_state = "3"

---
 client/tests/kvm/base.cfg.sample       |    9 +++++++++
 client/tests/kvm/blkdebug/default.conf |   16 ++++++++++++++++
 client/virt/kvm_vm.py                  |   14 +++++++++++---
 client/virt/virt_vm.py                 |   21 +++++++++++++++++++++
 4 files changed, 57 insertions(+), 3 deletions(-)
 create mode 100644 client/tests/kvm/blkdebug/default.conf
client/tests/kvm/base.cfg.sample +9 -0
index 0e6d222..96e14a6 100644
@@ -28,6 +28,15 @@ image_size = 10G
 image_raw_device = no
 drive_index_image1 = 0
 drive_cache = none
+# You can specify a blkdebug file here, relative to kvm/blkdebug dir
+# we have a premade default.conf in there. Important to note that you
+# can set this for any image defined in the config at a given time
+#drive_blkdebug_image1 = blkdebug/default.conf
+drive_blkdebug_image1 =
+# What to do whether a read error is detected, such as 'stop'
+drive_rerror_image1 =
+# What to do whether a write error is detected, such as 'stop'
+drive_werror_image1 =
 
 # Cdrom drive index
 drive_index_cd1 = 1
client/tests/kvm/blkdebug/default.conf new file +16 -0
new file mode 100644
index 0000000..0497405
@@ -0,0 +1,16 @@
+[inject-error]
+state = "2"
+event = "read_aio"
+errno = "7"
+immediately = "off"
+once = "on"
+
+[set-state]
+state = "1"
+event = "read_aio"
+new_state = "2"
+
+[set-state]
+state = "2"
+event = "read_aio"
+new_state = "3"
client/virt/kvm_vm.py +11 -3
index f7b8345..d0b8015 100644
@@ -215,7 +215,8 @@ class VM(virt_vm.BaseVM):
                 return " -cdrom '%s'" % filename
 
         def add_drive(help, filename, index=None, format=None, cache=None,
-                      werror=None, serial=None, snapshot=False, boot=False):
+                      werror=None, rerror=None, serial=None, snapshot=False,
+                      boot=False, blkdebug=None):
             name = None;
             dev = "";
             if format == "ahci":
@@ -229,13 +230,18 @@ class VM(virt_vm.BaseVM):
                 dev += ",port=%d" % (int(index) + 1)
                 format = "none"
                 index = None
-            cmd = " -drive file='%s'" % filename
+            if blkdebug is not None:
+                cmd = " -drive file=blkdebug:%s:%s" % (blkdebug, filename)
+            else:
+                cmd = " -drive file='%s'" % filename
             if index is not None:
                 cmd += ",index=%s" % index
             if format:
                 cmd += ",if=%s" % format
             if cache:
                 cmd += ",cache=%s" % cache
+            if rerror:
+                cmd += ",rerror=%s" % rerror
             if werror:
                 cmd += ",werror=%s" % werror
             if serial:
@@ -440,10 +446,12 @@ class VM(virt_vm.BaseVM):
                                   image_params.get("drive_index"),
                                   image_params.get("drive_format"),
                                   image_params.get("drive_cache"),
+                                  image_params.get("drive_rerror"),
                                   image_params.get("drive_werror"),
                                   image_params.get("drive_serial"),
                                   image_params.get("image_snapshot") == "yes",
-                                  image_params.get("image_boot") == "yes")
+                                  image_params.get("image_boot") == "yes",
+                    virt_vm.get_image_blkdebug_filename(image_params, root_dir))
 
         redirs = []
         for redir_name in params.objects("redirs"):
client/virt/virt_vm.py +21 -0
index 8815bf4..de321c4 100644
@@ -188,6 +188,27 @@ class VMRebootError(VMError):
 class VMStatusError(VMError):
     pass
 
+
+def get_image_blkdebug_filename(params, root_dir):
+    """
+    Generate an blkdebug file path from params and root_dir.
+
+    blkdebug files allow error injection in the block subsystem.
+
+    @param params: Dictionary containing the test parameters.
+    @param root_dir: Base directory for relative filenames.
+
+    @note: params should contain:
+           blkdebug -- the name of the debug file.
+    """
+    blkdebug_name = params.get("drive_blkdebug", None)
+    if blkdebug_name is not None:
+        blkdebug_filename = virt_utils.get_path(root_dir, blkdebug_name)
+    else:
+        blkdebug_filename = None
+    return blkdebug_filename
+
+
 def get_image_filename(params, root_dir):
     """
     Generate an image path from params and root_dir.
Signature · 1 line
1.7.6
#2 lore raw

PATCH 2/3 KVM test: migration subtest - Introduce migration_living_guest param

In reply to Lucas Meneghel Rodrigues

In order to test a special guest configuration (special blkdebug config files to inject errors on the block subsystem), added a migration_living_guest param. If the param is set to "no", no attempt to have a session on the guest will be made, since the guest block subsystem will stop when the first error is injected.

---
 client/tests/kvm/tests/migration.py |   78 ++++++++++++++++++++---------------
 1 files changed, 45 insertions(+), 33 deletions(-)
client/tests/kvm/tests/migration.py +45 -33
index 7e877fe..1e02784 100644
@@ -36,34 +36,40 @@ def run_migration(test, params, env):
         mig_speed = params.get("mig_speed", "1G")
         return vm.monitor.migrate_set_speed(mig_speed)
 
-    vm = env.get_vm(params["main_vm"])
-    vm.verify_alive()
-    timeout = int(params.get("login_timeout", 360))
-    session = vm.wait_for_login(timeout=timeout)
-
     mig_timeout = float(params.get("mig_timeout", "3600"))
     mig_protocol = params.get("migration_protocol", "tcp")
     mig_cancel_delay = int(params.get("mig_cancel") == "yes") * 2
     offline = params.get("offline", "no") == "yes"
     check = params.get("vmstate_check", "no") == "yes"
+    living_guest_os = params.get("migration_living_guest", "yes") == "yes"
+
+    vm = env.get_vm(params["main_vm"])
+    vm.verify_alive()
+    timeout = int(params.get("login_timeout", 360))
+    if living_guest_os:
+        session = vm.wait_for_login(timeout=timeout)
 
     # Get the output of migration_test_command
-    test_command = params.get("migration_test_command")
-    reference_output = session.cmd_output(test_command)
+    if living_guest_os:
+        test_command = params.get("migration_test_command")
+        reference_output = session.cmd_output(test_command)
 
     # Start some process in the background (and leave the session open)
-    background_command = params.get("migration_bg_command", "")
-    session.sendline(background_command)
-    time.sleep(5)
+    if living_guest_os:
+        background_command = params.get("migration_bg_command", "")
+        session.sendline(background_command)
+        time.sleep(5)
 
     # Start another session with the guest and make sure the background
     # process is running
-    session2 = vm.wait_for_login(timeout=timeout)
+    if living_guest_os:
+        session2 = vm.wait_for_login(timeout=timeout)
 
     try:
-        check_command = params.get("migration_bg_check_command", "")
-        session2.cmd(check_command, timeout=30)
-        session2.close()
+        if living_guest_os:
+            check_command = params.get("migration_bg_check_command", "")
+            session2.cmd(check_command, timeout=30)
+            session2.close()
 
         # run some functions before migrate start.
         pre_migrate = get_functions(params.get("pre_migrate"), locals())
@@ -79,32 +85,38 @@ def run_migration(test, params, env):
             func()
 
         # Log into the guest again
-        logging.info("Logging into guest after migration...")
-        session2 = vm.wait_for_login(timeout=30)
-        logging.info("Logged in after migration")
+        if living_guest_os:
+            logging.info("Logging into guest after migration...")
+            session2 = vm.wait_for_login(timeout=30)
+            logging.info("Logged in after migration")
 
         # Make sure the background process is still running
-        session2.cmd(check_command, timeout=30)
+        if living_guest_os:
+            session2.cmd(check_command, timeout=30)
 
         # Get the output of migration_test_command
-        output = session2.cmd_output(test_command)
+        if living_guest_os:
+            output = session2.cmd_output(test_command)
 
         # Compare output to reference output
-        if output != reference_output:
-            logging.info("Command output before migration differs from "
-                         "command output after migration")
-            logging.info("Command: %s", test_command)
-            logging.info("Output before:" +
-                         virt_utils.format_str_for_message(reference_output))
-            logging.info("Output after:" +
-                         virt_utils.format_str_for_message(output))
-            raise error.TestFail("Command '%s' produced different output "
-                                 "before and after migration" % test_command)
+        if living_guest_os:
+            if output != reference_output:
+                logging.info("Command output before migration differs from "
+                             "command output after migration")
+                logging.info("Command: %s", test_command)
+                logging.info("Output before:" +
+                             virt_utils.format_str_for_message(reference_output))
+                logging.info("Output after:" +
+                             virt_utils.format_str_for_message(output))
+                raise error.TestFail("Command '%s' produced different output "
+                                     "before and after migration" % test_command)
 
     finally:
         # Kill the background process
-        if session2 and session2.is_alive():
-            session2.cmd_output(params.get("migration_bg_kill_command", ""))
+        if living_guest_os:
+            if session2 and session2.is_alive():
+                session2.cmd_output(params.get("migration_bg_kill_command", ""))
 
-    session2.close()
-    session.close()
+    if living_guest_os:
+        session2.close()
+        session.close()
Signature · 1 line
1.7.6
#3 lore raw

PATCH 3/3 KVM test: Introduce migrate.with_blkdebug variant

In reply to Lucas Meneghel Rodrigues

In order to solve task

http://autotest.kernel.org/ticket/50

Create a migrate.with_blkdebug variant, that will migrate the vm with state check before and after migration. As the reporter of the original problem on task 50 said, indeed we have a lot of migration state mismatch problems with a current qemu-kvm.

---
 client/tests/kvm/subtests.cfg.sample |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
client/tests/kvm/subtests.cfg.sample +6 -0
index 9d9dbba..d79b3af 100644
@@ -164,6 +164,12 @@ variants:
                 mig_cancel = yes
         variants:
             - @default:
+            - with_blkdebug:
+                drive_blkdebug_image1 = blkdebug/default.conf
+                drive_rerror_image1 = stop
+                drive_werror_image1 = stop
+                vmstate_check = yes
+                migration_living_guest = no
             - with_set_speed:
                 mig_speed = 1G
                 pre_migrate = "mig_set_speed"
Signature · 1 line
1.7.6