From: Ronnie Sahlberg <ronniesahlberg@gmail.com>
To: qemu-devel@nongnu.org, eblake@redhat.com
Cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Subject: [Qemu-devel] [PATCH] READCONFIG: Allow reading the configuration from a pre-existing filedescriptor
Date: Thu, 26 Jan 2012 09:23:31 +1100 [thread overview]
Message-ID: <1327530211-25614-2-git-send-email-ronniesahlberg@gmail.com> (raw)
In-Reply-To: <1327530211-25614-1-git-send-email-ronniesahlberg@gmail.com>
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 <ronniesahlberg@gmail.com>
---
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
next prev parent reply other threads:[~2012-01-25 22:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-25 22:23 [Qemu-devel] [PATCH 0/0] Allow -readconfig to read from a pre-existing filedescriptor Ronnie Sahlberg
2012-01-25 22:23 ` Ronnie Sahlberg [this message]
2012-01-25 22:47 ` [Qemu-devel] [PATCH] READCONFIG: Allow reading the configuration " Eric Blake
2012-01-26 7:40 ` Markus Armbruster
2012-01-26 10:43 ` Daniel P. Berrange
2012-03-08 19:13 ` Eduardo Habkost
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1327530211-25614-2-git-send-email-ronniesahlberg@gmail.com \
--to=ronniesahlberg@gmail.com \
--cc=eblake@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).