qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH V2] block/nfs: add support for setting debug level


From: Peter Lieven
Subject: [Qemu-devel] [PATCH V2] block/nfs: add support for setting debug level
Date: Fri, 26 Jun 2015 13:06:09 +0200

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 <address@hidden>
---
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.
 
address@hidden 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):
address@hidden
+qemu-system-i386 -nfs debug=2 -cdrom nfs://127.0.0.1/isos/cdimage.iso
address@hidden 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]