* [Qemu-devel] [PATCH V2] block/nfs: add support for setting debug level
@ 2015-06-26 11:06 Peter Lieven
2015-06-29 16:10 ` Stefan Hajnoczi
0 siblings, 1 reply; 2+ messages in thread
From: Peter Lieven @ 2015-06-26 11:06 UTC (permalink / raw)
To: qemu-block, qemu-devel
Cc: kwolf, stefanha, jcody, Peter Lieven, ronniesahlberg
upcoming libnfs versions will support logging debug messages. Add
support for it in qemu through a cmdline parameter.
Example
qemu -nfs debug=99 -cdrom nfs://...
Signed-off-by: Peter Lieven <pl@kamp.de>
---
v1->v2: reworked patch to accept the debug level as a cmdline
parameter instead of an URI parameter [Stefan]
block/nfs.c | 40 ++++++++++++++++++++++++++++++++++++++++
qemu-options.hx | 21 +++++++++++++++++++++
vl.c | 8 ++++++++
3 files changed, 69 insertions(+)
diff --git a/block/nfs.c b/block/nfs.c
index ca9e24e..43d48ae 100644
--- a/block/nfs.c
+++ b/block/nfs.c
@@ -274,6 +274,30 @@ static void nfs_file_close(BlockDriverState *bs)
nfs_client_close(client);
}
+static void nfs_parse_options(NFSClient *client)
+{
+ QemuOptsList *list;
+ QemuOpts *opts;
+ const char *debug;
+
+ list = qemu_find_opts("nfs");
+ if (list) {
+ opts = QTAILQ_FIRST(&list->head);
+ if (opts) {
+ debug = qemu_opt_get(opts, "debug");
+ if (debug) {
+#ifdef LIBNFS_FEATURE_DEBUG
+ nfs_set_debug(client->context, atoi(debug));
+#else
+ error_report("NFS Warning: The linked version of libnfs does"
+ " not support setting debug levels");
+#endif
+ }
+ }
+ }
+}
+
+
static int64_t nfs_client_open(NFSClient *client, const char *filename,
int flags, Error **errp)
{
@@ -336,6 +360,8 @@ static int64_t nfs_client_open(NFSClient *client, const char *filename,
}
}
+ nfs_parse_options(client);
+
ret = nfs_mount(client->context, uri->server, uri->path);
if (ret < 0) {
error_setg(errp, "Failed to mount nfs share: %s",
@@ -501,9 +527,23 @@ static BlockDriver bdrv_nfs = {
.bdrv_attach_aio_context = nfs_attach_aio_context,
};
+static QemuOptsList qemu_nfs_opts = {
+ .name = "nfs",
+ .head = QTAILQ_HEAD_INITIALIZER(qemu_nfs_opts.head),
+ .desc = {
+ {
+ .name = "debug",
+ .type = QEMU_OPT_NUMBER,
+ .help = "Set libnfs debug level (default 0 = no debug)",
+ },
+ { /* end of list */ }
+ },
+};
+
static void nfs_block_init(void)
{
bdrv_register(&bdrv_nfs);
+ qemu_add_opts(&qemu_nfs_opts);
}
block_init(nfs_block_init);
diff --git a/qemu-options.hx b/qemu-options.hx
index 389cf64..63c60e7 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2329,6 +2329,26 @@ STEXI
iSCSI parameters such as username and password can also be specified via
a configuration file. See qemu-doc for more information and examples.
+@item NFS
+NFS support allows QEMU to access NFS shares directly and use as
+images for the guest storage. Both disk and cdrom images are supported.
+
+Syntax for specifying NFS shares is
+``nfs://<server-ip>/<export>/<filename>''
+
+Example (setting deubg level to 2 and use ISO from NFS share as CDROM):
+@example
+qemu-system-i386 -nfs debug=2 -cdrom nfs://127.0.0.1/isos/cdimage.iso
+@end example
+
+NFS support is an optional feature of QEMU and only available when
+compiled and linked against libnfs.
+ETEXI
+DEF("nfs", HAS_ARG, QEMU_OPTION_nfs,
+ "-nfs [debug=debug]\n"
+ " NFS connection parameters\n", QEMU_ARCH_ALL)
+STEXI
+
@item NBD
QEMU supports NBD (Network Block Devices) both using TCP protocol as well
as Unix Domain Sockets.
@@ -2480,6 +2500,7 @@ ETEXI
STEXI
@end table
ETEXI
+DEFHEADING()
DEFHEADING(Bluetooth(R) options:)
STEXI
diff --git a/vl.c b/vl.c
index 9542095..4317572 100644
--- a/vl.c
+++ b/vl.c
@@ -3141,6 +3141,14 @@ int main(int argc, char **argv, char **envp)
}
break;
#endif
+#ifdef CONFIG_LIBNFS
+ case QEMU_OPTION_nfs:
+ opts = qemu_opts_parse(qemu_find_opts("nfs"), optarg, 0);
+ if (!opts) {
+ exit(1);
+ }
+ break;
+#endif
#ifdef CONFIG_SLIRP
case QEMU_OPTION_tftp:
legacy_tftp_prefix = optarg;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH V2] block/nfs: add support for setting debug level
2015-06-26 11:06 [Qemu-devel] [PATCH V2] block/nfs: add support for setting debug level Peter Lieven
@ 2015-06-29 16:10 ` Stefan Hajnoczi
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2015-06-29 16:10 UTC (permalink / raw)
To: Peter Lieven; +Cc: kwolf, jcody, ronniesahlberg, qemu-devel, qemu-block
[-- Attachment #1: Type: text/plain, Size: 1461 bytes --]
On Fri, Jun 26, 2015 at 01:06:09PM +0200, Peter Lieven wrote:
> upcoming libnfs versions will support logging debug messages. Add
> support for it in qemu through a cmdline parameter.
>
> Example
> qemu -nfs debug=99 -cdrom nfs://...
>
> Signed-off-by: Peter Lieven <pl@kamp.de>
> ---
> v1->v2: reworked patch to accept the debug level as a cmdline
> parameter instead of an URI parameter [Stefan]
>
> block/nfs.c | 40 ++++++++++++++++++++++++++++++++++++++++
> qemu-options.hx | 21 +++++++++++++++++++++
> vl.c | 8 ++++++++
> 3 files changed, 69 insertions(+)
>
> diff --git a/block/nfs.c b/block/nfs.c
> index ca9e24e..43d48ae 100644
> --- a/block/nfs.c
> +++ b/block/nfs.c
> @@ -274,6 +274,30 @@ static void nfs_file_close(BlockDriverState *bs)
> nfs_client_close(client);
> }
>
> +static void nfs_parse_options(NFSClient *client)
> +{
> + QemuOptsList *list;
> + QemuOpts *opts;
> + const char *debug;
> +
> + list = qemu_find_opts("nfs");
> + if (list) {
> + opts = QTAILQ_FIRST(&list->head);
> + if (opts) {
> + debug = qemu_opt_get(opts, "debug");
> + if (debug) {
> +#ifdef LIBNFS_FEATURE_DEBUG
> + nfs_set_debug(client->context, atoi(debug));
This is a per-context API and there are already per-drive run-time
options.
Please use per-drive options instead of adding a global option.
Stefan
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-29 16:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-26 11:06 [Qemu-devel] [PATCH V2] block/nfs: add support for setting debug level Peter Lieven
2015-06-29 16:10 ` Stefan Hajnoczi
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).