-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5634 from cliping/VIRT-37948
libvirtd: Add case to test qemu monitor socket
- Loading branch information
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
libvirt/tests/cfg/daemon/qemu_monitor_socket_creation_delay.cfg
This file contains 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,7 @@ | ||
- daemon.qemu_monitor_socket_creation_delay: | ||
type = qemu_monitor_socket_creation_delay | ||
start_vm = no | ||
check_image = no | ||
take_regular_screendumps = no | ||
qemu_wrapper_path = "../../deps/qemu_wrapper.py" | ||
tmp_qemu_wrapper_path = "/tmp/qemu_wrapper.py" |
This file contains 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,12 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
import sys | ||
import time | ||
|
||
TIMEOUT = 5 | ||
QEMU_PATH = "/usr/libexec/qemu-kvm" | ||
|
||
time.sleep(TIMEOUT) | ||
sys.argv[0] = QEMU_PATH | ||
os.execv(QEMU_PATH, sys.argv) |
43 changes: 43 additions & 0 deletions
43
libvirt/tests/src/daemon/qemu_monitor_socket_creation_delay.py
This file contains 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,43 @@ | ||
import os | ||
import shutil | ||
|
||
from avocado.utils import process | ||
|
||
from virttest import virt_vm | ||
|
||
from virttest.libvirt_xml import vm_xml | ||
from virttest.utils_libvirt import libvirt_vmxml | ||
|
||
|
||
def run(test, params, env): | ||
""" | ||
Write a wrapper for qemu to wait several seconds (>3) before starts. | ||
""" | ||
vm_name = params.get('main_vm') | ||
vm = env.get_vm(vm_name) | ||
emulator_dict = eval(params.get("emulator_dict")) | ||
qemu_wrapper_path = params.get("qemu_wrapper_path") | ||
tmp_qemu_wrapper_path = params.get("tmp_qemu_wrapper_path") | ||
vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name) | ||
xml_backup = vmxml.copy() | ||
|
||
try: | ||
qemu_wrapper_path = os.path.join(os.path.dirname(__file__), qemu_wrapper_path) | ||
shutil.copyfile(qemu_wrapper_path, tmp_qemu_wrapper_path) | ||
os.chown(tmp_qemu_wrapper_path, 107, 107) | ||
os.chmod(tmp_qemu_wrapper_path, 0o755) | ||
process.run("chcon system_u:object_r:qemu_exec_t:s0 %s" % tmp_qemu_wrapper_path, shell=True) | ||
|
||
emulator_dict = {"path": "%s" % tmp_qemu_wrapper_path} | ||
libvirt_vmxml.modify_vm_device(vmxml, "emulator", emulator_dict) | ||
vm.start() | ||
except virt_vm.VMStartError as e: | ||
test.fail("Fail to Start vm with qemu monitor socket creation delay: %s" % e) | ||
|
||
finally: | ||
if vm.is_alive(): | ||
vm.destroy(gracefully=False) | ||
if os.path.exists(tmp_qemu_wrapper_path): | ||
os.remove(tmp_qemu_wrapper_path) | ||
xml_backup.sync() |