On Tue, Jul 23, 2019 at 10:50:24AM +0100, Peter Maydell wrote: > On Tue, 23 Jul 2019 at 10:42, Stefano Garzarella <sgarz...@redhat.com> wrote: > > Reading the 'g_mapped_file_new_from_fd()' docs [1]: > > "If writable is TRUE, the mapped buffer may be modified, otherwise it is an > > error to modify the mapped buffer. Modifications to the buffer are not > > visible > > to other processes mapping the same file, and are not written back to the > > file." > > > > I don't know what "error" means, but reading the second part I thought > > the changes in that case were only visible at the current process. > > Ah, I misread the docs here (and thought the following paragraph > which talks about changes to the underlying file becoming visible > to the mapping process was talking about changes in the mapping > process becoming visible to the file).
I misread too... > > So I think the answer is that we do want to pass writable=true. Yes, I'll do in the v2! > > Looking at the implementation, we always use mmap()'s MAP_PRIVATE, > so we get a copy-on-write mapping that doesn't change the underlying > file. The effect of the 'writable' flag is that we use PROT_READ|PROT_WRITE, > so if we don't pass writable=true we're liable to get a segfault. Yes, I just tried and I got the segfault. Thanks, Stefano