All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: qemu-devel@nongnu.org
Cc: Peter Xu <peterx@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	"Dr . David Alan Gilbert" <dave@treblig.org>,
	Laurent Vivier <lvivier@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: [PATCH v2 11/18] migration: HMP: Fix bandwidth parameters
Date: Wed,  9 Sep 2026 18:45:01 -0300	[thread overview]
Message-ID: <20260909214509.237309-12-farosas@suse.de> (raw)
In-Reply-To: <20260909214509.237309-1-farosas@suse.de>

The max-bandwidth and avail-switchover-bandwidth parameters are
declared as bytes/second in migration.json and interpreted as such
throughout the code, except in HMP where they're expected to be
provided as mebibytes.

Fix the HMP code to parse the values as bytes.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
 migration/migration-hmp-cmds.c     | 23 +++--------------------
 tests/qtest/migration/misc-tests.c |  4 ++--
 2 files changed, 5 insertions(+), 22 deletions(-)

diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
index 27b38d0e5f..67ea2eea15 100644
--- a/migration/migration-hmp-cmds.c
+++ b/migration/migration-hmp-cmds.c
@@ -596,10 +596,9 @@ void hmp_migrate_set_parameter(MonitorHMP *hmp, const QDict *qdict)
     const char *valuestr = qdict_get_str(qdict, "value");
     Visitor *v = string_input_visitor_new(valuestr);
     MigrationParameters *p = g_new0(MigrationParameters, 1);
-    uint64_t valuebw = 0;
     uint64_t cache_size;
     Error *err = NULL;
