Skip to content

Commit

Permalink
migrate_with_virtual_devices: fix rng check method
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Zheng <[email protected]>
  • Loading branch information
dzhengfy committed Dec 17, 2024
1 parent 1aa9ac2 commit eb843da
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions libvirt/tests/src/migration/migrate_with_virtual_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,21 +552,21 @@ def check_rng_in_vm(vm, backend_type, rng_present):
"""

logging.debug("Check rng device in vm")
check_cmd = "dd if=/dev/hwrng of=/dev/null count=2 bs=2"
check_cmd = "cat /sys/devices/virtual/misc/hw_random/rng_available"
timeout = 10

try:
status, output = vm.session.cmd_status_output(check_cmd, timeout)
logging.debug("cmd exit status: %s, cmd output: %s",
logging.debug("cmd exit status: %s, current rng available: %s",
status, output)

if status == 0:
status = True if output.count("virtio-rng") else False
if status is True: # found
if rng_present:
return
else:
raise DeviceNotRemovedError("rng")
else:
if not rng_present and "No such device" in output:
else: # not found
if not rng_present:
return
elif rng_present:
raise DeviceNotFoundError("rng")
Expand Down

0 comments on commit eb843da

Please sign in to comment.