提交 fccfb11e 编写于 作者: M Markus Armbruster 提交者: Anthony Liguori

monitor: New argument type 'T'

This is a double value with optional suffixes ms, us, ns.  We'll need
this to get migrate_set_downtime() QMP-ready.
Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 5fd9083c
...@@ -75,6 +75,9 @@ ...@@ -75,6 +75,9 @@
* user mode accepts an optional G, g, M, m, K, k suffix, * user mode accepts an optional G, g, M, m, K, k suffix,
* which multiplies the value by 2^30 for suffixes G and * which multiplies the value by 2^30 for suffixes G and
* g, 2^20 for M and m, 2^10 for K and k * g, 2^20 for M and m, 2^10 for K and k
* 'T' double
* user mode accepts an optional ms, us, ns suffix,
* which divides the value by 1e3, 1e6, 1e9, respectively
* '/' optional gdb-like print format (like "/10x") * '/' optional gdb-like print format (like "/10x")
* *
* '?' optional type (for all types, except '/') * '?' optional type (for all types, except '/')
...@@ -3662,6 +3665,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, ...@@ -3662,6 +3665,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
} }
break; break;
case 'b': case 'b':
case 'T':
{ {
double val; double val;
...@@ -3676,7 +3680,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, ...@@ -3676,7 +3680,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
if (get_double(mon, &val, &p) < 0) { if (get_double(mon, &val, &p) < 0) {
goto fail; goto fail;
} }
if (*p) { if (c == 'b' && *p) {
switch (*p) { switch (*p) {
case 'K': case 'k': case 'K': case 'k':
val *= 1 << 10; p++; break; val *= 1 << 10; p++; break;
...@@ -3686,6 +3690,16 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, ...@@ -3686,6 +3690,16 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
val *= 1 << 30; p++; break; val *= 1 << 30; p++; break;
} }
} }
if (c == 'T' && p[0] && p[1] == 's') {
switch (*p) {
case 'm':
val /= 1e3; p += 2; break;
case 'u':
val /= 1e6; p += 2; break;
case 'n':
val /= 1e9; p += 2; break;
}
}
if (*p && !qemu_isspace(*p)) { if (*p && !qemu_isspace(*p)) {
monitor_printf(mon, "Unknown unit suffix\n"); monitor_printf(mon, "Unknown unit suffix\n");
goto fail; goto fail;
...@@ -4119,6 +4133,7 @@ static int check_arg(const CmdArgs *cmd_args, QDict *args) ...@@ -4119,6 +4133,7 @@ static int check_arg(const CmdArgs *cmd_args, QDict *args)
} }
break; break;
case 'b': case 'b':
case 'T':
if (qobject_type(value) != QTYPE_QINT && qobject_type(value) != QTYPE_QFLOAT) { if (qobject_type(value) != QTYPE_QINT && qobject_type(value) != QTYPE_QFLOAT) {
qemu_error_new(QERR_INVALID_PARAMETER_TYPE, name, "number"); qemu_error_new(QERR_INVALID_PARAMETER_TYPE, name, "number");
return -1; return -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册