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

2018-03-20 Thread Daniel P . Berrangé
On Tue, Mar 20, 2018 at 05:21:16PM +0100, Florian Larysch wrote: > 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 QEM

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 Eric Blake
On 03/20/2018 11:02 AM, Daniel P. Berrangé wrote: On Tue, Mar 20, 2018 at 09:50:19AM -0500, Eric Blake wrote: On 03/20/2018 04:31 AM, Florian Larysch wrote: qemu_create_pidfile does not truncate the pidfile when it creates it, but rather overwrites its contents with the new pid. This works fine

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

2018-03-20 Thread Daniel P . Berrangé
On Tue, Mar 20, 2018 at 09:50:19AM -0500, Eric Blake wrote: > On 03/20/2018 04:31 AM, Florian Larysch wrote: > > qemu_create_pidfile does not truncate the pidfile when it creates it, > > but rather overwrites its contents with the new pid. This works fine as > > long as the length of the pid doesn'

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

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

2018-03-20 Thread Eric Blake
On 03/20/2018 04:31 AM, Florian Larysch wrote: qemu_create_pidfile does not truncate the pidfile when it creates it, but rather overwrites its contents with the new pid. This works fine as long as the length of the pid doesn't decrease, but this might happen in case of wraparounds, causing pidfil