block/nfs: add support for setting debug level
PATCH v2 1/1 block/nfs: add support for setting debug level
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://...
---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(+)
block/nfs.c +40 -0
@@ -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);
qemu-options.hx +21 -0
@@ -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
vl.c +8 -0
@@ -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;
Signature · 1 line
1.7.9.5
Quoted 28 lines · Peter Lieven
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 <[email protected]>---
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(+)block/nfs.c +4
-0@@ -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;
block/nfs.c static void nfs_file_close(BlockDriverState *bs) · line 290
Quoted 10 lines
block/nfs.c +10
-0+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