block/nfs: add support for setting debug level
PATCH v4 1/1 block/nfs: add support for setting debug level
recent libnfs versions support logging debug messages. Add support for it in qemu through an URL parameter.
Example:
qemu -cdrom nfs://127.0.0.1/iso/my.iso?debug=2
---v3->v4: revert to the initial version, but limit max debug level v2->v3: use a per-drive option instead of a global one. [Stefan] v1->v2: reworked patch to accept the debug level as a cmdline
parameter instead of an URI parameter [Stefan]
block/nfs.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
block/nfs.c +10 -0
@@ -36,6 +36,7 @@#include <nfsc/libnfs.h> #define QEMU_NFS_MAX_READAHEAD_SIZE 1048576 +#define QEMU_NFS_MAX_DEBUG_LEVEL 2 typedef struct NFSClient { struct nfs_context *context;
@@ -334,6 +335,15 @@ static int64_t nfs_client_open(NFSClient *client, const char *filename, }nfs_set_readahead (client->context, val);#endif +#ifdef LIBNFS_FEATURE_DEBUG + }else if (!strcmp (qp->p[i].name,"debug" )) { +if (val >QEMU_NFS_MAX_DEBUG_LEVEL ) { +error_report ("NFS Warning: Limiting NFS debug level" +" to %d" ,QEMU_NFS_MAX_DEBUG_LEVEL ); + val =QEMU_NFS_MAX_DEBUG_LEVEL ; + } +nfs_set_debug (client->context, val); +#endif }else {error_setg (errp,"Unknown NFS parameter name: %s" , qp->p[i].name);
Signature · 1 line
1.7.9.5
Quoted 29 lines · Peter Lieven
recent libnfs versions support logging debug messages. Add support for it in qemu through an URL parameter.
Example:
qemu -cdrom nfs://127.0.0.1/iso/my.iso?debug=2
---v3->v4: revert to the initial version, but limit max debug levelv2->v3: use a per-drive option instead of a global one. [Stefan]v1->v2: reworked patch to accept the debug level as a cmdline
parameter instead of an URI parameter [Stefan]block/nfs.c | 10 ++++++++++ 1 file changed, 10 insertions(+)block/nfs.c +1
-0@@ -36,6 +36,7 @@#include <nfsc/libnfs.h> #define QEMU_NFS_MAX_READAHEAD_SIZE 1048576 +#define QEMU_NFS_MAX_DEBUG_LEVEL 2 typedef struct NFSClient { struct nfs_context *context;@@ -334,6 +335,15 @@ static int64_t nfs_client_open(NFSClient *client, const char *filename, }nfs_set_readahead (client->context, val);
block/nfs.c static int64_t nfs_client_open(NFSClient *client, const char *filename, · line 346
Quoted 10 lines
block/nfs.c +9
-0#endif +#ifdef LIBNFS_FEATURE_DEBUG + }else if (!strcmp (qp->p[i].name,"debug" )) { +if (val >QEMU_NFS_MAX_DEBUG_LEVEL ) { +error_report ("NFS Warning: Limiting NFS debug level" +" to %d" ,QEMU_NFS_MAX_DEBUG_LEVEL ); + val =QEMU_NFS_MAX_DEBUG_LEVEL ; + } +nfs_set_debug (client->context, val); +#endif
Please include the rationale for limiting the debug level as a comment in the code. Otherwise people may read the code and not understand why we do this.
The error message should indicate how to set high debug levels (if possible). A simple "You can't do that" error message is frustrating :).
Am 06.11.2015 um 12:23 schrieb Stefan Hajnoczi:
Quoted 35 lines · Peter Lieven
Quoted 34 lines
recent libnfs versions support logging debug messages. Add support for it in qemu through an URL parameter.
Example:
qemu -cdrom nfs://127.0.0.1/iso/my.iso?debug=2
---v3->v4: revert to the initial version, but limit max debug levelv2->v3: use a per-drive option instead of a global one. [Stefan]v1->v2: reworked patch to accept the debug level as a cmdline
parameter instead of an URI parameter [Stefan]block/nfs.c | 10 ++++++++++ 1 file changed, 10 insertions(+)block/nfs.c +5
-0@@ -36,6 +36,7 @@#include <nfsc/libnfs.h> #define QEMU_NFS_MAX_READAHEAD_SIZE 1048576 +#define QEMU_NFS_MAX_DEBUG_LEVEL 2 typedef struct NFSClient { struct nfs_context *context;@@ -334,6 +335,15 @@ static int64_t nfs_client_open(NFSClient *client, const char *filename, }nfs_set_readahead (client->context, val);#endif +#ifdef LIBNFS_FEATURE_DEBUG + }else if (!strcmp (qp->p[i].name,"debug" )) { +if (val >QEMU_NFS_MAX_DEBUG_LEVEL ) { + error_report("NFS Warning: Limiting NFS debug level"
Quoted 8 lines
block/nfs.c static int64_t nfs_client_open(NFSClient *client, const char *filename, · line 346
Quoted 5 lines
block/nfs.c +5
-0+ " to %d", QEMU_NFS_MAX_DEBUG_LEVEL); + val = QEMU_NFS_MAX_DEBUG_LEVEL; + } +nfs_set_debug (client->context, val); +#endif Please include the rationale for limiting the debug level as a comment in the code. Otherwise people may read the code and not understand why we do this.
Okay. Then we should add this to the readahead limitation as well.
Quoted 4 lines
The error message should indicate how to set high debug levels (if possible). A simple "You can't do that" error message is frustrating :).
But thats the case at the moment ;-)
Peter