Skip to content

Commit 023f61c

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 a806781 commit 023f61c

File tree

8 files changed

+484
-30
lines changed

8 files changed

+484
-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
@@ -185,8 +185,9 @@ def mtu_set(mtu):
185185
session = vm.wait_for_login(nic_index=2, timeout=login_timeout)
186186
for driver_name in driver_name.split():
187187
inf_path = win_driver_utils.get_driver_inf_path(
188-
session, test, media_type, driver_name
188+
session, test, media_type, driver_name, params
189189
)
190+
190191
if driver_name == "netkvm":
191192
device_name = params.get("device_name")
192193
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
@@ -289,10 +289,19 @@ def get_viofs_exe_path(test, params, session):
289289
exe_middle_path = (
290290
"{name}\\{arch}" if media_type == "iso" else "{arch}\\{name}"
291291
).format(name=guest_name, arch=guest_arch)
292-
exe_file_name = "virtiofs.exe"
293-
exe_find_cmd = 'dir /b /s %s\\%s | findstr "\\%s\\\\"'
294-
exe_find_cmd %= (viowin_ltr, exe_file_name, exe_middle_path)
295-
exe_path = session.cmd(exe_find_cmd).strip()
292+
293+
exe_file_name = params.get("exe_file_name", "virtiofs.exe")
294+
formal_exe_find_cmd = (
295+
'dir /b /s VIOWIN_LTR\\EXE_FILE_NAME | findstr "\\EXE_MID_PATH\\\\"'
296+
)
297+
exe_find_cmd = params.get("exe_find_cmd", formal_exe_find_cmd)
298+
299+
exe_find_cmd_new = exe_find_cmd.replace(
300+
'VIOWIN_LTR', viowin_ltr).replace(
301+
'EXE_FILE_NAME', exe_file_name).replace(
302+
'EXE_MID_PATH', exe_middle_path)
303+
304+
exe_path = session.cmd(exe_find_cmd_new).strip()
296305
test.log.info("Found exe file '%s'", exe_path)
297306
return exe_path
298307

