[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 13/20] oslib: add a wrapper for mmap/munmap
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 13/20] oslib: add a wrapper for mmap/munmap |
Date: |
Sat, 15 Dec 2012 04:06:48 -0500 (EST) |
----- Messaggio originale -----
> Da: "Eric Blake" <address@hidden>
> A: "Paolo Bonzini" <address@hidden>
> Cc: address@hidden, address@hidden, address@hidden, address@hidden
> Inviato: Venerdì, 14 dicembre 2012 23:54:31
> Oggetto: Re: [PATCH 13/20] oslib: add a wrapper for mmap/munmap
>
> On 12/12/2012 06:46 AM, Paolo Bonzini wrote:
> > Signed-off-by: Paolo Bonzini <address@hidden>
> > ---
> > osdep.h | 10 ++++++++++
> > oslib-posix.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
> > oslib-win32.c | 59
> > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > 3 files changed, 116 insertions(+)
> >
>
> > +int qemu_mmap_alloc(QEMUMmapArea *mm, const char *path, size_t
> > size)
> > +{
> > + int fd = -1;
> > + char *mem = NULL;
> > + int save_errno;
> > +
> > + fd = qemu_open(path, O_RDWR | O_CREAT, 0666);
>
> Do you want O_EXCL and/or O_TRUNC here as well?
> Or are you okay with using this to read existing contents and for the
> size to possibly discard the tail of a file? (Hmm, thinking of how
> you plan on using persistent bitmaps, it sounds like you WANT to open
> pre-existing files; but then the caller has to be careful to pass in
> the right size).
Yes. The caller will copy the transient bitmap to the persistent one
if it is creating a new file, and vice versa when loading.
> You're blindly unlinking here
Right, the unlink should be in the caller.
> ; sounds like you either want O_EXCL on the
> open, or need to skip the unlink() if the file was pre-existing. No
> error checking that unlink() succeeded?
No error checking because the mmap error is more important to pass up.
> You unlink()d the file on failure during the initial map, but nowhere
> else. Is that intentional?
Yes.
Paolo
- Re: [Qemu-devel] [PATCH 08/20] mirror: allow customizing the granularity, (continued)
- [Qemu-devel] [PATCH 10/20] mirror: add buf-size argument to drive-mirror, Paolo Bonzini, 2012/12/12
- [Qemu-devel] [PATCH 12/20] mirror: support arbitrarily-sized iterations, Paolo Bonzini, 2012/12/12
- [Qemu-devel] [PATCH 11/20] mirror: support more than one in-flight AIO operation, Paolo Bonzini, 2012/12/12
- [Qemu-devel] [PATCH 13/20] oslib: add a wrapper for mmap/munmap, Paolo Bonzini, 2012/12/12
- [Qemu-devel] [PATCH 14/20] hbitmap: add hbitmap_alloc_with_data and hbitmap_required_size, Paolo Bonzini, 2012/12/12
- [Qemu-devel] [PATCH 15/20] hbitmap: add hbitmap_copy, Paolo Bonzini, 2012/12/12
- [Qemu-devel] [PATCH 16/20] block: split bdrv_enable_dirty_tracking and bdrv_disable_dirty_tracking, Paolo Bonzini, 2012/12/12
- [Qemu-devel] [PATCH 18/20] mirror: add support for persistent dirty bitmap, Paolo Bonzini, 2012/12/12
- [Qemu-devel] [PATCH 19/20] block: choose the default dirty bitmap granularity in bdrv_enable_dirty_tracking, Paolo Bonzini, 2012/12/12