Skip to content

Commit e3ffa44

Browse files
committed
migration: Update canonical_paths_in_shared_filesystems case
According to bug RHEL-86592, update auto script. Signed-off-by: lcheng <[email protected]>
1 parent 4cd579e commit e3ffa44

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

libvirt/tests/cfg/migration/migration_misc/canonical_paths_in_shared_filesystems.cfg

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
virsh_migrate_dest_state = "running"
1919
virsh_migrate_src_state = "shut off"
2020
image_convert = 'no'
21-
vms = avocado-vt-vm1
21+
vms = avocado-vt-vm1 vm2
2222
server_ip = "${migrate_dest_host}"
2323
server_user = "root"
2424
server_pwd = "${migrate_dest_pwd}"
@@ -30,8 +30,11 @@
3030
migrate_desturi_type = "ssh"
3131
virsh_migrate_desturi = "qemu+ssh://${migrate_dest_host}/system"
3232
start_vm = "no"
33-
nfs_mount_options = "bind"
34-
export_dir = "/nfs"
33+
mount_options_images = 'bind,context="system_u:object_r:virt_image_t:s0"'
34+
mount_options_nvram = 'bind,context="system_u:object_r:qemu_var_run_t:s0"'
35+
mount_options_swtpm = 'bind,context="system_u:object_r:virt_var_lib_t:s0"'
36+
export_dir = "/var/shared_filesystems"
37+
mount_options = "bind"
3538
nfs_server_ip = "${migrate_source_host}"
3639
images_path = "/var/lib/libvirt/images"
3740
nvram_path = "/var/lib/libvirt/qemu/nvram"
@@ -64,6 +67,7 @@
6467
firmware_type = "ovmf"
6568
loader_path = "/usr/share/edk2/ovmf/OVMF.amdsev.fd"
6669
loader_dict = {'os_firmware': 'efi', 'loader_stateless': 'yes', 'loader': '${loader_path}', 'loader_type': 'rom'}
70+
simple_disk_check_after_mig = "no"
6771
- uefi_with_nvram:
6872
firmware_type = "ovmf"
6973
loader_path = "/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd"

libvirt/tests/src/migration/migration_misc/canonical_paths_in_shared_filesystems.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from virttest import remote
77
from virttest import utils_config
88
from virttest import utils_disk
9+
from virttest import utils_iptables
910
from virttest import utils_misc
1011
from virttest import virsh
1112
from virttest.libvirt_xml import vm_xml
@@ -33,34 +34,49 @@ def setup_for_shared_filesystems(params, test):
3334
nvram_path = params.get("nvram_path")
3435
swtpm_path = params.get("swtpm_path")
3536
nfs_mount_options = params.get("nfs_mount_options")
37+
mount_options = params.get("mount_options")
3638
server_ip = params.get("server_ip")
3739
server_user = params.get("server_user", "root")
3840
server_pwd = params.get("server_pwd")
3941
mount_images_path = params.get("mount_images_path")
4042
mount_nvram_path = params.get("mount_nvram_path")
4143
mount_swtpm_path = params.get("mount_swtpm_path")
44+
tpm_model = params.get("tpm_model")
4245

4346
if not os.path.exists(export_dir):
4447
os.mkdir(export_dir)
4548

4649
mount_opt = "rw,no_root_squash,sync"
50+
process.run("exportfs -r", shell=True)
4751
res = libvirt.setup_or_cleanup_nfs(is_setup=True,
4852
is_mount=False,
4953
export_options=mount_opt,
5054
export_dir=export_dir)
5155

56+
firewall_cmd = utils_iptables.Firewall_cmd()
57+
firewall_cmd.add_service('rpc-bind', permanent=True)
58+
firewall_cmd.add_service('mountd', permanent=True)
5259
for path in [nfs_images_path, nfs_nvram_path, nfs_swtpm_path]:
5360
if not utils_misc.check_exists(path):
5461
process.run(f"mkdir -p {path}", shell=True, verbose=True)
5562

56-
utils_disk.mount(nfs_images_path, images_path, options=nfs_mount_options)
57-
utils_disk.mount(nfs_nvram_path, nvram_path, options=nfs_mount_options)
58-
utils_disk.mount(nfs_swtpm_path, swtpm_path, options=nfs_mount_options)
63+
if tpm_model:
64+
process.run(f"semanage fcontext -a -e /mnt {export_dir}", shell=True, verbose=True)
65+
process.run(f"restorecon -Rv {export_dir}", shell=True, verbose=True)
66+
process.run(f"chcon -R -t mnt_t {export_dir}/libvirt/", shell=True, verbose=True)
67+
utils_disk.mount(nfs_images_path, images_path, options=params.get("mount_options_images"))
68+
utils_disk.mount(nfs_nvram_path, nvram_path, options=params.get("mount_options_nvram"))
69+
utils_disk.mount(nfs_swtpm_path, swtpm_path, options=params.get("mount_options_swtpm"))
70+
else:
71+
utils_disk.mount(nfs_images_path, images_path, options=mount_options, verbose=True)
72+
utils_disk.mount(nfs_nvram_path, nvram_path, options=mount_options, verbose=True)
73+
utils_disk.mount(nfs_swtpm_path, swtpm_path, options=mount_options, verbose=True)
5974

6075
remote_session = remote.wait_for_login("ssh", server_ip, "22", server_user, server_pwd, r"[\#\$]\s*$")
61-
utils_disk.mount(mount_images_path, images_path, session=remote_session)
62-
utils_disk.mount(mount_nvram_path, nvram_path, session=remote_session)
63-
utils_disk.mount(mount_swtpm_path, swtpm_path, session=remote_session)
76+
77+
utils_disk.mount(mount_images_path, images_path, session=remote_session, options=nfs_mount_options, verbose=True)
78+
utils_disk.mount(mount_nvram_path, nvram_path, session=remote_session, options=nfs_mount_options, verbose=True)
79+
utils_disk.mount(mount_swtpm_path, swtpm_path, session=remote_session, options=nfs_mount_options, verbose=True)
6480
remote_session.close()
6581

6682
remote_obj = None
@@ -153,16 +169,18 @@ def setup_test():
153169
virsh.dumpxml(vm_name, debug=True)
154170
migration_obj.setup_connection()
155171
vm.start()
156-
vm.wait_for_login().close()
172+
# stateless='yes' only use for AMD test
173+
if boot_type != "statless_uefi":
174+
vm.wait_for_login().close()
157175

158176
def verify_test_again():
159177
"""
160178
Verify test again
161179
162180
"""
163181
test.log.info("Verify test again.")
164-
dargs = {"check_disk_on_dest": "no"}
165-
migration_obj.migration_test.post_migration_check([vm], dargs)
182+
params.update({"check_disk_on_dest": "no"})
183+
migration_obj.migration_test.post_migration_check([vm], params)
166184

167185
def cleanup_test():
168186
"""

0 commit comments

Comments
 (0)