WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 527e829

Browse files
committed
virtio_win_installer: add pretest for installer
In the situation of only having installer related files, try to create a standard virtio-win iso and testing the basic install/uninstall/update function, qga and drivers version check. Signed-off-by: Xiaoling Gao <[email protected]>
1 parent e91fe7f commit 527e829

File tree

7 files changed

+492
-29
lines changed

7 files changed

+492
-29
lines changed

generic/tests/netperf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,9 @@ def mtu_set(mtu):
173173
session = vm.wait_for_login(nic_index=2, timeout=login_timeout)
174174
for driver_name in driver_name.split():
175175
inf_path = win_driver_utils.get_driver_inf_path(
176-
session, test, media_type, driver_name
176+
session, test, media_type, driver_name, params
177177
)
178+
178179
if driver_name == "netkvm":
179180
device_name = params.get("device_name")
180181
device_hwid = params.get("device_hwid")

provider/virtio_fs_utils.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,19 @@ def get_viofs_exe_path(test, params, session):
307307
exe_middle_path = (
308308
"{name}\\{arch}" if media_type == "iso" else "{arch}\\{name}"
309309
).format(name=guest_name, arch=guest_arch)
310-
exe_file_name = "virtiofs.exe"
311-
exe_find_cmd = 'dir /b /s %s\\%s | findstr "\\%s\\\\"'
312-
exe_find_cmd %= (viowin_ltr, exe_file_name, exe_middle_path)
313-
exe_path = session.cmd(exe_find_cmd).strip()
310+
311+
exe_file_name = params.get("exe_file_name", "virtiofs.exe")
312+
formal_exe_find_cmd = (
313+
'dir /b /s VIOWIN_LTR\\EXE_FILE_NAME | findstr "\\EXE_MID_PATH\\\\"'
314+
)
315+
exe_find_cmd = params.get("exe_find_cmd", formal_exe_find_cmd)
316+
317+
exe_find_cmd_new = exe_find_cmd.replace(
318+
'VIOWIN_LTR', viowin_ltr).replace(
319+
'EXE_FILE_NAME', exe_file_name).replace(
320+
'EXE_MID_PATH', exe_middle_path)
321+
322+
exe_path = session.cmd(exe_find_cmd_new).strip()
314323
test.log.info("Found exe file '%s'", exe_path)
315324
return exe_path
316325

provider/win_driver_installer_test.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"vioinput",
2828
"fwcfg",
2929
"viomem",
30+
"viosock",
3031
]
3132

3233
device_hwid_list = [
@@ -41,6 +42,7 @@
4142
'"PCI\\VEN_1AF4&DEV_1052"',
4243
'"ACPI\\VEN_QEMU&DEV_0002"',
4344
r'"PCI\VEN_1AF4&DEV_1002" "PCI\VEN_1AF4&DEV_1058"',
45+
r'"PCI\VEN_1AF4&DEV_1053" "PCI\VEN_1AF4&DEV_1012"',
4446
]
4547

4648
device_name_list = [
@@ -55,6 +57,7 @@
5557
"VirtIO Input Driver",
5658
"QEMU FwCfg Device",
5759
"VirtIO Viomem Driver",
60+
"VirtIO Socket Driver",
5861
]
5962

6063

