[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 40/51] chardev/char-file: Add FILE_SHARE_WRITE when openning
From: |
Marc-André Lureau |
Subject: |
Re: [PATCH 40/51] chardev/char-file: Add FILE_SHARE_WRITE when openning the file for win32 |
Date: |
Thu, 25 Aug 2022 11:58:47 +0400 |
Hi
On Wed, Aug 24, 2022 at 1:43 PM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> From: Xuzhou Cheng <xuzhou.cheng@windriver.com>
>
> The combination of GENERIC_WRITE and FILE_SHARE_READ options does
> not allow the same file to be opened again by CreateFile() from
> another QEMU process with the same options when the previous QEMU
> process still holds the file handle openned.
opened
>
> As per [1] we should add FILE_SHARE_WRITE to the share mode to allow
> such use case. This change makes the behavior be consisten with the
> POSIX platforms.
>
consistent
> [1]
> https://docs.microsoft.com/en-us/windows/win32/fileio/creating-and-opening-files
>
> Signed-off-by: Xuzhou Cheng <xuzhou.cheng@windriver.com>
> Signed-off-by: Bin Meng <bin.meng@windriver.com>
> ---
What's the benefit to allow multiple processes write access to the
same file? It seems it could easily lead to corruption or unexpected
results.
To me, it's the other way around, the POSIX implementation should
learn to lock the file opened for write..
>
> chardev/char-file.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/chardev/char-file.c b/chardev/char-file.c
> index 2fd80707e5..66385211eb 100644
> --- a/chardev/char-file.c
> +++ b/chardev/char-file.c
> @@ -60,8 +60,8 @@ static void qmp_chardev_open_file(Chardev *chr,
> flags = CREATE_ALWAYS;
> }
>
> - out = CreateFile(file->out, accessmode, FILE_SHARE_READ, NULL, flags,
> - FILE_ATTRIBUTE_NORMAL, NULL);
> + out = CreateFile(file->out, accessmode, FILE_SHARE_READ |
> FILE_SHARE_WRITE,
> + NULL, flags, FILE_ATTRIBUTE_NORMAL, NULL);
> if (out == INVALID_HANDLE_VALUE) {
> error_setg(errp, "open %s failed", file->out);
> return;
> --
> 2.34.1
>
- [PATCH 42/51] hw/ppc: spapr: Use qemu_vfree() to free spapr->htab, (continued)
- [PATCH 42/51] hw/ppc: spapr: Use qemu_vfree() to free spapr->htab, Bin Meng, 2022/08/24
- [PATCH 41/51] tests/qtest: migration-test: Kill "to" after migration is canceled, Bin Meng, 2022/08/24
- [PATCH 45/51] tests/qtest: prom-env-test: Use double quotes to pass the prom-env option, Bin Meng, 2022/08/24
- [PATCH 46/51] tests/qtest: libqtest: Replace the call to close a socket with closesocket(), Bin Meng, 2022/08/24
- [PATCH 36/51] tests/qtest: machine-none-test: Use double quotes to pass the cpu option, Bin Meng, 2022/08/24
- [PATCH 40/51] chardev/char-file: Add FILE_SHARE_WRITE when openning the file for win32, Bin Meng, 2022/08/24
- Re: [PATCH 40/51] chardev/char-file: Add FILE_SHARE_WRITE when openning the file for win32,
Marc-André Lureau <=
[PATCH 44/51] tests/qtest: microbit-test: Fix socket access for win32, Bin Meng, 2022/08/24
[PATCH 47/51] tests/qtest: libqtest: Correct the timeout unit of blocking receive calls for win32, Bin Meng, 2022/08/24
[PATCH 48/51] io/channel-watch: Drop a superfluous '#ifdef WIN32', Bin Meng, 2022/08/24
[PATCH 49/51] io/channel-watch: Fix socket watch on Windows, Bin Meng, 2022/08/24
[PATCH 50/51] .gitlab-ci.d/windows.yml: Increase the timeout to the runner limit, Bin Meng, 2022/08/24