|
6 | 6 | from virttest import remote |
7 | 7 | from virttest import utils_config |
8 | 8 | from virttest import utils_disk |
| 9 | +from virttest import utils_iptables |
9 | 10 | from virttest import utils_misc |
10 | 11 | from virttest import virsh |
11 | 12 | from virttest.libvirt_xml import vm_xml |
@@ -33,34 +34,49 @@ def setup_for_shared_filesystems(params, test): |
33 | 34 | nvram_path = params.get("nvram_path") |
34 | 35 | swtpm_path = params.get("swtpm_path") |
35 | 36 | nfs_mount_options = params.get("nfs_mount_options") |
| 37 | + mount_options = params.get("mount_options") |
36 | 38 | server_ip = params.get("server_ip") |
37 | 39 | server_user = params.get("server_user", "root") |
38 | 40 | server_pwd = params.get("server_pwd") |
39 | 41 | mount_images_path = params.get("mount_images_path") |
40 | 42 | mount_nvram_path = params.get("mount_nvram_path") |
41 | 43 | mount_swtpm_path = params.get("mount_swtpm_path") |
| 44 | + tpm_model = params.get("tpm_model") |
42 | 45 |
|
43 | 46 | if not os.path.exists(export_dir): |
44 | 47 | os.mkdir(export_dir) |
45 | 48 |
|
46 | 49 | mount_opt = "rw,no_root_squash,sync" |
| 50 | + process.run("exportfs -r", shell=True) |
47 | 51 | res = libvirt.setup_or_cleanup_nfs(is_setup=True, |
48 | 52 | is_mount=False, |
49 | 53 | export_options=mount_opt, |
50 | 54 | export_dir=export_dir) |
51 | 55 |
|
| 56 | + firewall_cmd = utils_iptables.Firewall_cmd() |
| 57 | + firewall_cmd.add_service('rpc-bind', permanent=True) |
| 58 | + firewall_cmd.add_service('mountd', permanent=True) |
52 | 59 | for path in [nfs_images_path, nfs_nvram_path, nfs_swtpm_path]: |
53 | 60 | if not utils_misc.check_exists(path): |
54 | 61 | process.run(f"mkdir -p {path}", shell=True, verbose=True) |
55 | 62 |
|
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) |
59 | 74 |
|
60 | 75 | 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) |
64 | 80 | remote_session.close() |
65 | 81 |
|
66 | 82 | remote_obj = None |
@@ -153,16 +169,18 @@ def setup_test(): |
153 | 169 | virsh.dumpxml(vm_name, debug=True) |
154 | 170 | migration_obj.setup_connection() |
155 | 171 | 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() |
157 | 175 |
|
158 | 176 | def verify_test_again(): |
159 | 177 | """ |
160 | 178 | Verify test again |
161 | 179 |
|
162 | 180 | """ |
163 | 181 | 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) |
166 | 184 |
|
167 | 185 | def cleanup_test(): |
168 | 186 | """ |
|
0 commit comments