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

virt.virtnet : update vm.virtnet when guest reboot #1180

Merged
merged 1 commit into from
Dec 4, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions virttest/env_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@ def preprocess_vm(test, params, env, name):
vm.remove()

start_vm = False
update_virtnet = False

if params.get("restart_vm") == "yes":
if vm.is_alive():
vm.destroy(gracefully=True, free_mac_addresses=False)
update_virtnet = True
start_vm = True
elif params.get("migration_mode"):
start_vm = True
Expand All @@ -114,6 +116,7 @@ def preprocess_vm(test, params, env, name):
params=params,
basedir=test.bindir):
start_vm = True
update_virtnet = True

if start_vm:
if vm_type == "libvirt" and params.get("type") != "unattended_install":
Expand All @@ -123,6 +126,9 @@ def preprocess_vm(test, params, env, name):
vm.params = params
vm.start()
else:
if update_virtnet:
vm.update_vm_id()
vm.virtnet = utils_net.VirtNet(params, name, vm.instance)
# Start the VM (or restart it if it's already up)
if params.get("reuse_previous_config", "no") == "no":
vm.create(name, params, test.bindir,
Expand Down
7 changes: 7 additions & 0 deletions virttest/virt_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,13 @@ def _generate_unique_id(self):
if not glob.glob("/tmp/*%s" % self.instance):
break

def update_vm_id(self):
"""
Update vm identifier, we need do that when force reboot vm, since vm
virnet params may be changed.
"""
self._generate_unique_id()

@staticmethod
def lookup_vm_class(vm_type, target):
if vm_type == 'qemu':
Expand Down