Skip to content
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

Clean the env before vm clone #6089

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yalzhang
Copy link
Contributor

There could be scenario that existing VMs with the same name which block the following operations. Remove these VMs to clean the env.

@yalzhang
Copy link
Contributor Author

yalzhang commented Dec 24, 2024

before the test, there could be error:
rhel.managedsave.libvirt_guests.positive_test.no_parallel_shutdown.shutdown_on_shutdown.none_on_boot.with_transient_vm.persistent_only_true (from avocado-vt)
Error message:
Command 'virt-clone --original 'avocado-vt-vm1' --name 'avocado-vt-vm2' --auto-clone' failed. stdout: b'' stderr: b"ERROR Disk /var/lib/avocado/data/avocado-vt/images/jeos-27-x86_64-clone.qcow2 is already in use by other guests ['avocado-vt-vm1_0']. (Use --check path_in_use=off or --check all=off to override)\n" additional_info: None

after the fix, run the same with with existing VM 'avocado-vt-vm2'

 Id   Name             State
---------------------------------
 -    avocado-vt-vm1   shut off
 -    avocado-vt-vm2   shut off
(1/1) type_specific.io-github-autotest-libvirt.managedsave.libvirt_guests.positive_test.parallel_shutdown.shutdown_on_shutdown.ignore_on_boot.without_transient_vm: PASS (167.62 s)```

@yalzhang
Copy link
Contributor Author

@nanli1 Hi Please help to review, Thank you!

all_vm_list = virsh.dom_list('--name --all').stdout.strip().splitlines()
logging.debug("All vm on the host: %s", all_vm_list)
for vm_i in all_vm_list:
if vm_i.startswith("avocado-vt-vm") and vm_i != "avocado-vt-vm1":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use guest_name = ("%s" % main_vm_name[:-1])+("%s" % str(i+2)) to as cloned name , right? if so, could we if vm_i.startswith(main_vm_name) and vm_i != "main_vm_name": here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated and tested pass

@yalzhang yalzhang force-pushed the fix_managedsave_addtional_vms branch 2 times, most recently from 0365ea1 to b4891f4 Compare December 26, 2024 05:23
There could be scenario that existing VMs with the same name which block
the following operations. Remove these VMs to clean the env.

Signed-off-by: Yalan Zhang <[email protected]>
@yalzhang yalzhang force-pushed the fix_managedsave_addtional_vms branch from b4891f4 to e95578b Compare December 26, 2024 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants