All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: huangy81@chinatelecom.cn
Cc: qemu-devel <qemu-devel@nongnu.org>,  Peter Xu <peterx@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	 "Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	 Paolo Bonzini <pbonzini@redhat.com>,
	 Laurent Vivier <laurent@vivier.eu>,
	 Eric Blake <eblake@redhat.com>,
	 Juan Quintela <quintela@redhat.com>,
	 Thomas Huth <thuth@redhat.com>,
	 Peter Maydell <peter.maydell@linaro.org>,
	 Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [PATCH v2 02/11] softmmu/dirtylimit: Add parameter check for hmp "set_vcpu_dirty_limit"
Date: Sat, 03 Dec 2022 10:01:28 +0100	[thread overview]
Message-ID: <87bkokq2s7.fsf@pond.sub.org> (raw)
In-Reply-To: <56f207f3f962da7d90772cce1e724d50ba415d79.1669047366.git.huangy81@chinatelecom.cn> (huangy's message of "Mon, 21 Nov 2022 11:26:34 -0500")

huangy81@chinatelecom.cn writes:

> From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
>
> dirty_rate paraemter of hmp command "set_vcpu_dirty_limit" is invalid
> if less than 0, so add parameter check for it.
>
> Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
> ---
>  softmmu/dirtylimit.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/softmmu/dirtylimit.c b/softmmu/dirtylimit.c
> index 940d238..c42eddd 100644
> --- a/softmmu/dirtylimit.c
> +++ b/softmmu/dirtylimit.c
> @@ -515,6 +515,11 @@ void hmp_set_vcpu_dirty_limit(Monitor *mon, const QDict *qdict)
   void hmp_set_vcpu_dirty_limit(Monitor *mon, const QDict *qdict)
   {
       int64_t dirty_rate = qdict_get_int(qdict, "dirty_rate");
>      int64_t cpu_index = qdict_get_try_int(qdict, "cpu_index", -1);
>      Error *err = NULL;
>  
> +    if (dirty_rate < 0) {
> +        monitor_printf(mon, "invalid dirty page limit %ld\n", dirty_rate);

Here, you use monitor_printf() to report an error, and ...

> +        return;
> +    }
> +
>      qmp_set_vcpu_dirty_limit(!!(cpu_index != -1), cpu_index, dirty_rate, &err);
>      if (err) {
>          hmp_handle_error(mon, err);

... here you use hmp_handle_error().  Suggest to use the latter
consistently.

           return;
       }

       monitor_printf(mon, "[Please use 'info vcpu_dirty_limit' to query "
                      "dirty limit for virtual CPU]\n");

This prints unsolicited help how to read the setting every time you
change it.  We don't that.  Please delete.

   }

Together, the function could look like this:

void hmp_set_vcpu_dirty_limit(Monitor *mon, const QDict *qdict)
{
    int64_t dirty_rate = qdict_get_int(qdict, "dirty_rate");
    int64_t cpu_index = qdict_get_try_int(qdict, "cpu_index", -1);
    Error *err = NULL;

    if (dirty_rate < 0) {
        error_setg(&err, "invalid dirty page limit %ld", dirty_rate);
        goto out;
    }

    qmp_set_vcpu_dirty_limit(!!(cpu_index != -1), cpu_index, dirty_rate, &err);

out:
    hmp_handle_error(mon, err);
}



  parent reply	other threads:[~2022-12-03  9:02 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-21 16:26 [PATCH v2 00/11] migration: introduce dirtylimit capability huangy81
2022-11-21 16:26 ` [PATCH v2 01/11] dirtylimit: Fix overflow when computing MB huangy81
2022-11-29 23:17   ` Peter Xu
2022-12-03  8:56   ` Markus Armbruster
2022-11-21 16:26 ` [PATCH v2 02/11] softmmu/dirtylimit: Add parameter check for hmp "set_vcpu_dirty_limit" huangy81
2022-11-29 23:17   ` Peter Xu
2022-12-03  9:01   ` Markus Armbruster [this message]
2022-11-21 16:26 ` [PATCH v2 03/11] kvm-all: Do not allow reap vcpu dirty ring buffer if not ready huangy81
2022-11-29 22:42   ` Peter Xu
2022-11-30  3:11     ` Hyman Huang
2022-11-21 16:26 ` [PATCH v2 04/11] qapi/migration: Introduce x-vcpu-dirty-limit-period parameter huangy81
2022-11-29 22:49   ` Peter Xu
2022-12-03  9:06   ` Markus Armbruster
2022-12-03  9:11   ` Markus Armbruster
2022-11-21 16:26 ` [PATCH v2 05/11] qapi/migration: Introduce vcpu-dirty-limit parameters huangy81
2022-11-29 23:58   ` Peter Xu
2022-12-03  9:13   ` Markus Armbruster
2022-12-03  9:21     ` Markus Armbruster
2022-11-21 16:26 ` [PATCH v2 06/11] migration: Introduce dirty-limit capability huangy81
2022-11-29 23:58   ` Peter Xu
2022-12-03  9:24   ` Markus Armbruster
2022-11-21 16:26 ` [PATCH v2 07/11] migration: Implement dirty-limit convergence algo huangy81
2022-11-29 23:17   ` Peter Xu
2022-12-01  1:13     ` Hyman
2022-11-21 16:26 ` [PATCH v2 08/11] migration: Export dirty-limit time info huangy81
2022-11-30  0:09   ` Peter Xu
2022-12-01  2:09     ` Hyman
2022-12-03  9:14   ` Hyman
2022-12-03  9:42     ` Markus Armbruster
2022-12-03  9:28   ` Markus Armbruster
2022-11-21 16:26 ` [PATCH v2 09/11] tests: Add migration dirty-limit capability test huangy81
2022-11-21 16:26 ` [PATCH v2 10/11] tests/migration: Introduce dirty-ring-size option into guestperf huangy81
2022-11-21 16:26 ` [PATCH v2 11/11] tests/migration: Introduce dirty-limit " huangy81

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=87bkokq2s7.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=huangy81@chinatelecom.cn \
    --cc=laurent@vivier.eu \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.