return p;
}
-int get_next_param_value(char *buf, int buf_size,
- const char *tag, const char **pstr)
-{
- const char *p;
- char option[128];
-
- p = *pstr;
- for(;;) {
- p = get_opt_name(option, sizeof(option), p, '=');
- if (*p != '=')
- break;
- p++;
- if (!strcmp(tag, option)) {
- *pstr = get_opt_value(buf, buf_size, p);
- if (**pstr == ',') {
- (*pstr)++;
- }
- return strlen(buf);
- } else {
- p = get_opt_value(NULL, 0, p);
- }
- if (*p != ',')
- break;
- p++;
- }
- return 0;
-}
-
-int get_param_value(char *buf, int buf_size,
- const char *tag, const char *str)
-{
- return get_next_param_value(buf, buf_size, tag, &str);
-}
-
static void parse_option_bool(const char *name, const char *value, bool *ret,
Error **errp)
{
}
for (; desc && desc->name; desc++) {
const char *value;
- QemuOpt *opt = qemu_opt_find(opts, desc->name);
+ opt = qemu_opt_find(opts, desc->name);
value = opt ? opt->str : desc->def_value_str;
if (!value) {
static void qemu_opts_from_qdict_1(const char *key, QObject *obj, void *opaque)
{
OptsFromQDictState *state = opaque;
- char buf[32];
+ char buf[32], *tmp = NULL;
const char *value;
- int n;
if (!strcmp(key, "id") || *state->errp) {
return;
case QTYPE_QSTRING:
value = qstring_get_str(qobject_to_qstring(obj));
break;
- case QTYPE_QINT:
- n = snprintf(buf, sizeof(buf), "%" PRId64,
- qint_get_int(qobject_to_qint(obj)));
- assert(n < sizeof(buf));
- value = buf;
- break;
- case QTYPE_QFLOAT:
- n = snprintf(buf, sizeof(buf), "%.17g",
- qfloat_get_double(qobject_to_qfloat(obj)));
- assert(n < sizeof(buf));
- value = buf;
+ case QTYPE_QNUM:
+ tmp = qnum_to_string(qobject_to_qnum(obj));
+ value = tmp;
break;
case QTYPE_QBOOL:
pstrcpy(buf, sizeof(buf),
}
qemu_opt_set(state->opts, key, value, state->errp);
+ g_free(tmp);
}
/*
* Create QemuOpts from a QDict.
- * Use value of key "id" as ID if it exists and is a QString.
- * Only QStrings, QInts, QFloats and QBools are copied. Entries with
- * other types are silently ignored.
+ * Use value of key "id" as ID if it exists and is a QString. Only
+ * QStrings, QNums and QBools are copied. Entries with other types
+ * are silently ignored.
*/
QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict,
Error **errp)