提交 f4a06d13 编写于 作者: J Juan Quintela

hmp: Use visitor api for hmp_migrate_set_parameter()

We only use it for int64 at this point, I am not able to find a way to
parse an int with MiB units.
Signed-off-by: NJuan Quintela <quintela@redhat.com>
Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
上级 5d214a92
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "monitor/qdev.h" #include "monitor/qdev.h"
#include "qapi/opts-visitor.h" #include "qapi/opts-visitor.h"
#include "qapi/qmp/qerror.h" #include "qapi/qmp/qerror.h"
#include "qapi/string-input-visitor.h"
#include "qapi/string-output-visitor.h" #include "qapi/string-output-visitor.h"
#include "qapi/util.h" #include "qapi/util.h"
#include "qapi-visit.h" #include "qapi-visit.h"
...@@ -1524,8 +1525,9 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) ...@@ -1524,8 +1525,9 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
{ {
const char *param = qdict_get_str(qdict, "parameter"); const char *param = qdict_get_str(qdict, "parameter");
const char *valuestr = qdict_get_str(qdict, "value"); const char *valuestr = qdict_get_str(qdict, "value");
Visitor *v = string_input_visitor_new(valuestr);
uint64_t valuebw = 0; uint64_t valuebw = 0;
long valueint = 0; int64_t valueint = 0;
Error *err = NULL; Error *err = NULL;
bool use_int_value = false; bool use_int_value = false;
int i, ret; int i, ret;
...@@ -1583,9 +1585,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) ...@@ -1583,9 +1585,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
} }
if (use_int_value) { if (use_int_value) {
if (qemu_strtol(valuestr, NULL, 10, &valueint) < 0) { visit_type_int(v, param, &valueint, &err);
error_setg(&err, "Unable to parse '%s' as an int", if (err) {
valuestr);
goto cleanup; goto cleanup;
} }
/* Set all integers; only one has_FOO will be set, and /* Set all integers; only one has_FOO will be set, and
...@@ -1609,6 +1610,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) ...@@ -1609,6 +1610,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
} }
cleanup: cleanup:
visit_free(v);
if (err) { if (err) {
error_report_err(err); error_report_err(err);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册