From patchwork Tue Jul 5 09:16:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prasanna Kumar Kalever X-Patchwork-Id: 9213897 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6995E60572 for ; Tue, 5 Jul 2016 09:17:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5984428693 for ; Tue, 5 Jul 2016 09:17:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E35128844; Tue, 5 Jul 2016 09:17:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DA0DD28693 for ; Tue, 5 Jul 2016 09:17:12 +0000 (UTC) Received: from localhost ([::1]:53438 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKMTg-0001vB-2h for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Jul 2016 05:17:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKMTJ-0001uU-8U for qemu-devel@nongnu.org; Tue, 05 Jul 2016 05:16:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKMTG-00049f-E8 for qemu-devel@nongnu.org; Tue, 05 Jul 2016 05:16:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39048) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKMTG-00049T-6V for qemu-devel@nongnu.org; Tue, 05 Jul 2016 05:16:46 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3F5597DCD6; Tue, 5 Jul 2016 09:16:44 +0000 (UTC) Received: from dhcp1-86.lab.eng.blr.redhat.com (pkalever.blr.redhat.com [10.70.1.86]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u659Gei0015925; Tue, 5 Jul 2016 05:16:41 -0400 From: Prasanna Kumar Kalever To: qemu-devel@nongnu.org Date: Tue, 5 Jul 2016 14:46:26 +0530 Message-Id: <1467710186-8792-1-git-send-email-prasanna.kalever@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 05 Jul 2016 09:16:44 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] block/gluster: add support to choose libgfapi logfile X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, Prasanna Kumar Kalever , pgurusid@redhat.com, jcody@redhat.com, gluster-devel@gluster.org, rtalur@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP currently all the libgfapi logs defaults to '/dev/stderr' as it was hardcoded in a call to glfs logging api, in case if debug level is chosen to DEBUG/TRACE gfapi logs will be huge and fill/overflow the console view. this patch provides a commandline option to mention log file path which helps in logging to the specified file and also help in persisting the gfapi logs. Usage: -drive file=gluster://hostname/volname/image.qcow2,file.debug=9,\ file.logfile=/var/log/qemu/qemu-gfapi.log Signed-off-by: Prasanna Kumar Kalever --- block/gluster.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/block/gluster.c b/block/gluster.c index 16f7778..6875429 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -24,6 +24,7 @@ typedef struct GlusterAIOCB { typedef struct BDRVGlusterState { struct glfs *glfs; struct glfs_fd *fd; + const char *logfile; bool supports_seek_data; int debug_level; } BDRVGlusterState; @@ -34,6 +35,7 @@ typedef struct GlusterConf { char *volname; char *image; char *transport; + const char *logfile; int debug_level; } GlusterConf; @@ -181,7 +183,8 @@ static struct glfs *qemu_gluster_init(GlusterConf *gconf, const char *filename, ret = qemu_gluster_parseuri(gconf, filename); if (ret < 0) { error_setg(errp, "Usage: file=gluster[+transport]://[server[:port]]/" - "volname/image[?socket=...]"); + "volname/image[?socket=...][,file.debug=N]" + "[,file.logfile=/path/filename.log]"); errno = -ret; goto out; } @@ -197,7 +200,7 @@ static struct glfs *qemu_gluster_init(GlusterConf *gconf, const char *filename, goto out; } - ret = glfs_set_logging(glfs, "-", gconf->debug_level); + ret = glfs_set_logging(glfs, gconf->logfile, gconf->debug_level); if (ret < 0) { goto out; } @@ -256,6 +259,8 @@ static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret, void *arg) } #define GLUSTER_OPT_FILENAME "filename" +#define GLUSTER_OPT_LOGFILE "logfile" +#define GLUSTER_LOGFILE_DEFAULT "-" /* '-' handled in libgfapi as /dev/stderr */ #define GLUSTER_OPT_DEBUG "debug" #define GLUSTER_DEBUG_DEFAULT 4 #define GLUSTER_DEBUG_MAX 9 @@ -271,6 +276,11 @@ static QemuOptsList runtime_opts = { .help = "URL to the gluster image", }, { + .name = GLUSTER_OPT_LOGFILE, + .type = QEMU_OPT_STRING, + .help = "Logfile path of libgfapi", + }, + { .name = GLUSTER_OPT_DEBUG, .type = QEMU_OPT_NUMBER, .help = "Gluster log level, valid range is 0-9", @@ -339,6 +349,12 @@ static int qemu_gluster_open(BlockDriverState *bs, QDict *options, filename = qemu_opt_get(opts, GLUSTER_OPT_FILENAME); + s->logfile = qemu_opt_get(opts, GLUSTER_OPT_LOGFILE); + if (!s->logfile) { + s->logfile = GLUSTER_LOGFILE_DEFAULT; + } + gconf->logfile = s->logfile; + s->debug_level = qemu_opt_get_number(opts, GLUSTER_OPT_DEBUG, GLUSTER_DEBUG_DEFAULT); if (s->debug_level < 0) { @@ -422,6 +438,7 @@ static int qemu_gluster_reopen_prepare(BDRVReopenState *state, gconf = g_new0(GlusterConf, 1); + gconf->logfile = s->logfile; gconf->debug_level = s->debug_level; reop_s->glfs = qemu_gluster_init(gconf, state->bs->filename, errp); if (reop_s->glfs == NULL) { @@ -556,6 +573,11 @@ static int qemu_gluster_create(const char *filename, char *tmp = NULL; GlusterConf *gconf = g_new0(GlusterConf, 1); + gconf->logfile = qemu_opt_get_del(opts, GLUSTER_OPT_LOGFILE); + if (!gconf->logfile) { + gconf->logfile = GLUSTER_LOGFILE_DEFAULT; + } + gconf->debug_level = qemu_opt_get_number_del(opts, GLUSTER_OPT_DEBUG, GLUSTER_DEBUG_DEFAULT); if (gconf->debug_level < 0) { @@ -949,6 +971,11 @@ static QemuOptsList qemu_gluster_create_opts = { .help = "Preallocation mode (allowed values: off, full)" }, { + .name = GLUSTER_OPT_LOGFILE, + .type = QEMU_OPT_STRING, + .help = "Logfile path of libgfapi", + }, + { .name = GLUSTER_OPT_DEBUG, .type = QEMU_OPT_NUMBER, .help = "Gluster log level, valid range is 0-9",