provider/win_driver_installer_test.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,12 @@ def driver_check(session, test, params):
175175
for driver_name, device_name in zip(driver_name_list, device_name_list):
176176
error_context.context("%s Driver Check" % driver_name, LOG_JOB.info)
177177
inf_path = win_driver_utils.get_driver_inf_path(
178-
session, test, media_type, driver_name
178+
session, test, media_type, driver_name, params
179179
)
180180
expected_ver = session.cmd(
181181
"type %s | findstr /i /r DriverVer.*=" % inf_path, timeout=360
182182
)
183+
183184
expected_ver = expected_ver.strip().split(",", 1)[-1]
184185
if not expected_ver:
185186
test.error("Failed to find driver version from inf file")
@@ -213,6 +214,16 @@ def check_gagent_version(session, test, gagent_pkg_info_cmd, expected_gagent_ver
213214
"""
214215
error_context.context("Check if gagent version is correct.", LOG_JOB.info)
215216
actual_gagent_version = session.cmd_output(gagent_pkg_info_cmd).split()[-2]
217+
218+
exe_ver_cmd = r'"c:\program files\qemu-ga\qemu-ga.exe" --version'
219+
gagent_exe_version = session.cmd_output(exe_ver_cmd)
220+
221+
test.log.info("actual_gagent_version version is %s,"
222+
"qga vertion by installer is %s,"
223+
"gagent exe version is %s" % (actual_gagent_version,
224+
expected_gagent_version,
225+
gagent_exe_version)
226+
)
216227
if actual_gagent_version != expected_gagent_version:
217228
test.fail(
218229
"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
@@ -114,14 +114,15 @@ def uninstall_driver(session, test, devcon_path, driver_name, device_name, devic
114114
)
115115

116116

117-
def get_driver_inf_path(session, test, media_type, driver_name):
117+
def get_driver_inf_path(session, test, media_type, driver_name, params):
118118
"""
119119
Get driver inf path from virtio win iso,such as E:\viofs\2k19\amd64.
120120
121121
:param session: The guest session object.
122122
:param test: kvm test object.
123123
:param media_type: media type.
124124
:param driver_name: driver name.
125+
:param params: the dict used for parameters
125126
"""
126127
try:
127128
get_drive_letter = getattr(virtio_win, "drive_letter_%s" % media_type)
@@ -138,20 +139,27 @@ def get_driver_inf_path(session, test, media_type, driver_name):
138139
guest_arch = get_arch_dirname(session)
139140
if not guest_arch:
140141
test.error("Could not get architecture dirname of the vm")
141-
142+
# for formal virtio-win iso
142143
inf_middle_path = (
143144
"{name}\\{arch}" if media_type == "iso" else "{arch}\\{name}"
144145
).format(name=guest_name, arch=guest_arch)
145-
inf_find_cmd = 'dir /b /s %s\\%s.inf | findstr "\\%s\\\\"'
146-
inf_find_cmd %= (viowin_ltr, driver_name, inf_middle_path)
147-
inf_path = session.cmd(inf_find_cmd, timeout=OPERATION_TIMEOUT).strip()
146+
formal_inf_find_cmd = 'dir /b /s VIOWIN_LTR\\DRIVER_NAME.inf |'
147+
formal_inf_find_cmd += ' findstr "\\INF_MID_PATH\\\\'
148+
inf_find_cmd = params.get("inf_find_cmd", formal_inf_find_cmd)
149+
150+
inf_find_cmd_new = inf_find_cmd.replace(
151+
'VIOWIN_LTR', viowin_ltr).replace(
152+
'DRIVER_NAME', driver_name).replace(
153+
'INF_MID_PATH', inf_middle_path)
154+
155+
inf_path = session.cmd(inf_find_cmd_new, timeout=OPERATION_TIMEOUT).strip()
148156
LOG_JOB.info("Found inf file '%s'", inf_path)
149157
return inf_path
150158

151159

152160
@error_context.context_aware
153161
def install_driver_by_virtio_media(
154-
session, test, devcon_path, media_type, driver_name, device_hwid
162+
session, test, devcon_path, media_type, driver_name, device_hwid, params
155163
):
156164
"""
157165
Install driver by virtio media.
@@ -162,6 +170,7 @@ def install_driver_by_virtio_media(
162170
:param media_type: media type.
163171
:param driver_name: driver name.
164172
:param device_hwid: device hardware id.
173+
:param params: the dict used for parameters
165174
"""
166175
devcon_path = utils_misc.set_winutils_letter(session, devcon_path)
167176
status, output = session.cmd_status_output(
@@ -175,7 +184,8 @@ def install_driver_by_virtio_media(
175184
output = session.cmd_output("%s find %s" % (devcon_path, hwid))
176185
if re.search("No matching devices found", output, re.I):
177186
continue
178-
inf_path = get_driver_inf_path(session, test, media_type, driver_name)
187+
inf_path = get_driver_inf_path(session, test, media_type,
188+
driver_name, params)
179189
inst_cmd = "%s updateni %s %s" % (devcon_path, inf_path, hwid)
180190
status, output = session.cmd_status_output(inst_cmd, INSTALL_TIMEOUT)
181191
# acceptable status: OK(0), REBOOT(1)
@@ -226,15 +236,7 @@ def run_installer(vm, session, test, params, run_installer_cmd):
226236
:param run_installer_cmd: install/uninstall/repair cmd.
227237
:return session: a new session after restart of installer
228238
"""
229-
cdrom_virtio = params["cdrom_virtio"]
230-
installer_restart_version = params.get(
231-
"installer_restart_version", "[1.9.37.0, 1.9.40.0]"
232-
)
233-
cdrom_virtio_path = os.path.basename(
234-
utils_misc.get_path(data_dir.get_data_dir(), cdrom_virtio)
235-
)
236-
match = re.search(r"virtio-win-(\d+\.\d+(?:\.\d+)?-\d+)", cdrom_virtio_path)
237-
cdrom_virtio_version = re.sub("-", ".", match.group(1))
239+
238240
# run installer cmd
239241
run_installer_cmd = utils_misc.set_winutils_letter(session, run_installer_cmd)
240242
session.cmd(run_installer_cmd)
@@ -243,19 +245,16 @@ def run_installer(vm, session, test, params, run_installer_cmd):
243245
lambda: not autoit_installer_check(params, session), 240, 2, 2
244246
):
245247
test.fail("Autoit exe stop there for 240s," " please have a check.")
246-
restart_con_ver = cdrom_virtio_version in VersionInterval(installer_restart_version)
248+
247249
restart_con_repair = "repair" in run_installer_cmd
248-
if restart_con_ver or restart_con_repair:
249-
# Wait for vm re-start by installer itself
250+
if restart_con_repair:
251+
# Wait for vm re-start by installer itself, only repair has self-restart
250252
if not utils_misc.wait_for(lambda: not session.is_responsive(), 120, 5, 5):
251253
test.fail(
252254
"The previous session still exists,"
253255
"seems that the vm doesn't restart."
254256
)
255257
session = vm.wait_for_login(timeout=360)
256-
# for the early virtio-win instller, rebooting is needed.
257-
if cdrom_virtio_version in VersionInterval("(,1.9.37.0)"):
258-
session = vm.reboot(session)
259258
return session
260259

261260

@@ -294,7 +293,6 @@ def copy_file_to_samepath(session, test, params):
294293
dst_path = r"C:\\"
295294
vol_virtio_key = "VolumeName like '%virtio-win%'"
296295
vol_virtio = utils_misc.get_win_disk_vol(session, vol_virtio_key)
297-
298296
installer_path = r"%s:\%s" % (vol_virtio, "virtio-win-guest-tools.exe")
299297
install_script_path = utils_misc.set_winutils_letter(
300298
session, params["install_script_path"]
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
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+
variants:
122+
- create_iso:
123+
create_iso = yes
124+
driver_folder_name = Virtio-Win
125+
guest_path = "C:\Program Files\${driver_folder_name}\*"
126+
host_installer_path = "/home/installer/"
127+
mkiso_cmd = "mkisofs -o ${cdrom_virtio} -input-charset iso8859-1 -J -R -V "Virtio-Win" ${host_installer_path}"
128+
- install_uninstall:
129+
install_uninstall_test = yes
130+
- update:
131+
update_test = yes
132+
static_ip = 192.168.0.11
133+
static_mask = 255.255.255.0
134+
static_gateway = 192.168.0.5
135+
static_dns = 192.168.0.1
136+
setup_ip_cmd = 'netsh interface ip set address "%s" static ${static_ip} ${static_mask} ${static_gateway}'
137+
setup_dns_cmd = 'netsh interface ip add dns "%s" ${static_dns} validate=no'
138+
- repair:
139+
repair_test = yes
140+
msi_uninstall_cmd = "msiexec.exe /q /passive /x %s"

0 commit comments

Comments
 (0)