Skip to content

Commit c5befba

Browse files
committed
Merge pull request autotest#662 from rbian/libvirt_hooks
libvirt_hooks: Modify interface type before test.
2 parents 03939d6 + 0b03e75 commit c5befba

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

libvirt/tests/cfg/libvirt_hooks.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
hook_script = '#! /bin/bash;echo "$0" "$@" >> %s;exit 1;'
4141
- network_t:
4242
test_network = "yes"
43+
net_name = "default"
4344
hook_file = "/etc/libvirt/hooks/network"
4445
hook_log = "/tmp/network.log"
4546
- error_test:

libvirt/tests/src/libvirt_hooks.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def start_stop_hook():
7373
prepare_hook_file(hook_script %
7474
(vm_name, hook_log))
7575
vm.start()
76+
vm.wait_for_login().close()
7677
try:
7778
hook_str = hook_para + " prepare begin -"
7879
assert check_hooks(hook_str)
@@ -255,11 +256,26 @@ def attach_hook():
255256
raise error.TestFail("Failed to check"
256257
" attach hooks")
257258

259+
def edit_iface(net_name):
260+
"""
261+
Edit interface options for vm.
262+
"""
263+
vmxml = vm_xml.VMXML.new_from_dumpxml(vm.name)
264+
iface_xml = vmxml.get_devices(device_type="interface")[0]
265+
vmxml.del_device(iface_xml)
266+
iface_xml.type_name = "network"
267+
iface_xml.source = {"network": net_name}
268+
del iface_xml.address
269+
vmxml.add_device(iface_xml)
270+
vmxml.sync()
271+
258272
def network_hook():
259273
"""
260274
Check network hooks.
261275
"""
262-
net_name = "default"
276+
# Set interface to use default network
277+
net_name = params.get("net_name", "default")
278+
edit_iface(net_name)
263279
prepare_hook_file(hook_script %
264280
(net_name, hook_log))
265281
try:

0 commit comments

Comments
 (0)