Skip to content

Commit ddc3703

Browse files
authored
Merge pull request #4246 from xiagao/bz1863-md5sum
virtio_fs: wait a moment for the shared volume active
2 parents 91f3cd2 + 8e264c9 commit ddc3703

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

provider/virtio_fs_utils.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import logging
22
import os
3+
import re
4+
import time
35

46
from avocado.utils import process
57
from virttest import data_dir, error_context, utils_misc
@@ -67,7 +69,23 @@ def basic_io_test(test, params, session):
6769
error_context.context(
6870
"Creating file under %s inside guest." % fs_dest, LOG_JOB.info
6971
)
70-
session.cmd(cmd_dd % guest_file, io_timeout)
72+
# for windows, after virtiofs service start up, should wait several seconds
73+
# to make the volume active.
74+
if windows:
75+
pattern = r"The system cannot find the file specified"
76+
end_time = time.time() + io_timeout
77+
while time.time() < end_time:
78+
status, output = session.cmd_status_output(cmd_dd % guest_file)
79+
if re.findall(pattern, output, re.M | re.I):
80+
time.sleep(2)
81+
continue
82+
if status != 0:
83+
test.fail("dd command failed on virtiofs.")
84+
break
85+
else:
86+
test.error(f"Volume is not ready for io within {io_timeout}.")
87+
else:
88+
session.cmd(cmd_dd % guest_file, io_timeout)
7189

7290
if windows:
7391
guest_file_win = guest_file.replace("/", "\\")

qemu/tests/virtio_fs_share_data.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,27 @@ def start_multifs_instance():
447447
"Creating file under %s inside " "guest." % fs_dest,
448448
test.log.info,
449449
)
450-
session.cmd(cmd_dd % guest_file, io_timeout)
450+
# for windows, after virtiofs service start up, should wait
451+
# for the volume active.
452+
if os_type == "windows":
453+
pattern = r"The system cannot find the file specified"
454+
end_time = time.time() + io_timeout
455+
while time.time() < end_time:
456+
status, output = session.cmd_status_output(
457+
cmd_dd % guest_file
458+
)
459+
if re.findall(pattern, output, re.M | re.I):
460+
time.sleep(2)
461+
continue
462+
if status != 0:
463+
test.fail("dd command failed on virtiofs.")
464+
break
465+
else:
466+
test.error(
467+
f"Volume is not ready for io within {io_timeout}."
468+
)
469+
else:
470+
session.cmd(cmd_dd % guest_file, io_timeout)
451471

452472
if os_type == "linux":
453473
cmd_md5_vm = cmd_md5 % guest_file

0 commit comments

Comments
 (0)