qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Peter Lieven <pl@kamp.de>
Cc: kwolf@redhat.com, qemu-block@nongnu.org, stefanha@gmail.com,
	qemu-devel@nongnu.org, mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH V5] block/nfs: add support for setting debug level
Date: Tue, 10 Nov 2015 10:50:50 +0800	[thread overview]
Message-ID: <20151110025050.GB15410@ad.usersys.redhat.com> (raw)
In-Reply-To: <1447052973-14513-1-git-send-email-pl@kamp.de>

On Mon, 11/09 08:09, Peter Lieven wrote:
> 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
> 
> Signed-off-by: Peter Lieven <pl@kamp.de>
> ---
> v4->v5: add a comment in the code why we limit the debug level [Stefan]
> 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 | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/block/nfs.c b/block/nfs.c
> index fd79f89..ab1e267 100644
> --- a/block/nfs.c
> +++ b/block/nfs.c
> @@ -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,17 @@ 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")) {
> +            /* limit the maximum debug level to avoid potential flooding
> +             * of our log files. */
> +            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

It would be slightly nicer to do:

        } else if (!strcmp(qp->p[i].name, "debug")) {
#ifdef LIBNFS_FEATURE_DEBUG
            /* limit the maximum debug level to avoid potential flooding
             * of our log files. */
            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);
#else
            error_report("Specifying debug level is only supported by libnfs"
                         " version >= XXX");
#endif

So that you know which one out of QEMU and libnfs to upgrade when the option is
refused. :)

But it's your call. Either way:

Reviewed-by: Fam Zheng <famz@redhat.com>

>          } else {
>              error_setg(errp, "Unknown NFS parameter name: %s",
>                         qp->p[i].name);
> -- 
> 1.9.1
> 

  reply	other threads:[~2015-11-10  2:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-09  7:09 [Qemu-devel] [PATCH V5] block/nfs: add support for setting debug level Peter Lieven
2015-11-10  2:50 ` Fam Zheng [this message]
2015-11-13  9:45 ` Stefan Hajnoczi
2015-11-13  9:52   ` Peter Lieven
2015-11-16  3:25     ` Stefan Hajnoczi
2015-11-16 16:27       ` John Snow
2015-11-13 18:19   ` [Qemu-devel] [Qemu-block] " Jeff Cody
2015-11-16  3:26     ` Stefan Hajnoczi
2016-01-11  8:51   ` [Qemu-devel] " Peter Lieven
2016-01-11 10:47     ` [Qemu-devel] [Qemu-block] " Jeff Cody

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=20151110025050.GB15410@ad.usersys.redhat.com \
    --to=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pl@kamp.de \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /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).