qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] READCONFIG: Allow reading the configuration from a


From: Ronnie Sahlberg
Subject: [Qemu-devel] [PATCH] READCONFIG: Allow reading the configuration from a pre-existing filedescriptor
Date: Thu, 26 Jan 2012 09:23:31 +1100

Update the readconfig filename parsing to allow specifying an existing, 
inherited, filedescriptor as 'fd:<n>'
This is useful when you want to pass potentially sensitive onfiguration data to 
qemu without having it hit the filesystem/stable-storage

Signed-off-by: Ronnie Sahlberg <address@hidden>
---
 qemu-config.c   |   15 +++++++++++++--
 qemu-options.hx |    3 ++-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/qemu-config.c b/qemu-config.c
index b030205..c12c5eb 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -770,8 +770,19 @@ out:
 
 int qemu_read_config_file(const char *filename)
 {
-    FILE *f = fopen(filename, "r");
-    int ret;
+    FILE *f;
+    int ret, fd;
+
+    if (strncmp(filename, "fd:", 3)) {
+        f = fopen(filename, "r");
+    } else {
+        errno = 0;
+        fd = strtol(filename + 3, NULL, 10);
+        if (errno != 0) {
+            return -errno;
+        }
+        f = fdopen(fd, "r");
+    }
 
     if (f == NULL) {
         return -errno;
diff --git a/qemu-options.hx b/qemu-options.hx
index 3a07ae8..653ff2d 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2577,7 +2577,8 @@ DEF("readconfig", HAS_ARG, QEMU_OPTION_readconfig,
 STEXI
 @item -readconfig @var{file}
 @findex -readconfig
-Read device configuration from @var{file}.
+Read device configuration from @var{file}. Use 'fd:<n>' as filename
+to read from an existing, inherited, filedesriptor.
 ETEXI
 DEF("writeconfig", HAS_ARG, QEMU_OPTION_writeconfig,
     "-writeconfig <file>\n"
-- 
1.7.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]