@@ -94,6 +94,7 @@ typedef struct QemuOptDesc {
const char *name;
enum QemuOptType type;
const char *help;
+ const char *def_value_str;
} QemuOptDesc;
struct QemuOptsList {
@@ -150,7 +151,7 @@ QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict);
void qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp);
typedef int (*qemu_opts_loopfunc)(QemuOpts *opts, void *opaque);
-int qemu_opts_print(QemuOpts *opts, void *dummy);
+int qemu_opts_print(QemuOpts *opts);
int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque,
int abort_on_failure);
@@ -826,16 +826,36 @@ void qemu_opts_del(QemuOpts *opts)
g_free(opts);
}
-int qemu_opts_print(QemuOpts *opts, void *dummy)
+int qemu_opts_print(QemuOpts *opts)
{
QemuOpt *opt;
+ QemuOptDesc *desc = opts->list->desc;
- fprintf(stderr, "%s: %s:", opts->list->name,
- opts->id ? opts->id : "<noid>");
- QTAILQ_FOREACH(opt, &opts->head, next) {
- fprintf(stderr, " %s=\"%s\"", opt->name, opt->str);
+ if (desc[0].name == NULL) {
+ QTAILQ_FOREACH(opt, &opts->head, next) {
+ printf("%s=\"%s\" ", opt->name, opt->str);
+ }
+ return 0;
+ }
+ for (; desc && desc->name; desc++) {
+ const char *value = desc->def_value_str;
+ QemuOpt *opt;
+
+ opt = qemu_opt_find(opts, desc->name);
+ if (opt) {
+ value = opt->str;
+ }
+
+ if (!value) {
+ continue;
+ }
+
+ if (desc->type == QEMU_OPT_STRING) {
+ printf("%s='%s' ", desc->name, value);
+ } else {
+ printf("%s=%s ", desc->name, value);
+ }
}
- fprintf(stderr, "\n");
return 0;
}