Re: [Qemu-devel] [PATCH v3] os: truncate pidfile on creation

2018-03-20 Thread Florian Larysch
On Tue, Mar 20, 2018 at 01:00:40PM -0500, Eric Blake wrote: > Here after the --- is a nice place to summarize how v3 differs from > v2, to save reviewers some time. The triviality of the change didn't seem to warrant that, but in retrospect, I realize that searching for the sole trivial change wh

[Qemu-devel] [PATCH v3] os: truncate pidfile on creation

2018-03-20 Thread Florian Larysch
dfiles. Signed-off-by: Florian Larysch --- os-posix.c | 6 ++ os-win32.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/os-posix.c b/os-posix.c index b9c2343b1e..f2318aef55 100644 --- a/os-posix.c +++ b/os-posix.c @@ -309,6 +309,12 @@ int qemu_create_pidfile(const

[Qemu-devel] [PATCH v2] os: truncate pidfile on creation

2018-03-20 Thread Florian Larysch
dfiles. Signed-off-by: Florian Larysch --- os-posix.c | 6 ++ os-win32.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/os-posix.c b/os-posix.c index b9c2343b1e..f2318aef55 100644 --- a/os-posix.c +++ b/os-posix.c @@ -309,6 +309,12 @@ int qemu_create_pidfile(const

Re: [Qemu-devel] [PATCH for-2.12] os: truncate pidfile on creation

2018-03-20 Thread Florian Larysch
On Tue, Mar 20, 2018 at 04:02:44PM +, Daniel P. Berrangé wrote: > No, it is unsafe - we rely on lockf() to get the mutual exclusion. > If a QEMU is running with pidfile locked, and its pid written into > it, then a 2nd QEMU comes along it will truncate the pidfile owned > by the original QEMU b

Re: [Qemu-devel] [PATCH for-2.12] os: truncate pidfile on creation

2018-03-20 Thread Florian Larysch
On Tue, Mar 20, 2018 at 09:50:19AM -0500, Eric Blake wrote: > However, I have to wonder if we have the opposite problem - when the > file exists (truncated) but has not yet been written, how often do > we have a race where someone can see the empty file? > > Should we be going even further and wri

[Qemu-devel] [PATCH] os: truncate pidfile on creation

2018-03-20 Thread Florian Larysch
reaks operations such as 'kill $(cat pidfile)'. Instead, always truncate the file before writing it. Signed-off-by: Florian Larysch --- os-posix.c | 2 +- os-win32.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/os-posix.c b/os-posix.c index b9c2343b1e..9a6b874180