@@ -183,7 +186,7 @@ def driver_check(session, test, params):
183186
continue
184187
error_context.context("%s Driver Check" % driver_name, LOG_JOB.info)
185188
inf_path = win_driver_utils.get_driver_inf_path(
186-
session, test, media_type, driver_name
189+
session, test, media_type, driver_name, params
187190
)
188191
expected_ver = session.cmd(
189192
"type %s | findstr /i /r DriverVer.*=" % inf_path, timeout=360
@@ -221,6 +224,16 @@ def check_gagent_version(session, test, gagent_pkg_info_cmd, expected_gagent_ver
221224
"""
222225
error_context.context("Check if gagent version is correct.", LOG_JOB.info)
223226
actual_gagent_version = session.cmd_output(gagent_pkg_info_cmd).split()[-2]
227+
228+
exe_ver_cmd = r'"c:\program files\qemu-ga\qemu-ga.exe" --version'
229+
gagent_exe_version = session.cmd_output(exe_ver_cmd)
230+
231+
test.log.info("actual_gagent_version version is %s,"
232+
"qga vertion by installer is %s,"
233+
"gagent exe version is %s" % (actual_gagent_version,
234+
expected_gagent_version,
235+
gagent_exe_version)
236+
)
224237
if actual_gagent_version != expected_gagent_version:
225238
test.fail(
226239
"gagent version is not right, expected is %s but got %s"

provider/win_driver_utils.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ def uninstall_driver(session, test, devcon_path, driver_name, device_name, devic
9696
inf_list_all = _pnpdrv_info(session, device_name, ["InfName"])
9797
inf_list = list(set(inf_list_all))
9898

99+
# Check if any drivers were found
100+
if not inf_list:
101+
LOG_JOB.warning("No driver found for device '%s'.
102+
Driver may not installed.", device_name)
103+
99104
# pnputil flags available starting in Windows 10,
100105
# version 1607, build 14393 later
101106
build_ver = system.version(session).split(".")[2]
@@ -120,14 +125,15 @@ def uninstall_driver(session, test, devcon_path, driver_name, device_name, devic
120125
)
121126

122127

123-
def get_driver_inf_path(session, test, media_type, driver_name):
128+
def get_driver_inf_path(session, test, media_type, driver_name, params):
124129
"""
125130
Get driver inf path from virtio win iso,such as E:\viofs\2k19\amd64.
126131
127132
:param session: The guest session object.
128133
:param test: kvm test object.
129134
:param media_type: media type.
130135
:param driver_name: driver name.
136+
:param params: the dict used for parameters
131137
"""
132138
try:
133139
get_drive_letter = getattr(virtio_win, "drive_letter_%s" % media_type)
@@ -144,20 +150,27 @@ def get_driver_inf_path(session, test, media_type, driver_name):
144150
guest_arch = get_arch_dirname(session)
145151
if not guest_arch:
146152
test.error("Could not get architecture dirname of the vm")
147-
153+
# for formal virtio-win iso
148154
inf_middle_path = (
149155
"{name}\\{arch}" if media_type == "iso" else "{arch}\\{name}"
150156
).format(name=guest_name, arch=guest_arch)
151-
inf_find_cmd = 'dir /b /s %s\\%s.inf | findstr "\\%s\\\\"'
152-
inf_find_cmd %= (viowin_ltr, driver_name, inf_middle_path)
153-
inf_path = session.cmd(inf_find_cmd, timeout=OPERATION_TIMEOUT).strip()
157+
formal_inf_find_cmd = 'dir /b /s VIOWIN_LTR\\DRIVER_NAME.inf |'
158+
formal_inf_find_cmd += ' findstr "\\INF_MID_PATH\\\\'
159+
inf_find_cmd = params.get("inf_find_cmd", formal_inf_find_cmd)
160+
161+
inf_find_cmd_new = inf_find_cmd.replace(
162+
'VIOWIN_LTR', viowin_ltr).replace(
163+
'DRIVER_NAME', driver_name).replace(
164+
'INF_MID_PATH', inf_middle_path)
165+
166+
inf_path = session.cmd(inf_find_cmd_new, timeout=OPERATION_TIMEOUT).strip()
154167
LOG_JOB.info("Found inf file '%s'", inf_path)
155168
return inf_path
156169

157170

158171
@error_context.context_aware
159172
def install_driver_by_virtio_media(
160-
session, test, devcon_path, media_type, driver_name, device_hwid
173+
session, test, devcon_path, media_type, driver_name, device_hwid, params
161174
):
162175
"""
163176
Install driver by virtio media.
@@ -168,6 +181,7 @@ def install_driver_by_virtio_media(
168181
:param media_type: media type.
169182
:param driver_name: driver name.
170183
:param device_hwid: device hardware id.
184+
:param params: the dict used for parameters
171185
"""
172186
devcon_path = utils_misc.set_winutils_letter(session, devcon_path)
173187
status, output = session.cmd_status_output(
@@ -181,7 +195,8 @@ def install_driver_by_virtio_media(
181195
output = session.cmd_output("%s find %s" % (devcon_path, hwid))
182196
if re.search("No matching devices found", output, re.I):
183197
continue
184-
inf_path = get_driver_inf_path(session, test, media_type, driver_name)
198+
inf_path = get_driver_inf_path(session, test, media_type,
199+
driver_name, params)
185200
inst_cmd = "%s updateni %s %s" % (devcon_path, inf_path, hwid)
186201
status, output = session.cmd_status_output(inst_cmd, INSTALL_TIMEOUT)
187202
# acceptable status: OK(0), REBOOT(1)
@@ -232,15 +247,6 @@ def run_installer(vm, session, test, params, run_installer_cmd):
232247
:param run_installer_cmd: install/uninstall/repair cmd.
233248
:return session: a new session after restart of installer
234249
"""
235-
cdrom_virtio = params["cdrom_virtio"]
236-
installer_restart_version = params.get(
237-
"installer_restart_version", "[1.9.37.0, 1.9.40.0]"
238-
)
239-
cdrom_virtio_path = os.path.basename(
240-
utils_misc.get_path(data_dir.get_data_dir(), cdrom_virtio)
241-
)
242-
match = re.search(r"virtio-win-(\d+\.\d+(?:\.\d+)?-\d+)", cdrom_virtio_path)
243-
cdrom_virtio_version = re.sub("-", ".", match.group(1))
244250
# run installer cmd
245251
run_installer_cmd = utils_misc.set_winutils_letter(session, run_installer_cmd)
246252
session.cmd(run_installer_cmd)
@@ -249,18 +255,14 @@ def run_installer(vm, session, test, params, run_installer_cmd):
249255
lambda: not autoit_installer_check(params, session), 240, 2, 2
250256
):
251257
test.fail("Autoit exe stop there for 240s, please have a check.")
252-
restart_con_ver = cdrom_virtio_version in VersionInterval(installer_restart_version)
253258
restart_con_repair = "repair" in run_installer_cmd
254-
if restart_con_ver or restart_con_repair:
255-
# Wait for vm re-start by installer itself
259+
if restart_con_repair:
260+
# Wait for vm re-start by installer itself, only repair has self-restart
256261
if not utils_misc.wait_for(lambda: not session.is_responsive(), 120, 5, 5):
257262
test.fail(
258263
"The previous session still exists,seems that the vm doesn't restart."
259264
)
260265
session = vm.wait_for_login(timeout=360)
261-
# for the early virtio-win instller, rebooting is needed.
262-
if cdrom_virtio_version in VersionInterval("(,1.9.37.0)"):
263-
session = vm.reboot(session)
264266
return session
265267

266268

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
- win_virtio_driver_installer_pretest:
2+
type = win_virtio_driver_installer_pretest
3+
only Windows
4+
virtio_win_media_type = iso
5+
cdroms += " virtio"
6+
clone_master = yes
7+
master_images_clone = image1
8+
remove_image_image1 = yes
9+
cd_format_fixed = ide
10+
drive_format_image1 = ide
11+
q35:
12+
cd_format_fixed = ahci
13+
drive_format_image1 = ahci
14+
vio_driver_chk_cmd = 'driverquery /si | find /i "%s"'
15+
chk_timeout = 240
16+
install_script_path = "WIN_UTILS:\install.au3"
17+
repair_script_path = "WIN_UTILS:\repair.au3"
18+
uninstall_script_path = "WIN_UTILS:\uninstall.au3"
19+
run_install_cmd = 'WIN_UTILS:\AutoIt3_%PROCESSOR_ARCHITECTURE%.exe C:\install.au3'
20+
run_repair_cmd = 'WIN_UTILS:\AutoIt3_%PROCESSOR_ARCHITECTURE%.exe C:\repair.au3'
21+
run_uninstall_cmd = 'WIN_UTILS:\AutoIt3_%PROCESSOR_ARCHITECTURE%.exe C:\uninstall.au3'
22+
signed_check_cmd = 'wmic product where name="Virtio-win-driver-installer" | findstr "Red Hat, Inc."'
23+
monitor_type = qmp
24+
monitors = qmp1
25+
mem_stat_check_list = 'stat-free-memory'
26+
check_mem_diff = 300
27+
guest_compare_threshold = 300
28+
guest_mem_ratio = 0.025
29+
devcon_dirname = "win7_"
30+
i386:
31+
devcon_dirname += "x86"
32+
qemu_ga_pkg = qemu-ga-i386.msi
33+
msi_name = virtio-win-gt-x86.msi
34+
uninstall_msi_script = "uninstall_via_msi_x86.au3"
35+
x86_64:
36+
devcon_dirname += "amd64"
37+
qemu_ga_pkg = qemu-ga-x86_64.msi
38+
msi_name = virtio-win-gt-x64.msi
39+
uninstall_msi_script = "uninstall_via_msi_x64.au3"
40+
uninstall_msi_script_path = "WIN_UTILS:\${uninstall_msi_script}"
41+
devcon_path = "WIN_UTILS:\devcon\${devcon_dirname}\devcon.exe"
42+
gagent_install_cmd = "start /wait %s /quiet"
43+
gagent_pkg_info_cmd = 'wmic product where name="Qemu guest agent"'
44+
gagent_uninstall_cmd = "wmic product where name='Qemu guest agent' call uninstall"
45+
threshold = 0.025
46+
nic_model_nic1 = rtl8139
47+
q35:
48+
nic_model_nic1 = e1000e
49+
# install winfsp tool
50+
i386, i686:
51+
install_winfsp_path = 'C:\Program Files'
52+
x86_64:
53+
install_winfsp_path = 'C:\Program Files (x86)'
54+
nics += " nic2"
55+
nic_model_nic2 = virtio
56+
no_virtio_rng:
57+
virtio_rngs += " rng0"
58+
backend_rng0 = rng-builtin
59+
backend_type = builtin
60+
images += " stg0 stg1"
61+
image_name_stg0 = "images/stg0"
62+
image_name_stg1 = "images/stg1"
63+
image_size_stg0 = 5G
64+
image_size_stg1 = 10G
65+
drive_format_stg0 = virtio
66+
drive_format_stg1 = scsi-hd
67+
remove_image_stg0 = yes
68+
remove_image_stg1 = yes
69+
force_create_image_stg0 = yes
70+
force_create_image_stg1 = yes
71+
serials += " vs"
72+
serial_type_vs = virtserialport
73+
balloon = balloon0
74+
balloon_dev_devid = balloon0
75+
balloon_dev_add_bus = yes
76+
install_balloon_service = "%s:\Balloon\blnsvr.exe -i"
77+
uninstall_balloon_service = "%s:\Balloon\blnsvr.exe -u"
78+
status_balloon_service = "%s:\Balloon\blnsvr.exe status"
79+
run_balloon_service = "%s:\Balloon\blnsvr.exe -r"
80+
stop_balloon_service = "%s:\Balloon\blnsvr.exe -s"
81+
inputs = input1
82+
input_dev_bus_type_input1 = virtio
83+
input_dev_type_input1 = mouse
84+
vmcoreinfo = yes
85+
filesystems = fs
86+
fs_driver = virtio-fs
87+
fs_source_type = mount
88+
fs_source_dir = virtio_fs_test/
89+
force_create_fs_source = yes
90+
remove_fs_source = yes
91+
fs_target = 'myfs'
92+
fs_driver_props = {"queue-size": 1024}
93+
Win10.i386:
94+
mem = 4096
95+
mem_devs = mem1
96+
backend_mem_mem1 = memory-backend-file
97+
mem-path_mem1 = /dev/shm
98+
size_mem1 = ${mem}M
99+
use_mem_mem1 = no
100+
share_mem = yes
101+
guest_numa_nodes = shm0
102+
numa_memdev_shm0 = mem-mem1
103+
numa_nodeid_shm0 = 0
104+
fs_binary_extra_options = " -o cache=auto"
105+
exe_file_name = "virtiofs.exe"
106+
exe_find_cmd = 'dir /b /s VIOWIN_LTR\EXE_FILE_NAME'
107+
inf_find_cmd = 'dir /b /s VIOWIN_LTR\DRIVER_NAME.inf'
108+
cdrom_virtio = '/home/virtio-win-pretest.iso'
109+
vsocks = vhost_vsock0
110+
# add viomem
111+
x86_64:
112+
# virtio-mem is not supported on 32-bit systems
113+
# and viomem is supported from 1.9.40-0
114+
boot_with_viomem = yes
115+
driver_test_name_viomem = "viomem"
116+
slots_mem = 20
117+
maxmem_mem = 80G
118+
mem_devs += ' vmem0'
119+
backend_mem_vmem0 = memory-backend-memfd
120+
node_memory_vmem0 = "0"
121+
vm_memdev_model_vmem0 = "virtio-mem"
122+
size_mem_vmem0 = 8G
123+
requested-size_memory_vmem0 = 1G
124+
memdev_memory_vmem0 = "mem-vmem0"
125+
i386:
126+
# mainly to cover win10.i386 test without viomem
127+
boot_with_viomem = no
128+
variants:
129+
- create_iso:
130+
create_iso = yes
131+
driver_folder_name = Virtio-Win
132+
guest_path = "C:\Program Files\${driver_folder_name}\*"
133+
host_installer_path = "/home/installer/"
134+
mkiso_cmd = "mkisofs -o ${cdrom_virtio} -input-charset iso8859-1 -J -R -V "Virtio-Win" ${host_installer_path}"
135+
- install_uninstall:
136+
install_uninstall_test = yes
137+
- update:
138+
update_test = yes
139+
static_ip = 192.168.0.11
140+
static_mask = 255.255.255.0
141+
static_gateway = 192.168.0.5
142+
static_dns = 192.168.0.1
143+
setup_ip_cmd = 'netsh interface ip set address "%s" static ${static_ip} ${static_mask} ${static_gateway}'
144+
setup_dns_cmd = 'netsh interface ip add dns "%s" ${static_dns} validate=no'
145+
- repair:
146+
repair_test = yes
147+
msi_uninstall_cmd = "msiexec.exe /q /passive /x %s"

0 commit comments

Comments
 (0)