Skip to content

Commit

Permalink
virtio_fs: wait a moment for the shared volume active
Browse files Browse the repository at this point in the history
For windows guest, need to wait a moment for the volume
active.

Signed-off-by: Xiaoling Gao <xiagao@redhat.com>
  • Loading branch information
xiagao committed Jan 7, 2025
1 parent b2108ff commit b1a3c7f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
17 changes: 16 additions & 1 deletion provider/virtio_fs_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import logging
import os
import re
import time

from avocado.utils import process
from virttest import data_dir, error_context, utils_misc
Expand Down Expand Up @@ -67,7 +69,20 @@ def basic_io_test(test, params, session):
error_context.context(
"Creating file under %s inside guest." % fs_dest, LOG_JOB.info
)
session.cmd(cmd_dd % guest_file, io_timeout)
# for windows, after virtiofs service start up, should wait several seconds
# to make the volume active.
if windows:
end_time = time.time() + io_timeout
while time.time() < end_time:
output = session.cmd_output(cmd_dd % guest_file)
pattern = r"The system cannot find the file specified"
if not re.findall(pattern, output, re.M | re.I):
break
else:
test.log.info("Volume is not ready for io.")
time.sleep(2)
else:
session.cmd(cmd_dd % guest_file, io_timeout)

if windows:
guest_file_win = guest_file.replace("/", "\\")
Expand Down
16 changes: 15 additions & 1 deletion qemu/tests/virtio_fs_share_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,21 @@ def start_multifs_instance():
"Creating file under %s inside " "guest." % fs_dest,
test.log.info,
)
session.cmd(cmd_dd % guest_file, io_timeout)

# for windows, after virtiofs service start up, should wait
# for the volume active.
if os_type == "windows":
end_time = time.time() + io_timeout
while time.time() < end_time:
output = session.cmd_output(cmd_dd % guest_file)
pattern = r"The system cannot find the file specified"
if not re.findall(pattern, output, re.M | re.I):
break
else:
test.log.info("Volume is not ready for io.")
time.sleep(2)
else:
session.cmd(cmd_dd % guest_file, io_timeout)

if os_type == "linux":
cmd_md5_vm = cmd_md5 % guest_file
Expand Down

0 comments on commit b1a3c7f

Please sign in to comment.