From e57f122915709f856c99cbae2e034f7c7439d637 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 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 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..1beb4d417d 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: # 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")