Skip to content

Commit

Permalink
Snapshot: fix console failure when using the console for the second
Browse files Browse the repository at this point in the history
time

Fix "No console available" issues in some snapshot scripts:
1) delete_external_snap_with_references.py: this script starts the guest
   twice. So I added an if statement to check vm.is_alive in the second
time.
2) Another two scripts, to make sure the second console is same and
   pure. I added vm.cleanup_serial_console and vm.create_serial_console
before the second time.

Signed-off-by: Meina Li <[email protected]>
  • Loading branch information
meinaLi committed Nov 21, 2024
1 parent 54364e8 commit f10d5e4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ def run_test_del_parent_snap():
Delete the parent snapshot with multiple children.
"""
test.log.info("TEST_STEP:Delete the parent snapshot with multi-child.")
virsh.start(vm_name)
vm.wait_for_login().close()
if not vm.is_alive():
virsh.start(vm_name)
vm.wait_for_login().close()
del_res = virsh.snapshot_delete(vm.name, snap_names[0], debug=True)
libvirt.check_exit_status(del_res, error_msg)

Expand Down
8 changes: 5 additions & 3 deletions libvirt/tests/src/snapshot/revert_disk_external_snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def revert_snap_and_check_files(params, vm, test, snap_name, expected_files):
"""
virsh.snapshot_revert(vm.name, snap_name, **virsh_dargs)

session = vm.wait_for_login()
vm.cleanup_serial_console()
vm.create_serial_console()
session = vm.wait_for_serial_login()
for file in expected_files:
output = session.cmd('ls %s' % file)
if file not in output:
Expand All @@ -49,8 +51,8 @@ def setup_test():
Prepare file and snapshot.
"""
test.log.info("TEST_SETUP: Create files and snaps in running guest.")
virsh.start(vm_name)
session = vm.wait_for_login()
vm.start()
session = vm.wait_for_serial_login()
mem_file = " "
for index, sname in enumerate(snap_names):
session.cmd("touch %s" % file_list[index])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ def check_file_exist(test, vm, params, revert_snap):

if not vm.is_alive():
virsh.start(vm_name)
session = vm.wait_for_login()
vm.cleanup_serial_console()
vm.create_serial_console()
session = vm.wait_for_serial_login()

if revert_snap == "1":
file_list = eval(params.get("file_list"))[0:1]
Expand Down Expand Up @@ -186,8 +188,8 @@ def run_test():
hotplug disk/hotplug vcpus/blkiotune
"""
test.log.info("TEST_STEP1:Prepare a running guest and create file.")
virsh.start(vm_name)
session = vm.wait_for_login()
vm.start()
session = vm.wait_for_serial_login()
create_file(vm, file_list[0], session)

test.log.info("TEST_STEP2: Create snapshot.")
Expand Down

0 comments on commit f10d5e4

Please sign in to comment.