提交 ec7b2ccb 编写于 作者: L Luiz Capitulino

qemu-option: parse_option_size(): use error_set()

Signed-off-by: NLuiz Capitulino <lcapitulino@redhat.com>
Reviewed-By: NLaszlo Ersek <lersek@redhat.com>
上级 cf62adfa
...@@ -203,7 +203,8 @@ static void parse_option_number(const char *name, const char *value, ...@@ -203,7 +203,8 @@ static void parse_option_number(const char *name, const char *value,
} }
} }
static int parse_option_size(const char *name, const char *value, uint64_t *ret) static void parse_option_size(const char *name, const char *value,
uint64_t *ret, Error **errp)
{ {
char *postfix; char *postfix;
double sizef; double sizef;
...@@ -229,16 +230,14 @@ static int parse_option_size(const char *name, const char *value, uint64_t *ret) ...@@ -229,16 +230,14 @@ static int parse_option_size(const char *name, const char *value, uint64_t *ret)
*ret = (uint64_t) sizef; *ret = (uint64_t) sizef;
break; break;
default: default:
qerror_report(QERR_INVALID_PARAMETER_VALUE, name, "a size"); error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size");
error_printf_unless_qmp("You may use k, M, G or T suffixes for " error_printf_unless_qmp("You may use k, M, G or T suffixes for "
"kilobytes, megabytes, gigabytes and terabytes.\n"); "kilobytes, megabytes, gigabytes and terabytes.\n");
return -1; return;
} }
} else { } else {
qerror_report(QERR_INVALID_PARAMETER_VALUE, name, "a size"); error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size");
return -1;
} }
return 0;
} }
/* /*
...@@ -290,8 +289,7 @@ int set_option_parameter(QEMUOptionParameter *list, const char *name, ...@@ -290,8 +289,7 @@ int set_option_parameter(QEMUOptionParameter *list, const char *name,
break; break;
case OPT_SIZE: case OPT_SIZE:
if (parse_option_size(name, value, &list->value.n) == -1) parse_option_size(name, value, &list->value.n, &local_err);
return -1;
break; break;
default: default:
...@@ -602,7 +600,8 @@ static int qemu_opt_parse(QemuOpt *opt) ...@@ -602,7 +600,8 @@ static int qemu_opt_parse(QemuOpt *opt)
&local_err); &local_err);
break; break;
case QEMU_OPT_SIZE: case QEMU_OPT_SIZE:
return parse_option_size(opt->name, opt->str, &opt->value.uint); parse_option_size(opt->name, opt->str, &opt->value.uint, &local_err);
break;
default: default:
abort(); abort();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册