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" Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx> --- 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 diff --git a/client/tests/kvm/base.cfg.sample b/client/tests/kvm/base.cfg.sample index 0e6d222..96e14a6 100644 --- a/client/tests/kvm/base.cfg.sample +++ b/client/tests/kvm/base.cfg.sample @@ -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 diff --git a/client/tests/kvm/blkdebug/default.conf b/client/tests/kvm/blkdebug/default.conf new file mode 100644 index 0000000..0497405 --- /dev/null +++ b/client/tests/kvm/blkdebug/default.conf @@ -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" diff --git a/client/virt/kvm_vm.py b/client/virt/kvm_vm.py index f7b8345..d0b8015 100644 --- a/client/virt/kvm_vm.py +++ b/client/virt/kvm_vm.py @@ -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"): diff --git a/client/virt/virt_vm.py b/client/virt/virt_vm.py index 8815bf4..de321c4 100644 --- a/client/virt/virt_vm.py +++ b/client/virt/virt_vm.py @@ -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. -- 1.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