Skip to content

Commit e361ff7

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 <xiagao@redhat.com>
1 parent 83e9f35 commit e361ff7

File tree

7 files changed

+497
-32
lines changed

7 files changed

+497
-32
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: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
"vioinput",
2929
"fwcfg",
3030
"viomem",
31+
"viosock",
32+
"viogpudo",
3133
]
3234

3335
device_hwid_list = [
@@ -42,6 +44,8 @@
4244
'"PCI\\VEN_1AF4&DEV_1052"',
4345
'"ACPI\\VEN_QEMU&DEV_0002"',
4446
r'"PCI\VEN_1AF4&DEV_1002" "PCI\VEN_1AF4&DEV_1058"',
47+
r'"PCI\VEN_1AF4&DEV_1053" "PCI\VEN_1AF4&DEV_1012"',
48+
r'"PCI\VEN_1AF4&DEV_1050&SUBSYS_11001AF4&REV_01"',
4549
]
4650

4751
device_name_list = [
@@ -56,6 +60,8 @@
5660
"VirtIO Input Driver",
5761
"QEMU FwCfg Device",
5862
"VirtIO Viomem Driver",
63+
"VirtIO Socket Driver",
64+
"Red Hat VirtIO GPU DOD controller",
5965
]
6066

6167

@@ -184,7 +190,7 @@ def driver_check(session, test, params):
184190
continue
185191
error_context.context("%s Driver Check" % driver_name, LOG_JOB.info)
186192
inf_path = win_driver_utils.get_driver_inf_path(
187-
session, test, media_type, driver_name
193+
session, test, media_type, driver_name, params
188194
)
189195
expected_ver = session.cmd(
190196
"type %s | findstr /i /r DriverVer.*=" % inf_path, timeout=360
@@ -222,6 +228,18 @@ def check_gagent_version(session, test, gagent_pkg_info_cmd, expected_gagent_ver
222228
"""
223229
error_context.context("Check if gagent version is correct.", LOG_JOB.info)
224230
actual_gagent_version = session.cmd_output(gagent_pkg_info_cmd).split()[-2]
231+
232+
exe_ver_cmd = r'"c:\program files\qemu-ga\qemu-ga.exe" --version'
233+
gagent_exe_version = session.cmd_output(exe_ver_cmd)
234+
235+
test.log.info(
236+
"actual_gagent_version version is %s, "
237+
"qga version by installer is %s, "
238+
"gagent exe version is %s",
239+
actual_gagent_version,
240+
expected_gagent_version,
241+
gagent_exe_version,
242+
)
225243
if actual_gagent_version != expected_gagent_version:
226244
test.fail(
227245
"gagent version is not right, expected is %s but got %s"

provider/win_driver_utils.py

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
"""
66

77
import logging
8-
import os
98
import re
109
import time
1110

1211
import aexpect
13-
from virttest import data_dir, error_context, utils_misc, utils_test
14-
from virttest.utils_version import VersionInterval
12+
from virttest import error_context, utils_misc, utils_test
1513
from virttest.utils_windows import system, virtio_win, wmic
1614

1715
LOG_JOB = logging.getLogger("avocado.test")
@@ -127,14 +125,15 @@ def uninstall_driver(session, test, devcon_path, driver_name, device_name, devic
127125
)
128126

129127

130-
def get_driver_inf_path(session, test, media_type, driver_name):
128+
def get_driver_inf_path(session, test, media_type, driver_name, params):
131129
"""
132130
Get driver inf path from virtio win iso,such as E:\viofs\2k19\amd64.
133131
134132
:param session: The guest session object.
135133
:param test: kvm test object.
136134
:param media_type: media type.
137135
:param driver_name: driver name.
136+
:param params: the dict used for parameters
138137
"""
139138
try:
140139
get_drive_letter = getattr(virtio_win, "drive_letter_%s" % media_type)
@@ -151,20 +150,28 @@ def get_driver_inf_path(session, test, media_type, driver_name):
151150
guest_arch = get_arch_dirname(session)
152151
if not guest_arch:
153152
test.error("Could not get architecture dirname of the vm")
154-
153+
# for formal virtio-win iso
155154
inf_middle_path = (
156155
"{name}\\{arch}" if media_type == "iso" else "{arch}\\{name}"
157156
).format(name=guest_name, arch=guest_arch)
158-
inf_find_cmd = 'dir /b /s %s\\%s.inf | findstr "\\%s\\\\"'
159-
inf_find_cmd %= (viowin_ltr, driver_name, inf_middle_path)
160-
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 = (
162+
inf_find_cmd.replace("VIOWIN_LTR", viowin_ltr)
163+
.replace("DRIVER_NAME", driver_name)
164+
.replace("INF_MID_PATH", inf_middle_path)
165+
)
166+
167+
inf_path = session.cmd(inf_find_cmd_new, timeout=OPERATION_TIMEOUT).strip()
161168
LOG_JOB.info("Found inf file '%s'", inf_path)
162169
return inf_path
163170

164171

165172
@error_context.context_aware
166173
def install_driver_by_virtio_media(
167-
session, test, devcon_path, media_type, driver_name, device_hwid
174+
session, test, devcon_path, media_type, driver_name, device_hwid, params
168175
):
169176
"""
170177
Install driver by virtio media.
@@ -175,6 +182,7 @@ def install_driver_by_virtio_media(
175182
:param media_type: media type.
176183
:param driver_name: driver name.
177184
:param device_hwid: device hardware id.
185+
:param params: the dict used for parameters
178186
"""
179187
devcon_path = utils_misc.set_winutils_letter(session, devcon_path)
180188
status, output = session.cmd_status_output(
@@ -188,7 +196,7 @@ def install_driver_by_virtio_media(
188196
output = session.cmd_output("%s find %s" % (devcon_path, hwid))
189197
if re.search("No matching devices found", output, re.I):
190198
continue
191-
inf_path = get_driver_inf_path(session, test, media_type, driver_name)
199+
inf_path = get_driver_inf_path(session, test, media_type, driver_name, params)
192200
inst_cmd = "%s updateni %s %s" % (devcon_path, inf_path, hwid)
193201
status, output = session.cmd_status_output(inst_cmd, INSTALL_TIMEOUT)
194202
# acceptable status: OK(0), REBOOT(1)
@@ -239,15 +247,6 @@ def run_installer(vm, session, test, params, run_installer_cmd):
239247
:param run_installer_cmd: install/uninstall/repair cmd.
240248
:return session: a new session after restart of installer
241249
"""
242-
cdrom_virtio = params["cdrom_virtio"]
243-
installer_restart_version = params.get(
244-
"installer_restart_version", "[1.9.37.0, 1.9.40.0]"
245-
)
246-
cdrom_virtio_path = os.path.basename(
247-
utils_misc.get_path(data_dir.get_data_dir(), cdrom_virtio)
248-
)
249-
match = re.search(r"virtio-win-(\d+\.\d+(?:\.\d+)?-\d+)", cdrom_virtio_path)
250-
cdrom_virtio_version = re.sub("-", ".", match.group(1))
251250
# run installer cmd
252251
run_installer_cmd = utils_misc.set_winutils_letter(session, run_installer_cmd)
253252
session.cmd(run_installer_cmd)
@@ -256,18 +255,14 @@ def run_installer(vm, session, test, params, run_installer_cmd):
256255
lambda: not autoit_installer_check(params, session), 240, 2, 2
257256
):
258257
test.fail("Autoit exe stop there for 240s, please have a check.")
259-
restart_con_ver = cdrom_virtio_version in VersionInterval(installer_restart_version)
260258
restart_con_repair = "repair" in run_installer_cmd
261-
if restart_con_ver or restart_con_repair:
262-
# 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
263261
if not utils_misc.wait_for(lambda: not session.is_responsive(), 120, 5, 5):
264262
test.fail(
265263
"The previous session still exists,seems that the vm doesn't restart."
266264
)
267265
session = vm.wait_for_login(timeout=360)
268-
# for the early virtio-win instller, rebooting is needed.
269-
if cdrom_virtio_version in VersionInterval("(,1.9.37.0)"):
270-
session = vm.reboot(session)
271266
return session
272267

273268

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
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+
# add vsock device, except for Win10
110+
! Win10:
111+
vsocks = vhost_vsock0
112+
# add virtio vga device
113+
vga = "virtio"
114+
# add viomem
115+
x86_64:
116+
# virtio-mem is not supported on 32-bit systems
117+
# and viomem is supported from 1.9.40-0
118+
boot_with_viomem = yes
119+
slots_mem = 20
120+
maxmem_mem = 80G
121+
mem_devs += ' vmem0'
122+
backend_mem_vmem0 = memory-backend-memfd
123+
node_memory_vmem0 = "0"
124+
vm_memdev_model_vmem0 = "virtio-mem"
125+
size_mem_vmem0 = 8G
126+
requested-size_memory_vmem0 = 1G
127+
memdev_memory_vmem0 = "mem-vmem0"
128+
i386:
129+
# mainly to cover win10.i386 test without viomem
130+
boot_with_viomem = no
131+
variants:
132+
- create_iso:
133+
create_iso = yes
134+
driver_folder_name = Virtio-Win
135+
guest_path = "C:\Program Files\${driver_folder_name}\*"
136+
host_installer_path = "/home/installer/"
137+
mkiso_cmd = "mkisofs -o ${cdrom_virtio} -input-charset iso8859-1 -J -R -V "Virtio-Win" ${host_installer_path}"
138+
- install_uninstall:
139+
install_uninstall_test = yes
140+
- update:
141+
update_test = yes
142+
static_ip = 192.168.0.11
143+
static_mask = 255.255.255.0
144+
static_gateway = 192.168.0.5
145+
static_dns = 192.168.0.1
146+
setup_ip_cmd = 'netsh interface ip set address "%s" static ${static_ip} ${static_mask} ${static_gateway}'
147+
setup_dns_cmd = 'netsh interface ip add dns "%s" ${static_dns} validate=no'
148+
- repair:
149+
repair_test = yes
150+
msi_uninstall_cmd = "msiexec.exe /q /passive /x %s"

0 commit comments

Comments
 (0)