From 4a29672fbe9dd30c40f1d77ceae58d90bb0203dd Mon Sep 17 00:00:00 2001 From: Dan Zheng Date: Tue, 17 Dec 2024 14:26:16 +0800 Subject: [PATCH] migrate_with_virtual_devices: fix rng check method As there might be other built-in rng devices, we only need to check if attached virtio rng is in rng_available. Signed-off-by: Dan Zheng --- .../src/migration/migrate_with_virtual_devices.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libvirt/tests/src/migration/migrate_with_virtual_devices.py b/libvirt/tests/src/migration/migrate_with_virtual_devices.py index e85ba30e06..b7629a542e 100644 --- a/libvirt/tests/src/migration/migrate_with_virtual_devices.py +++ b/libvirt/tests/src/migration/migrate_with_virtual_devices.py @@ -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: if rng_present: return else: raise DeviceNotRemovedError("rng") else: - if not rng_present and "No such device" in output: + if not rng_present: return elif rng_present: raise DeviceNotFoundError("rng")