Message ID | 1464943756-14143-7-git-send-email-famz@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Am 03.06.2016 um 10:49 hat Fam Zheng geschrieben: > This takes care of both the CLOEXEC flag and fd-path mapping for image > locking. > > Signed-off-by: Fam Zheng <famz@redhat.com> > --- > include/qemu/osdep.h | 3 +++ > util/osdep.c | 9 +++++++++ > 2 files changed, 12 insertions(+) > > diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h > index 749214a..89c63c7 100644 > --- a/include/qemu/osdep.h > +++ b/include/qemu/osdep.h > @@ -281,6 +281,9 @@ int qemu_madvise(void *addr, size_t len, int advice); > int qemu_open(const char *name, int flags, ...); > int qemu_close(int fd); > int qemu_lock_fd(int fd, int64_t start, int64_t len, bool exclusive); > +#ifndef _WIN32 > +int qemu_dup(int fd); > +#endif > int qemu_unlock_fd(int fd, int64_t start, int64_t len); > > #if defined(__HAIKU__) && defined(__i386__) > diff --git a/util/osdep.c b/util/osdep.c > index 085ed52..1c87c1e 100644 > --- a/util/osdep.c > +++ b/util/osdep.c > @@ -133,6 +133,15 @@ fail: > return -1; > } > > +int qemu_dup(int fd) > +{ > + int r = qemu_dup_flags(fd, 0); This clears all file status flags that might be set. I don't think we use any of them (on Linux at least, raw-posix still seems to use it for platform without O_DIRECT), but isn't this still surprising? > + if (r == -1) { > + return -errno; > + } > + return r; > +} Kevin
Am 17.06.2016 um 14:32 hat Kevin Wolf geschrieben: > Am 03.06.2016 um 10:49 hat Fam Zheng geschrieben: > > This takes care of both the CLOEXEC flag and fd-path mapping for image > > locking. > > > > Signed-off-by: Fam Zheng <famz@redhat.com> > > --- > > include/qemu/osdep.h | 3 +++ > > util/osdep.c | 9 +++++++++ > > 2 files changed, 12 insertions(+) > > > > diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h > > index 749214a..89c63c7 100644 > > --- a/include/qemu/osdep.h > > +++ b/include/qemu/osdep.h > > @@ -281,6 +281,9 @@ int qemu_madvise(void *addr, size_t len, int advice); > > int qemu_open(const char *name, int flags, ...); > > int qemu_close(int fd); > > int qemu_lock_fd(int fd, int64_t start, int64_t len, bool exclusive); > > +#ifndef _WIN32 > > +int qemu_dup(int fd); > > +#endif > > int qemu_unlock_fd(int fd, int64_t start, int64_t len); > > > > #if defined(__HAIKU__) && defined(__i386__) > > diff --git a/util/osdep.c b/util/osdep.c > > index 085ed52..1c87c1e 100644 > > --- a/util/osdep.c > > +++ b/util/osdep.c > > @@ -133,6 +133,15 @@ fail: > > return -1; > > } > > > > +int qemu_dup(int fd) > > +{ > > + int r = qemu_dup_flags(fd, 0); > > This clears all file status flags that might be set. I don't think we > use any of them (on Linux at least, raw-posix still seems to use it for > platform without O_DIRECT), but isn't this still surprising? Maybe this means that qemu_dup_flags() should call qemu_dup() instead of the other way round. Kevin
On Fri, 06/17 15:08, Kevin Wolf wrote: > Am 17.06.2016 um 14:32 hat Kevin Wolf geschrieben: > > Am 03.06.2016 um 10:49 hat Fam Zheng geschrieben: > > > This takes care of both the CLOEXEC flag and fd-path mapping for image > > > locking. > > > > > > Signed-off-by: Fam Zheng <famz@redhat.com> > > > --- > > > include/qemu/osdep.h | 3 +++ > > > util/osdep.c | 9 +++++++++ > > > 2 files changed, 12 insertions(+) > > > > > > diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h > > > index 749214a..89c63c7 100644 > > > --- a/include/qemu/osdep.h > > > +++ b/include/qemu/osdep.h > > > @@ -281,6 +281,9 @@ int qemu_madvise(void *addr, size_t len, int advice); > > > int qemu_open(const char *name, int flags, ...); > > > int qemu_close(int fd); > > > int qemu_lock_fd(int fd, int64_t start, int64_t len, bool exclusive); > > > +#ifndef _WIN32 > > > +int qemu_dup(int fd); > > > +#endif > > > int qemu_unlock_fd(int fd, int64_t start, int64_t len); > > > > > > #if defined(__HAIKU__) && defined(__i386__) > > > diff --git a/util/osdep.c b/util/osdep.c > > > index 085ed52..1c87c1e 100644 > > > --- a/util/osdep.c > > > +++ b/util/osdep.c > > > @@ -133,6 +133,15 @@ fail: > > > return -1; > > > } > > > > > > +int qemu_dup(int fd) > > > +{ > > > + int r = qemu_dup_flags(fd, 0); > > > > This clears all file status flags that might be set. I don't think we > > use any of them (on Linux at least, raw-posix still seems to use it for > > platform without O_DIRECT), but isn't this still surprising? > > Maybe this means that qemu_dup_flags() should call qemu_dup() instead of > the other way round. > Yes, I think you are right. Fam
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 749214a..89c63c7 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -281,6 +281,9 @@ int qemu_madvise(void *addr, size_t len, int advice); int qemu_open(const char *name, int flags, ...); int qemu_close(int fd); int qemu_lock_fd(int fd, int64_t start, int64_t len, bool exclusive); +#ifndef _WIN32 +int qemu_dup(int fd); +#endif int qemu_unlock_fd(int fd, int64_t start, int64_t len); #if defined(__HAIKU__) && defined(__i386__) diff --git a/util/osdep.c b/util/osdep.c index 085ed52..1c87c1e 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -133,6 +133,15 @@ fail: return -1; } +int qemu_dup(int fd) +{ + int r = qemu_dup_flags(fd, 0); + if (r == -1) { + return -errno; + } + return r; +} + static int qemu_parse_fdset(const char *param) { return qemu_parse_fd(param);
This takes care of both the CLOEXEC flag and fd-path mapping for image locking. Signed-off-by: Fam Zheng <famz@redhat.com> --- include/qemu/osdep.h | 3 +++ util/osdep.c | 9 +++++++++ 2 files changed, 12 insertions(+)