Received: from eggs.gnu.org ([140.186.70.92]:48181) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqBG7-0006JU-Bm for qemu-devel@nongnu.org; Wed, 25 Jan 2012 17:24:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RqBG4-0003wz-T8 for qemu-devel@nongnu.org; Wed, 25 Jan 2012 17:24:02 -0500 Received: from mail-gy0-f173.google.com ([209.85.160.173]:51688) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqBG4-0003ws-Oz for qemu-devel@nongnu.org; Wed, 25 Jan 2012 17:24:00 -0500 Received: by ghbg20 with SMTP id g20so3242892ghb.4 for ; Wed, 25 Jan 2012 14:24:00 -0800 (PST) From: Ronnie Sahlberg Date: Thu, 26 Jan 2012 09:23:31 +1100 Message-Id: <1327530211-25614-2-git-send-email-ronniesahlberg@gmail.com> In-Reply-To: <1327530211-25614-1-git-send-email-ronniesahlberg@gmail.com> References: <1327530211-25614-1-git-send-email-ronniesahlberg@gmail.com> Subject: [Qemu-devel] [PATCH] READCONFIG: Allow reading the configuration from a pre-existing filedescriptor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, eblake@redhat.com Cc: Ronnie Sahlberg Update the readconfig filename parsing to allow specifying an existing, inherited, filedescriptor as 'fd:' 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 --- 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:' as filename +to read from an existing, inherited, filedesriptor. ETEXI DEF("writeconfig", HAS_ARG, QEMU_OPTION_writeconfig, "-writeconfig \n" -- 1.7.3.1