Skip to content

Commit

Permalink
Merge pull request autotest#5280 from cliping/size
Browse files Browse the repository at this point in the history
migration: Add case about image size
  • Loading branch information
chunfuwen authored Dec 11, 2023
2 parents 5d943f8 + 333e885 commit 4651bf4
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
- migration_with_copy_storage.target_image_smaller_than_source:
type = target_image_smaller_than_source
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"
migrate_desturi_port = "16509"
migrate_desturi_type = "tcp"
virsh_migrate_desturi = "qemu+tcp://${migrate_dest_host}/system"
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}"
status_error = "yes"
disk_size = "2G"
err_msg = "migration of disk vda failed: Source and target image have different sizes"
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,62 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright Redhat
#
# SPDX-License-Identifier: GPL-2.0
#
# Author: Liping Cheng <[email protected]>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import os

from virttest import remote
from virttest import utils_misc

from virttest.utils_libvirt import libvirt_disk

from provider.migration import base_steps


def run(test, params, env):
"""
To verify that live migration with copying storage will fail when target
image size is smaller than source image size.
:param test: test object
:param params: dictionary with the test parameters
:param env: dictionary with test environment.
"""
def setup_test():
"""
Setup steps
"""
server_ip = params.get("server_ip")
server_user = params.get("server_user")
server_pwd = params.get("server_pwd")
disk_size = params.get("disk_size")

migration_obj.setup_connection()
remote_session = remote.remote_login("ssh", server_ip, "22",
server_user, server_pwd,
r'[$#%]')
first_disk = vm.get_first_disk_devices()
disk_path = first_disk["source"]
utils_misc.make_dirs(os.path.dirname(disk_path), remote_session)
libvirt_disk.create_disk(first_disk["type"], path=disk_path,
size=disk_size, disk_format="qcow2",
session=remote_session)
remote_session.close()

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:
migration_obj.cleanup_connection()
base_steps.cleanup_disks_remote(params, vm)

0 comments on commit 4651bf4

Please sign in to comment.