[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 3/4] osdep: Enable qemu_open to dup pre-opened fd
From: |
Corey Bryant |
Subject: |
[Qemu-devel] [PATCH v2 3/4] osdep: Enable qemu_open to dup pre-opened fd |
Date: |
Fri, 8 Jun 2012 11:42:58 -0400 |
This patch adds support to qemu_open to dup(X) a pre-opened file
descriptor if the filename is of the format /dev/fd/X.
This can be used when QEMU is restricted from opening files, and
the management application opens files on QEMU's behalf.
v2:
-Get rid of file_open and move dup code to qemu_open (address@hidden)
-Use strtol wrapper instead of atoi (address@hidden)
Signed-off-by: Corey Bryant <address@hidden>
---
osdep.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/osdep.c b/osdep.c
index 3e6bada..c17cdcb 100644
--- a/osdep.c
+++ b/osdep.c
@@ -82,6 +82,19 @@ int qemu_open(const char *name, int flags, ...)
int ret;
int mode = 0;
+#ifndef _WIN32
+ const char *p;
+
+ /* Attempt dup of fd for pre-opened file */
+ if (strstart(name, "/dev/fd/", &p)) {
+ ret = qemu_parse_fd(p);
+ if (ret == -1) {
+ return -1;
+ }
+ return dup(ret);
+ }
+#endif
+
if (flags & O_CREAT) {
va_list ap;
--
1.7.10.2
- Re: [Qemu-devel] [PATCH v2 1/4] qapi: Convert getfd and closefd, (continued)
[Qemu-devel] [PATCH v2 2/4] qapi: Add passfd QMP command, Corey Bryant, 2012/06/08
- Re: [Qemu-devel] [PATCH v2 2/4] qapi: Add passfd QMP command, Luiz Capitulino, 2012/06/13
- Re: [Qemu-devel] [PATCH v2 2/4] qapi: Add passfd QMP command, Corey Bryant, 2012/06/13
- Re: [Qemu-devel] [PATCH v2 2/4] qapi: Add passfd QMP command, Eric Blake, 2012/06/13
- Re: [Qemu-devel] [PATCH v2 2/4] qapi: Add passfd QMP command, Corey Bryant, 2012/06/13
- Re: [Qemu-devel] [PATCH v2 2/4] qapi: Add passfd QMP command, Luiz Capitulino, 2012/06/14
[Qemu-devel] [PATCH v2 3/4] osdep: Enable qemu_open to dup pre-opened fd,
Corey Bryant <=
[Qemu-devel] [PATCH v2 4/4] block: Convert open calls to qemu_open, Corey Bryant, 2012/06/08
Re: [Qemu-devel] [PATCH v2 0/4] file descriptor passing using passfd, Corey Bryant, 2012/06/08
Re: [Qemu-devel] [PATCH v2 0/4] file descriptor passing using passfd, Kevin Wolf, 2012/06/13