Skip to content

Commit

Permalink
Merge pull request #5276 from cliping/scsi
Browse files Browse the repository at this point in the history
migration: Add case to test block disk
  • Loading branch information
dzhengfy authored Dec 13, 2023
2 parents 2694ef5 + ac18e73 commit e4bf11f
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
- migration_with_copy_storage.disk_type_coverage.block_disk:
type = block_disk
migration_setup = 'yes'
# Console output can only be monitored via virsh console output
only_pty = True
take_regular_screendumps = no
# Extra options to pass after <domain> <desturi>
virsh_migrate_extra = ""
# SSH connection time out
ssh_timeout = 60
# Local URI
virsh_migrate_connect_uri = "qemu:///system"
image_convert = "no"
status_error = "no"
migrate_desturi_port = "16509"
migrate_desturi_type = "tcp"
virsh_migrate_desturi = "qemu+tcp://${migrate_dest_host}/system"
start_vm = "no"
setup_nfs = "no"
nfs_mount_dir =
server_ip = "${migrate_dest_host}"
server_user = "root"
server_pwd = "${migrate_dest_pwd}"
client_ip = "${migrate_source_host}"
client_user = "root"
client_pwd = "${migrate_source_pwd}"
target_type = "vdb"
attach_disk_args = "--config --driver qemu --subdriver raw"
scsi_disk_option = "lbpu=1 lbpws=1"
check_disk_after_mig = "yes"
variants:
- p2p:
virsh_migrate_options = "--live --p2p --verbose"
- non_p2p:
virsh_migrate_options = "--live --verbose"
variants:
- copy_storage_all:
copy_storage_option = "--copy-storage-all"
- copy_storage_inc:
copy_storage_option = "--copy-storage-inc"
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright Redhat
#
# SPDX-License-Identifier: GPL-2.0
#
# Author: Liping Cheng <[email protected]>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import re

from virttest import remote
from virttest import utils_disk
from virttest import virsh

from virttest.utils_test import libvirt

from provider.migration import base_steps


def setup_block_device_on_remote(params):
"""
Setup block device on remote host
:param params: Dictionary with the test parameters
"""
cmd = "modprobe scsi_debug lbpu=1 lbpws=1 dev_size_mb=2048"
remote.run_remote_cmd(cmd, params, ignore_status=False)


def cleanup_block_device_on_remote(params):
"""
Cleanup block device on remote host
:param params: Dictionary with the test parameters
"""
ret = remote.run_remote_cmd("lsscsi | grep scsi_debug", params, ignore_status=False)
if ret.exit_status == 0:
scsi_addr_pattern = '[0-9]+:[0-9]+:[0-9]+:[0-9]+'
for addr in re.findall(scsi_addr_pattern, ret.stdout_text):
remote.run_remote_cmd("echo 1>/sys/class/scsi_device/{}/device/delete".format(addr),
params, ignore_status=False)

remote.run_remote_cmd("modprobe -r scsi_debug", params, ignore_status=False)


def run(test, params, env):
"""
To verify that live migration with copying storage can succeed for block
disk.
:param test: test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
def setup_test():
"""
Setup steps
"""
test.log.info("Setup steps.")
attach_disk_args = params.get("attach_disk_args")
scsi_disk_option = params.get("scsi_disk_option")
target_type = params.get("target_type")

migration_obj.setup_connection()
base_steps.prepare_disks_remote(params, vm)
setup_block_device_on_remote(params)

disk_source = libvirt.create_scsi_disk(scsi_disk_option)
virsh.attach_disk(vm_name, disk_source, target_type,
attach_disk_args, debug=True, ignore_status=False)
vm.start()
vm_session = vm.wait_for_login()
utils_disk.linux_disk_check(vm_session, target_type)
vm_session.close()

def cleanup_test():
"""
Cleanup steps
"""
test.log.info("Cleanup steps.")
migration_obj.cleanup_connection()
libvirt.delete_scsi_disk()
cleanup_block_device_on_remote(params)
base_steps.cleanup_disks_remote(params, vm)

vm_name = params.get("migrate_main_vm")
vm = env.get_vm(vm_name)
migration_obj = base_steps.MigrationBase(test, vm, params)

try:
setup_test()
migration_obj.run_migration()
migration_obj.verify_default()
finally:
cleanup_test()

0 comments on commit e4bf11f

Please sign in to comment.