Skip to content

Commit d986a1b

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 e843780 commit d986a1b

File tree

8 files changed

+516
-30
lines changed

8 files changed

+516
-30
lines changed

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generic/tests/netperf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,9 @@ def mtu_set(mtu):
214214
session = vm.wait_for_login(nic_index=2, timeout=login_timeout)
215215
for driver_name in driver_name.split():
216216
inf_path = win_driver_utils.get_driver_inf_path(
217-
session, test, media_type, driver_name
217+
session, test, media_type, driver_name, params
218218
)
219+
219220
if driver_name == "netkvm":
220221
device_name = params.get("device_name")
221222
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: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"netkvm",
2626
"vioinput",
2727
"fwcfg",
28+
"viomem",
2829
]
2930

3031
device_hwid_list = [
@@ -38,6 +39,7 @@
3839
'"PCI\\VEN_1AF4&DEV_1000" "PCI\\VEN_1AF4&DEV_1041"',
3940
'"PCI\\VEN_1AF4&DEV_1052"',
4041
'"ACPI\\VEN_QEMU&DEV_0002"',
42+
r'"PCI\VEN_1AF4&DEV_1002" "PCI\VEN_1AF4&DEV_1058"',
4143
]
4244

4345
device_name_list = [
@@ -51,9 +53,11 @@
5153
"Red Hat VirtIO Ethernet Adapter",
5254
"VirtIO Input Driver",
5355
"QEMU FwCfg Device",
56+
"VirtIO Viomem Driver",
5457
]
5558

5659

