From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
Peter Lieven <pl@kamp.de>, Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PULL for-2.4 3/7] block/nfs: add support for setting debug level
Date: Tue, 7 Jul 2015 13:08:20 +0100 [thread overview]
Message-ID: <1436270904-2855-4-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1436270904-2855-1-git-send-email-stefanha@redhat.com>
From: Peter Lieven <pl@kamp.de>
upcoming libnfs versions will support logging debug messages. Add
support for it in qemu through a per-drive option.
Examples:
qemu -drive if=virtio,file=nfs://...,file.debug=2
qemu-img create -o debug=2 nfs://... 10G
Signed-off-by: Peter Lieven <pl@kamp.de>
Reviewed-by: Fam Zheng <famz@redhat.com>
Message-id: 1436251847-16875-1-git-send-email-pl@kamp.de
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/nfs.c | 28 ++++++++++++++++++++++++----
qapi/block-core.json | 20 ++++++++++++++++----
2 files changed, 40 insertions(+), 8 deletions(-)
diff --git a/block/nfs.c b/block/nfs.c
index c026ff6..72a4247 100644
--- a/block/nfs.c
+++ b/block/nfs.c
@@ -233,6 +233,11 @@ static QemuOptsList runtime_opts = {
.type = QEMU_OPT_STRING,
.help = "URL to the NFS file",
},
+ {
+ .name = "debug",
+ .type = QEMU_OPT_NUMBER,
+ .help = "Set libnfs debug level (default 0 = no debug)",
+ },
{ /* end of list */ }
},
};
@@ -277,9 +282,9 @@ static void nfs_file_close(BlockDriverState *bs)
}
static int64_t nfs_client_open(NFSClient *client, const char *filename,
- int flags, Error **errp)
+ int flags, QemuOpts *opts, Error **errp)
{
- int ret = -EINVAL, i;
+ int ret = -EINVAL, i, debug;
struct stat st;
URI *uri;
QueryParams *qp = NULL;
@@ -343,6 +348,16 @@ static int64_t nfs_client_open(NFSClient *client, const char *filename,
}
}
+ debug = qemu_opt_get_number(opts, "debug", 0);
+ if (debug) {
+#ifdef LIBNFS_FEATURE_DEBUG
+ nfs_set_debug(client->context, debug);
+#else
+ error_report("NFS Warning: The linked version of libnfs does"
+ " not support setting debug levels");
+#endif
+ }
+
ret = nfs_mount(client->context, uri->server, uri->path);
if (ret < 0) {
error_setg(errp, "Failed to mount nfs share: %s",
@@ -405,7 +420,7 @@ static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags,
}
ret = nfs_client_open(client, qemu_opt_get(opts, "filename"),
(flags & BDRV_O_RDWR) ? O_RDWR : O_RDONLY,
- errp);
+ opts, errp);
if (ret < 0) {
goto out;
}
@@ -425,6 +440,11 @@ static QemuOptsList nfs_create_opts = {
.type = QEMU_OPT_SIZE,
.help = "Virtual disk size"
},
+ {
+ .name = "debug",
+ .type = QEMU_OPT_NUMBER,
+ .help = "Set libnfs debug level (default 0 = no debug)",
+ },
{ /* end of list */ }
}
};
@@ -441,7 +461,7 @@ static int nfs_file_create(const char *url, QemuOpts *opts, Error **errp)
total_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
BDRV_SECTOR_SIZE);
- ret = nfs_client_open(client, url, O_CREAT, errp);
+ ret = nfs_client_open(client, url, O_CREAT, opts, errp);
if (ret < 0) {
goto out;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 7b2efb8..f43a1b1 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1381,9 +1381,9 @@
{ 'enum': 'BlockdevDriver',
'data': [ 'archipelago', 'blkdebug', 'blkverify', 'bochs', 'cloop',
'dmg', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device',
- 'host_floppy', 'http', 'https', 'null-aio', 'null-co', 'parallels',
- 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'tftp', 'vdi', 'vhdx',
- 'vmdk', 'vpc', 'vvfat' ] }
+ 'host_floppy', 'http', 'https', 'nfs', 'null-aio', 'null-co',
+ 'parallels', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'tftp',
+ 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] }
##
# @BlockdevOptionsBase
@@ -1635,6 +1635,18 @@
'*vport': 'int',
'*segment': 'str' } }
+##
+# @BlockdevOptionsNFS
+#
+# Driver specific block device options for NFS.
+#
+# @debug: #optional set libnfs debug level (default: 0 = disabled)
+#
+# Since: 2.4
+##
+{ 'struct': 'BlockdevOptionsNFS',
+ 'base': 'BlockdevOptionsFile',
+ 'data': { '*debug': 'int' } }
##
# @BlkdebugEvent
@@ -1816,7 +1828,7 @@
'https': 'BlockdevOptionsFile',
# TODO iscsi: Wait for structured options
# TODO nbd: Should take InetSocketAddress for 'host'?
-# TODO nfs: Wait for structured options
+ 'nfs': 'BlockdevOptionsNFS',
'null-aio': 'BlockdevOptionsNull',
'null-co': 'BlockdevOptionsNull',
'parallels': 'BlockdevOptionsGenericFormat',
--
2.4.3
next prev parent reply other threads:[~2015-07-07 12:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-07 12:08 [Qemu-devel] [PULL for-2.4 0/7] Block patches Stefan Hajnoczi
2015-07-07 12:08 ` [Qemu-devel] [PULL for-2.4 1/7] qcow2: remove unnecessary check Stefan Hajnoczi
2015-07-07 12:08 ` [Qemu-devel] [PULL for-2.4 2/7] block: update bdrv_drain_all()/bdrv_drain() comments Stefan Hajnoczi
2015-07-07 12:08 ` Stefan Hajnoczi [this message]
2015-07-07 12:50 ` [Qemu-devel] [PULL for-2.4 3/7] block/nfs: add support for setting debug level Peter Lieven
2015-07-07 13:13 ` Stefan Hajnoczi
2015-07-07 13:40 ` Kevin Wolf
2015-07-08 17:48 ` Max Reitz
2015-07-07 13:24 ` Stefan Hajnoczi
2015-07-07 13:41 ` Peter Lieven
2015-07-07 13:45 ` Kevin Wolf
2015-07-21 22:38 ` Eric Blake
2015-07-21 22:37 ` Eric Blake
2015-07-07 12:08 ` [Qemu-devel] [PULL for-2.4 4/7] block: Initialize local_err in bdrv_append_temp_snapshot Stefan Hajnoczi
2015-07-07 12:08 ` [Qemu-devel] [PULL for-2.4 5/7] block: Use bdrv_drain to replace uncessary bdrv_drain_all Stefan Hajnoczi
2015-07-07 12:08 ` [Qemu-devel] [PULL for-2.4 6/7] block/raw-posix: Don't think /dev/fd/<NN> is a floppy drive Stefan Hajnoczi
2015-07-07 12:08 ` [Qemu-devel] [PULL for-2.4 7/7] blockjob: add block_job_release function Stefan Hajnoczi
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=1436270904-2855-4-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=kwolf@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=pl@kamp.de \
--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).