Skip to content

Commit 794b8d1

Browse files
authored
Merge pull request #6541 from cliping/no_sufficient_disk
migration: Add new case for copy storage migration
2 parents 96da939 + d871f4d commit 794b8d1

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
- migration_with_copy_storage.no_sufficient_disk_space_on_target:
2+
type = no_sufficient_disk_space_on_target
3+
migration_setup = 'yes'
4+
# Console output can only be monitored via virsh console output
5+
only_pty = True
6+
take_regular_screendumps = no
7+
# Extra options to pass after <domain> <desturi>
8+
virsh_migrate_extra = ""
9+
# SSH connection time out
10+
ssh_timeout = 60
11+
# Local URI
12+
virsh_migrate_connect_uri = "qemu:///system"
13+
image_convert = "no"
14+
migrate_desturi_port = "16509"
15+
migrate_desturi_type = "tcp"
16+
virsh_migrate_desturi = "qemu+tcp://${migrate_dest_host}/system"
17+
setup_nfs = "no"
18+
nfs_mount_dir =
19+
server_ip = "${migrate_dest_host}"
20+
server_user = "root"
21+
server_pwd = "${migrate_dest_pwd}"
22+
client_ip = "${migrate_source_host}"
23+
client_user = "root"
24+
client_pwd = "${migrate_source_pwd}"
25+
status_error = "yes"
26+
disk_size = "200M"
27+
block_path = "/var/tmp/no_sufficient_disk_space.qcow2"
28+
err_msg = "No space left on device"
29+
variants:
30+
- p2p:
31+
virsh_migrate_options = "--live --p2p --verbose"
32+
- non_p2p:
33+
virsh_migrate_options = "--live --verbose"
34+
variants:
35+
- copy_storage_all:
36+
copy_storage_option = "--copy-storage-all"
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2+
#
3+
# Copyright Redhat
4+
#
5+
# SPDX-License-Identifier: GPL-2.0
6+
#
7+
# Author: Liping Cheng <[email protected]>
8+
#
9+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10+
11+
import os
12+
13+
from virttest import remote
14+
from virttest import utils_misc
15+
16+
from virttest.utils_libvirt import libvirt_disk
17+
18+
from provider.migration import base_steps
19+
20+
21+
def run(test, params, env):
22+
"""
23+
To verify that live migration with copying storage will fail when there
24+
is no sufficient disk space on target host.
25+
26+
:param test: test object
27+
:param params: dictionary with the test parameters
28+
:param env: dictionary with test environment.
29+
"""
30+
def setup_test():
31+
"""
32+
Setup steps
33+
34+
"""
35+
disk_size = params.get("disk_size")
36+
block_path = params.get("block_path")
37+
38+
migration_obj.setup_connection()
39+
remote_session = remote.remote_login("ssh", server_ip, "22",
40+
server_user, server_pwd,
41+
r'[$#%]')
42+
utils_misc.make_dirs(disk_path, remote_session)
43+
remote_session.cmd(f"rm -rf {block_path}")
44+
libvirt_disk.create_disk(first_disk["type"], path=block_path,
45+
size=disk_size, disk_format="qcow2",
46+
extra="-o preallocation=falloc",
47+
session=remote_session)
48+
remote_session.cmd(f"losetup /dev/loop0 {block_path}")
49+
remote_session.cmd("mkfs.ext3 /dev/loop0")
50+
remote_session.cmd(f"mount /dev/loop0 {disk_path}")
51+
52+
_, file_size = vm.get_device_size(first_disk["target"])
53+
libvirt_disk.create_disk(first_disk["type"], path=disk_name,
54+
size=file_size, disk_format="qcow2",
55+
session=remote_session)
56+
remote_session.close()
57+
58+
def cleanup_test():
59+
"""
60+
Cleanup steps
61+
62+
"""
63+
block_path = params.get("block_path")
64+
65+
migration_obj.cleanup_connection()
66+
remote_session = remote.remote_login("ssh", server_ip, "22",
67+
server_user, server_pwd,
68+
r'[$#%]')
69+
remote_session.cmd(f"umount {disk_path}")
70+
remote_session.cmd("losetup -d /dev/loop0")
71+
remote_session.cmd(f"rm -rf {block_path}")
72+
remote_session.close()
73+
74+
server_ip = params.get("server_ip")
75+
server_user = params.get("server_user")
76+
server_pwd = params.get("server_pwd")
77+
vm_name = params.get("migrate_main_vm")
78+
vm = env.get_vm(vm_name)
79+
first_disk = vm.get_first_disk_devices()
80+
disk_name = first_disk["source"]
81+
disk_path = os.path.dirname(disk_name)
82+
migration_obj = base_steps.MigrationBase(test, vm, params)
83+
84+
try:
85+
setup_test()
86+
migration_obj.run_migration()
87+
migration_obj.verify_default()
88+
finally:
89+
cleanup_test()

0 commit comments

Comments
 (0)