-
Notifications
You must be signed in to change notification settings - Fork 180
migration: Add case about suspend virsh command #6656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cliping
wants to merge
1
commit into
autotest:master
Choose a base branch
from
cliping:suspend
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...migration/destructive_operations_around_live_migration/suspend_virsh_during_migration.cfg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| - migration.destructive_operations_around_live_migration.suspend_virsh_during_migration: | ||
| type = suspend_virsh_during_migration | ||
| migration_setup = 'yes' | ||
| storage_type = 'nfs' | ||
| setup_local_nfs = 'yes' | ||
| disk_type = "file" | ||
| disk_source_protocol = "netfs" | ||
| mnt_path_name = ${nfs_mount_dir} | ||
| # 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' | ||
| virsh_migrate_dest_state = "running" | ||
| virsh_migrate_src_state = "shut off" | ||
| image_convert = 'no' | ||
| server_ip = "${migrate_dest_host}" | ||
| server_user = "root" | ||
| server_pwd = "${migrate_dest_pwd}" | ||
| check_network_accessibility_after_mig = "yes" | ||
| migrate_desturi_port = "16509" | ||
| migrate_desturi_type = "tcp" | ||
| virsh_migrate_desturi = "qemu+tcp://${migrate_dest_host}/system" | ||
| status_error = "no" | ||
| migrate_speed = "15" | ||
| virsh_migrate_dest_state = "running" | ||
| virsh_migrate_src_state = "shut off" | ||
| start_vm = "yes" | ||
| variants: | ||
| - with_precopy: | ||
| action_during_mig = '[{"func": "MigrationTest().do_cancel", "func_param": "signal.SIGTSTP", "after_event": "migration-iteration"}]' | ||
| variants: | ||
| - p2p: | ||
| virsh_migrate_options = '--live --p2p --verbose' | ||
| expected_event_src = ["lifecycle.*Stopped Migrated", "job-completed"] | ||
| expected_event_target = ["lifecycle.*: Resumed Migrated"] | ||
| - non_p2p: | ||
| virsh_migrate_options = '--live --verbose' | ||
| unexpected_event_src = ["Stopped Migrated", "job-completed"] | ||
| expected_event_target = ["lifecycle.*: Shutdown Finished after host request", "lifecycle.*: Stopped Destroyed"] | ||
| virsh_migrate_dest_state = "nonexist" | ||
| virsh_migrate_src_state = "running" | ||
| status_error = "yes" | ||
| - with_postcopy: | ||
| action_during_mig = '[{"func": "virsh.migrate_postcopy", "func_param": "'%s' % params.get('migrate_main_vm')", "after_event": "migration-iteration"}, {"func": "MigrationTest().do_cancel", "func_param": "signal.SIGTSTP", "after_event": "Suspended Post-copy"}]' | ||
| variants: | ||
| - p2p: | ||
| virsh_migrate_options = '--live --p2p --verbose --postcopy' | ||
| expected_event_src = ["lifecycle.*Stopped Migrated", "job-completed"] | ||
| expected_event_target = ["lifecycle.*: Resumed Post-copy", "lifecycle.*: Resumed Migrated"] | ||
| - non_p2p: | ||
| virsh_migrate_options = '--live --verbose --postcopy' | ||
| expected_event_src = ["lifecycle.*Suspended Post-copy", "lifecycle.*Stopped Migrated", "job-completed"] | ||
| expected_event_target = ["lifecycle.*: Resumed Post-copy", "lifecycle.*: Resumed Migrated"] | ||
34 changes: 34 additions & 0 deletions
34
.../migration/destructive_operations_around_live_migration/suspend_virsh_during_migration.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| # | ||
| # Copyright Redhat | ||
| # | ||
| # SPDX-License-Identifier: GPL-2.0 | ||
| # | ||
| # Author: Liping Cheng <[email protected]> | ||
| # | ||
| # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| from provider.migration import base_steps | ||
| from provider.migration import migration_base | ||
|
|
||
|
|
||
| def run(test, params, env): | ||
| """ | ||
| This case is to verify that if virsh(management app) is suspended during | ||
| migration, migration will succeed. | ||
|
|
||
| """ | ||
| vm_name = params.get("migrate_main_vm") | ||
| vm = env.get_vm(vm_name) | ||
| migration_obj = base_steps.MigrationBase(test, vm, params) | ||
| virsh_session = None | ||
| remote_virsh_session = None | ||
|
|
||
| try: | ||
| migration_obj.setup_connection() | ||
| virsh_session, remote_virsh_session = migration_base.monitor_event(params) | ||
| migration_obj.run_migration() | ||
| migration_obj.verify_default() | ||
| migration_base.check_event_output(params, test, virsh_session, remote_virsh_session) | ||
| finally: | ||
| migration_obj.cleanup_connection() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Fix quoting in
action_during_migfor with_postcopyThe
action_during_migvalue here is single‑quoted as a whole and also contains unescaped single quotes in'%s'andparams.get('migrate_main_vm'). In the usual VT cfg workflow (where these values are interpreted as Python expressions/strings), this will very likely lead to a syntax/parse error for this scenario, unlike the simpler precopy case on Line 35.Consider escaping the inner single quotes (or switching the outer string to double quotes) so that the expression remains valid, for example:
This keeps the intended
'%s' % params.get('migrate_main_vm')expression intact while avoiding conflicts with the outer quotes.Please rerun the parser/tests for this config after adjusting the quoting to confirm it loads and the postcopy variants execute correctly.
I'll verify this quoting concern by examining the configuration file and understanding how the VT cfg framework processes these strings.
Length of output: 3058
🏁 Script executed:
Length of output: 27
🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 27
Length of output: 501
🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 4819
🏁 Script executed:
Length of output: 72
Length of output: 168
🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 295
🏁 Script executed:
Length of output: 78
🏁 Script executed:
Length of output: 86
Fix critical quoting syntax error in
action_during_migThe
action_during_migvalue on line 49 will cause a SyntaxError when evaluated. The string is enclosed in single quotes but contains unescaped single quotes in'%s'andparams.get('migrate_main_vm'), prematurely terminating the outer string literal. Wheneval(action_during_mig)is called inprovider/migration/migration_base.py:55, this will fail at runtime.Fix by escaping the inner single quotes:
Alternatively, switch to double quotes for the outer string to allow the inner single quotes to remain unescaped.
📝 Committable suggestion
🤖 Prompt for AI Agents