qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

Merge remote-tracking branch 'remotes/philmd-gitlab/tags/fw_cfg-next-pull-request' into staging

Fix the fw_cfg reboot-timeout=-1 special value, add a test for it.

# gpg: Signature made Sun 03 Nov 2019 22:21:02 GMT
# gpg: using RSA key 89C1E78F601EE86C867495CBA2A3FD6EDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (Phil) <philmd@redhat.com>" [marginal]
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg: It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 89C1 E78F 601E E86C 8674 95CB A2A3 FD6E DEAD C0DE

* remotes/philmd-gitlab/tags/fw_cfg-next-pull-request:
tests/fw_cfg: Test 'reboot-timeout=-1' special value
fw_cfg: Allow reboot-timeout=-1 again

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

+25 -3
+4 -3
hw/nvram/fw_cfg.c
··· 237 237 static void fw_cfg_reboot(FWCfgState *s) 238 238 { 239 239 const char *reboot_timeout = NULL; 240 - int64_t rt_val = -1; 240 + uint64_t rt_val = -1; 241 241 uint32_t rt_le32; 242 242 243 243 /* get user configuration */ ··· 247 247 248 248 if (reboot_timeout) { 249 249 rt_val = qemu_opt_get_number(opts, "reboot-timeout", -1); 250 + 250 251 /* validate the input */ 251 - if (rt_val < 0 || rt_val > 0xffff) { 252 + if (rt_val > 0xffff && rt_val != (uint64_t)-1) { 252 253 error_report("reboot timeout is invalid," 253 - "it should be a value between 0 and 65535"); 254 + "it should be a value between -1 and 65535"); 254 255 exit(1); 255 256 } 256 257 }
+21
tests/fw_cfg-test.c
··· 194 194 qtest_quit(s); 195 195 } 196 196 197 + static void test_fw_cfg_no_reboot_timeout(void) 198 + { 199 + QFWCFG *fw_cfg; 200 + QTestState *s; 201 + uint32_t reboot_timeout = 0; 202 + size_t filesize; 203 + 204 + /* Special value -1 means "don't reboot" */ 205 + s = qtest_init("-boot reboot-timeout=-1"); 206 + fw_cfg = pc_fw_cfg_init(s); 207 + 208 + filesize = qfw_cfg_get_file(fw_cfg, "etc/boot-fail-wait", 209 + &reboot_timeout, sizeof(reboot_timeout)); 210 + g_assert_cmpint(filesize, ==, sizeof(reboot_timeout)); 211 + reboot_timeout = le32_to_cpu(reboot_timeout); 212 + g_assert_cmpint(reboot_timeout, ==, UINT32_MAX); 213 + pc_fw_cfg_uninit(fw_cfg); 214 + qtest_quit(s); 215 + } 216 + 197 217 static void test_fw_cfg_splash_time(void) 198 218 { 199 219 QFWCFG *fw_cfg; ··· 233 253 qtest_add_func("fw_cfg/numa", test_fw_cfg_numa); 234 254 qtest_add_func("fw_cfg/boot_menu", test_fw_cfg_boot_menu); 235 255 qtest_add_func("fw_cfg/reboot_timeout", test_fw_cfg_reboot_timeout); 256 + qtest_add_func("fw_cfg/no_reboot_timeout", test_fw_cfg_no_reboot_timeout); 236 257 qtest_add_func("fw_cfg/splash_time", test_fw_cfg_splash_time); 237 258 238 259 return g_test_run();