-    int val, ret;
+    int val;
 
     val = qapi_enum_parse(&MigrationParameter_lookup, param, -1, &err);
     if (val < 0) {
@@ -644,27 +643,11 @@ void hmp_migrate_set_parameter(MonitorHMP *hmp, const QDict *qdict)
         break;
     case MIGRATION_PARAMETER_MAX_BANDWIDTH:
         p->has_max_bandwidth = true;
-        /*
-         * Can't use visit_type_size() here, because it
-         * defaults to Bytes rather than Mebibytes.
-         */
-        ret = qemu_strtosz_MiB(valuestr, NULL, &valuebw);
-        if (ret < 0 || valuebw > INT64_MAX
-            || (size_t)valuebw != valuebw) {
-            error_setg(&err, "Invalid size %s", valuestr);
-            break;
-        }
-        p->max_bandwidth = valuebw;
+        visit_type_size(v, param, &p->max_bandwidth, &err);
         break;
     case MIGRATION_PARAMETER_AVAIL_SWITCHOVER_BANDWIDTH:
         p->has_avail_switchover_bandwidth = true;
-        ret = qemu_strtosz_MiB(valuestr, NULL, &valuebw);
-        if (ret < 0 || valuebw > INT64_MAX
-            || (size_t)valuebw != valuebw) {
-            error_setg(&err, "Invalid size %s", valuestr);
-            break;
-        }
-        p->avail_switchover_bandwidth = valuebw;
+        visit_type_size(v, param, &p->avail_switchover_bandwidth, &err);
         break;
     case MIGRATION_PARAMETER_DOWNTIME_LIMIT:
         p->has_downtime_limit = true;
diff --git a/tests/qtest/migration/misc-tests.c b/tests/qtest/migration/misc-tests.c
index 04f46d5e81..447fa5e232 100644
--- a/tests/qtest/migration/misc-tests.c
+++ b/tests/qtest/migration/misc-tests.c
@@ -62,8 +62,8 @@ HMPTestData test_cases[] = {
     TEST("announce-rounds", "6", "6"),
     TEST("announce-step", "15", "15 ms"),
     TEST("downtime-limit", "400", "400 ms"),
-    TEST("avail-switchover-bandwidth", "2097152", "2199023255552 bytes/second"),
-    TEST("max-bandwidth", "9876543", "10356305952768 bytes/second"),
+    TEST("avail-switchover-bandwidth", "2097152", "2097152 bytes/second"),
+    TEST("max-bandwidth", "9876543", "9876543 bytes/second"),
     TEST("max-postcopy-bandwidth", "1048576", "1048576 bytes/second"),
     TEST("vcpu-dirty-limit", "20", "20 MB/s"),
     TEST("x-rdma-chunk-size", "1048576", "1048576 bytes"),
-- 
2.53.0



  parent reply	other threads:[~2026-09-09 21:46 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09 21:44 [PATCH v2 00/18] migration: MigrationParameters changes Fabiano Rosas
2026-09-09 21:44 ` [PATCH v2 01/18] checkpatch: Fix checking of newlines in error messages Fabiano Rosas
2026-09-09 21:44 ` [PATCH v2 02/18] migration/options.c: Don't export migrate_tls_opts_free Fabiano Rosas
2026-09-09 21:44 ` [PATCH v2 03/18] migration: Rename variables in qmp_migrate_set_parameters Fabiano Rosas
2026-09-09 21:44 ` [PATCH v2 04/18] migration: Use QAPI_CLONE_MEMBERS in migrate_params_apply Fabiano Rosas
2026-09-09 21:44 ` [PATCH v2 05/18] migration: Merge parameter structs instead of assigning one by one Fabiano Rosas
2026-09-10 12:28   ` Peter Xu
2026-09-09 21:44 ` [PATCH v2 06/18] migration: Open code migrate_params_apply Fabiano Rosas
2026-09-09 21:44 ` [PATCH v2 07/18] migration: Stop freeing s->parameters members individually Fabiano Rosas
2026-09-09 21:44 ` [PATCH v2 08/18] migration: Use migrate_params_free during finalize Fabiano Rosas
2026-09-09 21:44 ` [PATCH v2 09/18] tests/qtest/migration: Add a test for HMP Fabiano Rosas
2026-09-10 14:02   ` Peter Xu
2026-09-13 20:30   ` Dr. David Alan Gilbert
2026-09-09 21:45 ` [PATCH v2 10/18] tests/qtest/migration: Add a test for HMP completion Fabiano Rosas
2026-09-10 17:36   ` Peter Xu
2026-09-13 20:58   ` Dr. David Alan Gilbert
2026-09-09 21:45 ` Fabiano Rosas [this message]
2026-09-10  6:05   ` [PATCH v2 11/18] migration: HMP: Fix bandwidth parameters Markus Armbruster
2026-09-10 12:37     ` Fabiano Rosas
2026-09-11  6:19       ` Markus Armbruster
2026-09-10 13:20     ` Dr. David Alan Gilbert
2026-09-10 13:26   ` Dr. David Alan Gilbert
2026-09-10 17:38   ` Peter Xu
2026-09-09 21:45 ` [PATCH v2 12/18] migration: Change HMP 'info migrate_parameters' output Fabiano Rosas
2026-09-10  7:32   ` Markus Armbruster
2026-09-10 13:02     ` Fabiano Rosas
2026-09-11  6:46       ` Markus Armbruster
2026-09-09 21:45 ` [PATCH v2 13/18] migration: Use keyval input visitor in HMP set command Fabiano Rosas
2026-09-10 11:07   ` Markus Armbruster
2026-09-10 14:15     ` Fabiano Rosas
2026-09-10 22:10       ` Fabiano Rosas
2026-09-11  8:22         ` Markus Armbruster
2026-09-11 12:54           ` Fabiano Rosas
2026-09-11  8:12       ` Markus Armbruster
2026-09-09 21:45 ` [PATCH v2 14/18] migration: Use output visitor in info command Fabiano Rosas
2026-09-09 21:45 ` [PATCH v2 15/18] migration: Rewrite migrate_set_parameter_completion using QDict Fabiano Rosas
2026-09-10 11:17   ` Markus Armbruster
2026-09-10 13:09     ` Fabiano Rosas
2026-09-11  7:15       ` Markus Armbruster
2026-09-09 21:45 ` [PATCH v2 16/18] migration: Add capabilities into MigrationParameters Fabiano Rosas
2026-09-10 11:22   ` Markus Armbruster
2026-09-09 21:45 ` [PATCH v2 17/18] migration: Remove s->capabilities Fabiano Rosas
2026-09-09 21:45 ` [PATCH v2 18/18] qapi/migration: Deprecate capabilities commands Fabiano Rosas
2026-09-10 17:35 ` [PATCH v2 00/18] migration: MigrationParameters changes Peter Xu
2026-09-10 19:27   ` Fabiano Rosas

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=20260909214509.237309-12-farosas@suse.de \
    --to=farosas@suse.de \
    --cc=armbru@redhat.com \
    --cc=dave@treblig.org \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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.