@@ -251,6 +251,7 @@ 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_dup(int fd);
int qemu_lock_fd(int fd, int64_t start, int64_t len, bool readonly);
int qemu_unlock_fd(int fd, int64_t start, int64_t len);
@@ -408,6 +408,21 @@ int qemu_close(int fd)
return qemu_fd_close(fd);
}
+int qemu_dup(int fd)
+{
+ char *path;
+ int ret = qemu_dup_flags(fd, 0);
+ if (ret == -1) {
+ return ret;
+ }
+
+ path = g_hash_table_lookup(fd_to_path, GINT_TO_POINTER(fd));
+ assert(path);
+ qemu_fd_add_record(ret, path);
+ return ret;
+}
+
+
/*
* A variant of write(2) which handles partial write.
*
This takes care both the CLOEXEC flag and fd-path mapping for image locking. Signed-off-by: Fam Zheng <famz@redhat.com> --- include/qemu/osdep.h | 1 + util/osdep.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+)