|
|
9ae3a8 |
From 2ffc3b31eafe39cc11678ef0e0ea39cdfef0469d Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Jeffrey Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
Date: Tue, 17 Jan 2017 19:51:32 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 3/3] block/gluster: add support for selecting debug logging
|
|
|
9ae3a8 |
level
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Jeffrey Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
Message-id: <87a60937c8dfa4bee63e59871811dbda7794e818.1484682588.git.jcody@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 73255
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.4 qemu-kvm 3/3] block/gluster: add support for selecting debug logging level
|
|
|
9ae3a8 |
Bugzilla: 1151859
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
This adds commandline support for the logging level of the
|
|
|
9ae3a8 |
gluster protocol driver, output to stdout. The option is 'debug',
|
|
|
9ae3a8 |
e.g.:
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-drive filename=gluster://192.168.15.180/gv2/test.qcow2,debug=9
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Debug levels are 0-9, with 9 being the most verbose, and 0 representing
|
|
|
9ae3a8 |
no debugging output. The default is the same as it was before, which
|
|
|
9ae3a8 |
is a level of 4. The current logging levels defined in the gluster
|
|
|
9ae3a8 |
source are:
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
0 - None
|
|
|
9ae3a8 |
1 - Emergency
|
|
|
9ae3a8 |
2 - Alert
|
|
|
9ae3a8 |
3 - Critical
|
|
|
9ae3a8 |
4 - Error
|
|
|
9ae3a8 |
5 - Warning
|
|
|
9ae3a8 |
6 - Notice
|
|
|
9ae3a8 |
7 - Info
|
|
|
9ae3a8 |
8 - Debug
|
|
|
9ae3a8 |
9 - Trace
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
(From: glusterfs/logging.h)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Reviewed-by: Niels de Vos <ndevos@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Jeff Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 7eac868a508cdbf4cccef5c2084941b63fa3aded)
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block/gluster.c | 61 +++++++++++++++++++++++++++++++++++++++++++++------------
|
|
|
9ae3a8 |
1 file changed, 48 insertions(+), 13 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/gluster.c b/block/gluster.c
|
|
|
9ae3a8 |
index 5266dce..86e136d 100644
|
|
|
9ae3a8 |
--- a/block/gluster.c
|
|
|
9ae3a8 |
+++ b/block/gluster.c
|
|
|
9ae3a8 |
@@ -35,6 +35,7 @@ typedef struct BDRVGlusterState {
|
|
|
9ae3a8 |
int qemu_aio_count;
|
|
|
9ae3a8 |
int event_reader_pos;
|
|
|
9ae3a8 |
GlusterAIOCB *event_acb;
|
|
|
9ae3a8 |
+ int debug_level;
|
|
|
9ae3a8 |
} BDRVGlusterState;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#define GLUSTER_FD_READ 0
|
|
|
9ae3a8 |
@@ -46,6 +47,7 @@ typedef struct GlusterConf {
|
|
|
9ae3a8 |
char *volname;
|
|
|
9ae3a8 |
char *image;
|
|
|
9ae3a8 |
char *transport;
|
|
|
9ae3a8 |
+ int debug_level;
|
|
|
9ae3a8 |
} GlusterConf;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static void qemu_gluster_gconf_free(GlusterConf *gconf)
|
|
|
9ae3a8 |
@@ -208,11 +210,7 @@ static struct glfs *qemu_gluster_init(GlusterConf *gconf, const char *filename,
|
|
|
9ae3a8 |
goto out;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- /*
|
|
|
9ae3a8 |
- * TODO: Use GF_LOG_ERROR instead of hard code value of 4 here when
|
|
|
9ae3a8 |
- * GlusterFS makes GF_LOG_* macros available to libgfapi users.
|
|
|
9ae3a8 |
- */
|
|
|
9ae3a8 |
- ret = glfs_set_logging(glfs, "-", 4);
|
|
|
9ae3a8 |
+ ret = glfs_set_logging(glfs, "-", gconf->debug_level);
|
|
|
9ae3a8 |
if (ret < 0) {
|
|
|
9ae3a8 |
goto out;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -292,16 +290,26 @@ static int qemu_gluster_aio_flush_cb(void *opaque)
|
|
|
9ae3a8 |
return (s->qemu_aio_count > 0);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+#define GLUSTER_OPT_FILENAME "filename"
|
|
|
9ae3a8 |
+#define GLUSTER_OPT_DEBUG "debug"
|
|
|
9ae3a8 |
+#define GLUSTER_DEBUG_DEFAULT 4
|
|
|
9ae3a8 |
+#define GLUSTER_DEBUG_MAX 9
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
/* TODO Convert to fine grained options */
|
|
|
9ae3a8 |
static QemuOptsList runtime_opts = {
|
|
|
9ae3a8 |
.name = "gluster",
|
|
|
9ae3a8 |
.head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head),
|
|
|
9ae3a8 |
.desc = {
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- .name = "filename",
|
|
|
9ae3a8 |
+ .name = GLUSTER_OPT_FILENAME,
|
|
|
9ae3a8 |
.type = QEMU_OPT_STRING,
|
|
|
9ae3a8 |
.help = "URL to the gluster image",
|
|
|
9ae3a8 |
},
|
|
|
9ae3a8 |
+ {
|
|
|
9ae3a8 |
+ .name = GLUSTER_OPT_DEBUG,
|
|
|
9ae3a8 |
+ .type = QEMU_OPT_NUMBER,
|
|
|
9ae3a8 |
+ .help = "Gluster log level, valid range is 0-9",
|
|
|
9ae3a8 |
+ },
|
|
|
9ae3a8 |
{ /* end of list */ }
|
|
|
9ae3a8 |
},
|
|
|
9ae3a8 |
};
|
|
|
9ae3a8 |
@@ -342,8 +350,17 @@ static int qemu_gluster_open(BlockDriverState *bs, QDict *options,
|
|
|
9ae3a8 |
goto out;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- filename = qemu_opt_get(opts, "filename");
|
|
|
9ae3a8 |
+ filename = qemu_opt_get(opts, GLUSTER_OPT_FILENAME);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ s->debug_level = qemu_opt_get_number(opts, GLUSTER_OPT_DEBUG,
|
|
|
9ae3a8 |
+ GLUSTER_DEBUG_DEFAULT);
|
|
|
9ae3a8 |
+ if (s->debug_level < 0) {
|
|
|
9ae3a8 |
+ s->debug_level = 0;
|
|
|
9ae3a8 |
+ } else if (s->debug_level > GLUSTER_DEBUG_MAX) {
|
|
|
9ae3a8 |
+ s->debug_level = GLUSTER_DEBUG_MAX;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ gconf->debug_level = s->debug_level;
|
|
|
9ae3a8 |
s->glfs = qemu_gluster_init(gconf, filename, errp);
|
|
|
9ae3a8 |
if (!s->glfs) {
|
|
|
9ae3a8 |
ret = -errno;
|
|
|
9ae3a8 |
@@ -398,6 +415,7 @@ static int qemu_gluster_reopen_prepare(BDRVReopenState *state,
|
|
|
9ae3a8 |
BlockReopenQueue *queue, Error **errp)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
int ret = 0;
|
|
|
9ae3a8 |
+ BDRVGlusterState *s;
|
|
|
9ae3a8 |
BDRVGlusterReopenState *reop_s;
|
|
|
9ae3a8 |
GlusterConf *gconf = NULL;
|
|
|
9ae3a8 |
int open_flags = 0;
|
|
|
9ae3a8 |
@@ -405,6 +423,8 @@ static int qemu_gluster_reopen_prepare(BDRVReopenState *state,
|
|
|
9ae3a8 |
assert(state != NULL);
|
|
|
9ae3a8 |
assert(state->bs != NULL);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ s = state->bs->opaque;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
state->opaque = g_malloc0(sizeof(BDRVGlusterReopenState));
|
|
|
9ae3a8 |
reop_s = state->opaque;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -412,6 +432,7 @@ static int qemu_gluster_reopen_prepare(BDRVReopenState *state,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
gconf = g_malloc0(sizeof(GlusterConf));
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ gconf->debug_level = s->debug_level;
|
|
|
9ae3a8 |
reop_s->glfs = qemu_gluster_init(gconf, state->bs->filename, errp);
|
|
|
9ae3a8 |
if (reop_s->glfs == NULL) {
|
|
|
9ae3a8 |
ret = -errno;
|
|
|
9ae3a8 |
@@ -487,19 +508,28 @@ static int qemu_gluster_create(const char *filename,
|
|
|
9ae3a8 |
int64_t total_size = 0;
|
|
|
9ae3a8 |
GlusterConf *gconf = g_malloc0(sizeof(GlusterConf));
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- glfs = qemu_gluster_init(gconf, filename, errp);
|
|
|
9ae3a8 |
- if (!glfs) {
|
|
|
9ae3a8 |
- ret = -errno;
|
|
|
9ae3a8 |
- goto out;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
+ gconf->debug_level = GLUSTER_DEBUG_DEFAULT;
|
|
|
9ae3a8 |
while (options && options->name) {
|
|
|
9ae3a8 |
if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
|
|
|
9ae3a8 |
total_size = options->value.n / BDRV_SECTOR_SIZE;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
+ if (!strcmp(options->name, GLUSTER_OPT_DEBUG)) {
|
|
|
9ae3a8 |
+ gconf->debug_level = options->value.n;
|
|
|
9ae3a8 |
+ if (gconf->debug_level < 0) {
|
|
|
9ae3a8 |
+ gconf->debug_level = 0;
|
|
|
9ae3a8 |
+ } else if (gconf->debug_level > GLUSTER_DEBUG_MAX) {
|
|
|
9ae3a8 |
+ gconf->debug_level = GLUSTER_DEBUG_MAX;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
options++;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ glfs = qemu_gluster_init(gconf, filename, errp);
|
|
|
9ae3a8 |
+ if (!glfs) {
|
|
|
9ae3a8 |
+ ret = -errno;
|
|
|
9ae3a8 |
+ goto out;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
fd = glfs_creat(glfs, gconf->image,
|
|
|
9ae3a8 |
O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR);
|
|
|
9ae3a8 |
if (!fd) {
|
|
|
9ae3a8 |
@@ -732,6 +762,11 @@ static QEMUOptionParameter qemu_gluster_create_options[] = {
|
|
|
9ae3a8 |
.type = OPT_SIZE,
|
|
|
9ae3a8 |
.help = "Virtual disk size"
|
|
|
9ae3a8 |
},
|
|
|
9ae3a8 |
+ {
|
|
|
9ae3a8 |
+ .name = GLUSTER_OPT_DEBUG,
|
|
|
9ae3a8 |
+ .type = QEMU_OPT_NUMBER,
|
|
|
9ae3a8 |
+ .help = "Gluster log level, valid range is 0-9",
|
|
|
9ae3a8 |
+ },
|
|
|
9ae3a8 |
{ NULL }
|
|
|
9ae3a8 |
};
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|