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

tpm_device.py: clean audit before vm start #5914

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion libvirt/tests/cfg/virtual_device/tpm_device.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
swtpm_path = '/usr/bin/swtpm'
variants:
- start_vm:
audit_cmd = ausearch -ts recent -m VIRT_RESOURCE| grep 'tpm-external'
audit_cmd = "cat /var/log/audit/audit.log| grep 'tpm-external'"
ausearch_check = 'reason=start.*device="/var/tmp/guest-swtpm.sock".*res=success'
- suspend_resume:
vm_operate = 'resume'
Expand Down
13 changes: 9 additions & 4 deletions libvirt/tests/src/virtual_device/tpm_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,12 @@ def check_swtpmpidfile(vm_name, test_stage):
return
if tpm_model and backend_version != 'default':
expect_fail = False
if ausearch_check:
cmd = "truncate -s 0 /var/log/audit/audit.log*"
process.run(cmd, shell=True)
ausearch_ret = process.run(audit_cmd, verbose=True, shell=True, ignore_status=True)
if not ausearch_ret:
test.fail('audit log is not cleaned well.')
try:
vm.start()
except VMStartError as detail:
Expand All @@ -838,10 +844,6 @@ def check_swtpmpidfile(vm_name, test_stage):
return
else:
test.fail(detail)
if ausearch_check:
process.run("echo > /var/log/audit/audit.log", ignore_status=True)
ausearch_result = process.run(audit_cmd, verbose=True, shell=True)
libvirt.check_result(ausearch_result, expected_match=ausearch_check)
if undefine_flag:
time.sleep(5)
vm.destroy()
Expand Down Expand Up @@ -946,6 +948,9 @@ def check_swtpmpidfile(vm_name, test_stage):
return
domid = vm.get_id()
check_qemu_cmd_line(vm, vm_name, domid)
if ausearch_check:
ausearch_result = process.run(audit_cmd, verbose=True, shell=True)
libvirt.check_result(ausearch_result, expected_match=ausearch_check)
if backend_type == "passthrough":
if tpm_real_v == "1.2" and tpm_model == "tpm-crb":
expect_fail = True
Expand Down
Loading