[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 39/54] tests/qtest: boot-serial-test: Close the serial file be
From: |
Bin Meng |
Subject: |
[PATCH v4 39/54] tests/qtest: boot-serial-test: Close the serial file before starting QEMU |
Date: |
Tue, 27 Sep 2022 19:06:17 +0800 |
From: Bin Meng <bin.meng@windriver.com>
This qtest executable created a serial chardev file to be passed to
the QEMU executable. The serial file was created by g_file_open_tmp(),
which internally opens the file with FILE_SHARE_WRITE security attribute
on Windows. Based on [1], there is only one case that allows the first
call to CreateFile() with GENERIC_READ & FILE_SHARE_WRITE, and second
call to CreateFile() with GENERIC_WRITE & FILE_SHARE_READ. All other
combinations require FILE_SHARE_WRITE in the second call. But there is
no way for the second call (in this case the QEMU executable) to know
what combination was passed to the first call, unless FILE_SHARE_WRITE
is passed to the second call.
Two processes shouldn't share the same file for writing with a chardev.
Let's close the serial file before starting QEMU.
[1]
https://docs.microsoft.com/en-us/windows/win32/fileio/creating-and-opening-files
Signed-off-by: Bin Meng <bin.meng@windriver.com>
---
Changes in v4:
- New patch: "tests/qtest: boot-serial-test: Close the serial file before
starting QEMU"
tests/qtest/boot-serial-test.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tests/qtest/boot-serial-test.c b/tests/qtest/boot-serial-test.c
index 72310ba30e..b216519b62 100644
--- a/tests/qtest/boot-serial-test.c
+++ b/tests/qtest/boot-serial-test.c
@@ -233,6 +233,7 @@ static void test_machine(const void *data)
ser_fd = g_file_open_tmp("qtest-boot-serial-sXXXXXX", &serialtmp, NULL);
g_assert(ser_fd != -1);
+ close(ser_fd);
if (test->kernel) {
code = test->kernel;
@@ -266,6 +267,8 @@ static void test_machine(const void *data)
unlink(codetmp);
}
+ ser_fd = open(serialtmp, O_RDONLY);
+ g_assert(ser_fd != -1);
if (!check_guest_output(qts, test, ser_fd)) {
g_error("Failed to find expected string. Please check '%s'",
serialtmp);
--
2.34.1
- [PATCH v4 33/54] tests/qtest: Use send/recv for socket communication, (continued)
- [PATCH v4 33/54] tests/qtest: Use send/recv for socket communication, Bin Meng, 2022/09/27
- [PATCH v4 31/54] accel/qtest: Implement a portable qtest accelerator, Bin Meng, 2022/09/27
- [PATCH v4 26/54] fsdev/virtfs-proxy-helper: Use g_mkdir(), Bin Meng, 2022/09/27
- [PATCH v4 28/54] tests/qtest: Skip running virtio-net-test cases that require socketpair() for win32, Bin Meng, 2022/09/27
- [PATCH v4 30/54] tests/qtest: qmp-test: Skip running test_qmp_oob for win32, Bin Meng, 2022/09/27
- [PATCH v4 13/54] tests/qtest: ide-test: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 17/54] tests/qtest: vhost-user-blk-test: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 35/54] tests/qtest: libqtest: Install signal handler via signal(), Bin Meng, 2022/09/27
- [PATCH v4 36/54] tests/qtest: Support libqtest to build and run on Windows, Bin Meng, 2022/09/27
- [PATCH v4 38/54] tests/qtest: bios-tables-test: Adapt the case for win32, Bin Meng, 2022/09/27
- [PATCH v4 39/54] tests/qtest: boot-serial-test: Close the serial file before starting QEMU,
Bin Meng <=
- [PATCH v4 32/54] tests/qtest: libqtest: Adapt global_qtest declaration for win32, Bin Meng, 2022/09/27
- [PATCH v4 34/54] tests/qtest: libqtest: Exclude the *_fds APIs for win32, Bin Meng, 2022/09/27
- [PATCH v4 37/54] tests/qtest: {ahci, ide}-test: Use relative path for temporary files for win32, Bin Meng, 2022/09/27
- [PATCH v4 43/54] tests/qtest: migration-test: Make sure QEMU process "to" exited after migration is canceled, Bin Meng, 2022/09/27
- [PATCH v4 46/54] tests/qtest: libqtest: Correct the timeout unit of blocking receive calls for win32, Bin Meng, 2022/09/27
- [PATCH v4 40/54] tests/qtest: ide-test: Open file in binary mode, Bin Meng, 2022/09/27