Skip to content

Commit

Permalink
Merge pull request #5012 from smitterl/rng_audit
Browse files Browse the repository at this point in the history
libvirt_rng: add checkpoint for audit log
  • Loading branch information
chunfuwen authored Jul 10, 2023
2 parents e7313e1 + 17f46a2 commit ea66d0b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions libvirt/tests/cfg/libvirt_rng.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
rng_random_source = "no"
- device_assign:
rng_attach_device = "no"
test_audit = "yes"
variants:
- backend_builtin:
backend_model = "builtin"
Expand Down
16 changes: 16 additions & 0 deletions libvirt/tests/src/libvirt_rng.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,21 @@ def add_udp_random_server():
finally:
sock.close()

def rotate_audit_log():
"""
Rotates the audit log so that the current log only contains
entries that were written during the test execution
"""
process.run("systemctl kill --signal SIGUSR1 auditd")

start_error = "yes" == params.get("start_error", "no")
status_error = "yes" == params.get("status_error", "no")

test_host = "yes" == params.get("test_host", "no")
test_guest = "yes" == params.get("test_guest", "no")
test_audit = "yes" == params.get("test_audit", "no")
audit_log_file = params.get("audit_log_file", "/var/log/audit/audit.log")
expected_audit_message = params.get("expected_audit_message", "VIRT_RESOURCE")
set_virtio_current = "yes" == params.get("set_virtio_current", "no")
test_guest_dump = "yes" == params.get("test_guest_dump", "no")
test_qemu_cmd = "yes" == params.get("test_qemu_cmd", "no")
Expand Down Expand Up @@ -548,6 +558,9 @@ def add_udp_random_server():
bgjob = None
bgjob2 = None

if test_audit:
rotate_audit_log()

# Prepare xml, make sure no extra rng dev.
vmxml = vmxml_backup.copy()
vmxml.remove_all_device_by_type('rng')
Expand Down Expand Up @@ -657,6 +670,9 @@ def add_udp_random_server():
check_qemu_cmd(params)
if test_host:
check_host()
if test_audit:
libvirt.check_logfile(expected_audit_message,
audit_log_file)
session = vm.wait_for_login()
if test_guest:
check_guest(session, set_virtio_current=set_virtio_current)
Expand Down

0 comments on commit ea66d0b

Please sign in to comment.