60+
5761
def install_gagent(session, test, qemu_ga_pkg, gagent_install_cmd, gagent_pkg_info_cmd):
5862
"""
5963
Install guest agent.
@@ -104,6 +108,9 @@ def win_uninstall_all_drivers(session, test, params):
104108
for driver_name, device_name, device_hwid in zip(
105109
driver_name_list, device_name_list, device_hwid_list
106110
):
111+
if params.get("boot_with_viomem", "no") == "no":
112+
if driver_name == "viomem":
113+
continue
107114
win_driver_utils.uninstall_driver(
108115
session, test, devcon_path, driver_name, device_name, device_hwid
109116
)
@@ -173,13 +180,17 @@ def driver_check(session, test, params):
173180
driver_name_list = [params["driver_name"]]
174181
device_name_list = [params["device_name"]]
175182
for driver_name, device_name in zip(driver_name_list, device_name_list):
183+
if params.get("boot_with_viomem", "no") == "no":
184+
if driver_name == "viomem":
185+
continue
176186
error_context.context("%s Driver Check" % driver_name, LOG_JOB.info)
177187
inf_path = win_driver_utils.get_driver_inf_path(
178-
session, test, media_type, driver_name
188+
session, test, media_type, driver_name, params
179189
)
180190
expected_ver = session.cmd(
181191
"type %s | findstr /i /r DriverVer.*=" % inf_path, timeout=360
182192
)
193+
183194
expected_ver = expected_ver.strip().split(",", 1)[-1]
184195
if not expected_ver:
185196
test.error("Failed to find driver version from inf file")
@@ -213,6 +224,16 @@ def check_gagent_version(session, test, gagent_pkg_info_cmd, expected_gagent_ver
213224
"""
214225
error_context.context("Check if gagent version is correct.", LOG_JOB.info)
215226
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+
)
216237
if actual_gagent_version != expected_gagent_version:
217238
test.fail(
218239
"gagent version is not right, expected is %s but got %s"

provider/win_driver_utils.py

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,15 @@ def uninstall_driver(session, test, devcon_path, driver_name, device_name, devic
120120
)
121121

122122

123-
def get_driver_inf_path(session, test, media_type, driver_name):
123+
def get_driver_inf_path(session, test, media_type, driver_name, params):
124124
"""
125125
Get driver inf path from virtio win iso,such as E:\viofs\2k19\amd64.
126126
127127
:param session: The guest session object.
128128
:param test: kvm test object.
129129
:param media_type: media type.
130130
:param driver_name: driver name.
131+
:param params: the dict used for parameters
131132
"""
132133
try:
133134
get_drive_letter = getattr(virtio_win, "drive_letter_%s" % media_type)
@@ -144,20 +145,27 @@ def get_driver_inf_path(session, test, media_type, driver_name):
144145
guest_arch = get_arch_dirname(session)
145146
if not guest_arch:
146147
test.error("Could not get architecture dirname of the vm")
147-
148+
# for formal virtio-win iso
148149
inf_middle_path = (
149150
"{name}\\{arch}" if media_type == "iso" else "{arch}\\{name}"
150151
).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()
152+
formal_inf_find_cmd = 'dir /b /s VIOWIN_LTR\\DRIVER_NAME.inf |'
153+
formal_inf_find_cmd += ' findstr "\\INF_MID_PATH\\\\'
154+
inf_find_cmd = params.get("inf_find_cmd", formal_inf_find_cmd)
155+
156+
inf_find_cmd_new = inf_find_cmd.replace(
157+
'VIOWIN_LTR', viowin_ltr).replace(
158+
'DRIVER_NAME', driver_name).replace(
159+
'INF_MID_PATH', inf_middle_path)
160+
161+
inf_path = session.cmd(inf_find_cmd_new, timeout=OPERATION_TIMEOUT).strip()
154162
LOG_JOB.info("Found inf file '%s'", inf_path)
155163
return inf_path
156164

157165

158166
@error_context.context_aware
159167
def install_driver_by_virtio_media(
160-
session, test, devcon_path, media_type, driver_name, device_hwid
168+
session, test, devcon_path, media_type, driver_name, device_hwid, params
161169
):
162170
"""
163171
Install driver by virtio media.
@@ -168,6 +176,7 @@ def install_driver_by_virtio_media(
168176
:param media_type: media type.
169177
:param driver_name: driver name.
170178
:param device_hwid: device hardware id.
179+
:param params: the dict used for parameters
171180
"""
172181
devcon_path = utils_misc.set_winutils_letter(session, devcon_path)
173182
status, output = session.cmd_status_output(
@@ -181,7 +190,8 @@ def install_driver_by_virtio_media(
181190
output = session.cmd_output("%s find %s" % (devcon_path, hwid))
182191
if re.search("No matching devices found", output, re.I):
183192
continue
184-
inf_path = get_driver_inf_path(session, test, media_type, driver_name)
193+
inf_path = get_driver_inf_path(session, test, media_type,
194+
driver_name, params)
185195
inst_cmd = "%s updateni %s %s" % (devcon_path, inf_path, hwid)
186196
status, output = session.cmd_status_output(inst_cmd, INSTALL_TIMEOUT)
187197
# acceptable status: OK(0), REBOOT(1)
@@ -232,15 +242,7 @@ def run_installer(vm, session, test, params, run_installer_cmd):
232242
:param run_installer_cmd: install/uninstall/repair cmd.
233243
:return session: a new session after restart of installer
234244
"""
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))
245+
244246
# run installer cmd
245247
run_installer_cmd = utils_misc.set_winutils_letter(session, run_installer_cmd)
246248
session.cmd(run_installer_cmd)
@@ -249,19 +251,16 @@ def run_installer(vm, session, test, params, run_installer_cmd):
249251
lambda: not autoit_installer_check(params, session), 240, 2, 2
250252
):
251253
test.fail("Autoit exe stop there for 240s," " please have a check.")
252-
restart_con_ver = cdrom_virtio_version in VersionInterval(installer_restart_version)
254+
253255
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
256+
if restart_con_repair:
257+
# Wait for vm re-start by installer itself, only repair has self-restart
256258
if not utils_misc.wait_for(lambda: not session.is_responsive(), 120, 5, 5):
257259
test.fail(
258260
"The previous session still exists,"
259261
"seems that the vm doesn't restart."
260262
)
261263
session = vm.wait_for_login(timeout=360)
262-
# for the early virtio-win instller, rebooting is needed.
263-
if cdrom_virtio_version in VersionInterval("(,1.9.37.0)"):
264-
session = vm.reboot(session)
265264
return session
266265

267266

@@ -300,7 +299,6 @@ def copy_file_to_samepath(session, test, params):
300299
dst_path = r"C:\\"
301300
vol_virtio_key = "VolumeName like '%virtio-win%'"
302301
vol_virtio = utils_misc.get_win_disk_vol(session, vol_virtio_key)
303-
304302
installer_path = r"%s:\%s" % (vol_virtio, "virtio-win-guest-tools.exe")
305303
install_script_path = utils_misc.set_winutils_letter(
306304
session, params["install_script_path"]
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
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+
installer_pkg_check_cmd = 'wmic product get name |findstr "Virtio-win-driver-installer"'
23+
signed_check_cmd = 'wmic product where name="Virtio-win-driver-installer" | findstr "Red Hat, Inc."'
24+
monitor_type = qmp
25+
monitors = qmp1
26+
mem_stat_check_list = 'stat-free-memory'
27+
check_mem_diff = 300
28+
guest_compare_threshold = 300
29+
guest_mem_ratio = 0.025
30+
devcon_dirname = "win7_"
31+
i386:
32+
devcon_dirname += "x86"
33+
qemu_ga_pkg = qemu-ga-i386.msi
34+
msi_name = virtio-win-gt-x86.msi
35+
uninstall_msi_script = "uninstall_via_msi_x86.au3"
36+
x86_64:
37+
devcon_dirname += "amd64"
38+
qemu_ga_pkg = qemu-ga-x86_64.msi
39+
msi_name = virtio-win-gt-x64.msi
40+
uninstall_msi_script = "uninstall_via_msi_x64.au3"
41+
uninstall_msi_script_path = "WIN_UTILS:\${uninstall_msi_script}"
42+
devcon_path = "WIN_UTILS:\devcon\${devcon_dirname}\devcon.exe"
43+
del devcon_dirname
44+
gagent_install_cmd = "start /wait %s /quiet"
45+
gagent_pkg_info_cmd = 'wmic product where name="Qemu guest agent"'
46+
gagent_uninstall_cmd = "wmic product where name='Qemu guest agent' call uninstall"
47+
nic_model_nic1 = rtl8139
48+
q35:
49+
nic_model_nic1 = e1000e
50+
# install winfsp tool
51+
i386, i686:
52+
install_winfsp_path = 'C:\Program Files'
53+
x86_64:
54+
install_winfsp_path = 'C:\Program Files (x86)'
55+
nics += " nic2"
56+
nic_model_nic2 = virtio
57+
no_virtio_rng:
58+
virtio_rngs += " rng0"
59+
backend_rng0 = rng-builtin
60+
backend_type = builtin
61+
images += " stg0 stg1"
62+
image_name_stg0 = "images/stg0"
63+
image_name_stg1 = "images/stg1"
64+
image_size_stg0 = 5G
65+
image_size_stg1 = 10G
66+
drive_format_stg0 = virtio
67+
drive_format_stg1 = scsi-hd
68+
remove_image_stg0 = yes
69+
remove_image_stg1 = yes
70+
force_create_image_stg0 = yes
71+
force_create_image_stg1 = yes
72+
serials += " vs"
73+
serial_type_vs = virtserialport
74+
balloon = balloon0
75+
balloon_dev_devid = balloon0
76+
balloon_dev_add_bus = yes
77+
install_balloon_service = "%s:\Balloon\blnsvr.exe -i"
78+
uninstall_balloon_service = "%s:\Balloon\blnsvr.exe -u"
79+
status_balloon_service = "%s:\Balloon\blnsvr.exe status"
80+
run_balloon_service = "%s:\Balloon\blnsvr.exe -r"
81+
stop_balloon_service = "%s:\Balloon\blnsvr.exe -s"
82+
inputs = input1
83+
input_dev_bus_type_input1 = virtio
84+
input_dev_type_input1 = mouse
85+
vmcoreinfo = yes
86+
filesystems = fs
87+
fs_driver = virtio-fs
88+
fs_source_type = mount
89+
fs_source_dir = virtio_fs_test/
90+
force_create_fs_source = yes
91+
remove_fs_source = yes
92+
fs_target = 'myfs'
93+
fs_driver_props = {"queue-size": 1024}
94+
Win10.i386:
95+
mem = 4096
96+
mem_devs = mem1
97+
backend_mem_mem1 = memory-backend-file
98+
mem-path_mem1 = /dev/shm
99+
size_mem1 = ${mem}M
100+
use_mem_mem1 = no
101+
share_mem = yes
102+
guest_numa_nodes = shm0
103+
numa_memdev_shm0 = mem-mem1
104+
numa_nodeid_shm0 = 0
105+
fs_binary_extra_options = " -o cache=auto"
106+
test_drivers = 'viorng viostor vioscsi viofs balloon'
107+
driver_test_name_viorng = 'rng'
108+
driver_test_name_viostor = 'iozone'
109+
driver_test_params_viostor = {'images': 'stg0'}
110+
driver_test_name_vioscsi = 'iozone'
111+
driver_test_params_vioscsi = {'images': 'stg1'}
112+
driver_test_name_viofs = "viofs_basic_io"
113+
driver_test_name_balloon = "balloon"
114+
iozone_cmd_opitons = " -azR -r 64k -n 512M -g 1G -M -I -i 0 -i 1 -b iozone.xls -f %s:\testfile"
115+
read_rng_cmd = "WIN_UTILS:\\random_%PROCESSOR_ARCHITECTURE%.exe"
116+
driver_test_names = 'balloon viofs_basic_io'
117+
exe_file_name = "virtiofs.exe"
118+
exe_find_cmd = 'dir /b /s VIOWIN_LTR\EXE_FILE_NAME'
119+
inf_find_cmd = 'dir /b /s VIOWIN_LTR\DRIVER_NAME.inf'
120+
cdrom_virtio = '/home/virtio-win-pretest.iso'
121+
# add viomem
122+
driver_test_name_viomem = "viomem"
123+
slots_mem = 20
124+
maxmem_mem = 80G
125+
mem_devs += ' vmem0'
126+
backend_mem_vmem0 = memory-backend-memfd
127+
node_memory_vmem0 = "0"
128+
vm_memdev_model_vmem0 = "virtio-mem"
129+
size_mem_vmem0 = 8G
130+
requested-size_memory_vmem0 = 1G
131+
memdev_memory_vmem0 = "mem-vmem0"
132+
test_drivers += ' viomem'
133+
driver_test_name_viomem = "viomem"
134+
boot_with_viomem = yes
135+
Win10.i386:
136+
boot_with_viomem = no
137+
variants:
138+
- create_iso:
139+
create_iso = yes
140+
driver_folder_name = Virtio-Win
141+
guest_path = "C:\Program Files\${driver_folder_name}\*"
142+
host_installer_path = "/home/installer/"
143+
mkiso_cmd = "mkisofs -o ${cdrom_virtio} -input-charset iso8859-1 -J -R -V "Virtio-Win" ${host_installer_path}"
144+
- install_uninstall:
145+
install_uninstall_test = yes
146+
- update:
147+
update_test = yes
148+
static_ip = 192.168.0.11
149+
static_mask = 255.255.255.0
150+
static_gateway = 192.168.0.5
151+
static_dns = 192.168.0.1
152+
setup_ip_cmd = 'netsh interface ip set address "%s" static ${static_ip} ${static_mask} ${static_gateway}'
153+
setup_dns_cmd = 'netsh interface ip add dns "%s" ${static_dns} validate=no'
154+
- repair:
155+
repair_test = yes
156+
msi_uninstall_cmd = "msiexec.exe /q /passive /x %s"

0 commit comments

Comments
 (0)