[PATCH 00/25] qemu-option, keyval, vl: switch -object/-M/-accel to keyval parsing

Paolo Bonzini posted 25 patches 3 years, 2 months ago
Test checkpatch failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20210118163113.780171-1-pbonzini@redhat.com
Maintainers: Markus Armbruster <armbru@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Eric Blake <eblake@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>
accel/accel.c                        |   6 +
block/blkdebug.c                     |   3 +-
docs/system/deprecated.rst           |   6 +
hmp-commands.hx                      |   6 +-
include/block/qdict.h                |   2 -
include/qapi/qmp/qdict.h             |   3 +
include/qemu/config-file.h           |   9 +-
include/qemu/help_option.h           |  11 -
include/qemu/option.h                |   6 +-
include/qom/object.h                 |  21 +
include/qom/object_interfaces.h      |  68 +--
include/sysemu/accel.h               |   1 +
monitor/hmp-cmds.c                   |  22 +-
monitor/hmp.c                        |  20 +-
qemu-img.c                           | 258 +++-------
qemu-io.c                            |  42 +-
qemu-nbd.c                           |  42 +-
qemu-options.hx                      |  13 +-
qom/object_interfaces.c              | 152 ++----
softmmu/vl.c                         | 673 ++++++++++++++-------------
storage-daemon/qemu-storage-daemon.c |  10 -
tests/check-qom-proplist.c           |  58 ++-
tests/test-keyval.c                  |  58 ++-
tests/test-qemu-opts.c               |  37 +-
util/keyval.c                        | 231 +++++----
util/qemu-config.c                   | 141 +++---
util/qemu-option.c                   | 126 +++--
27 files changed, 918 insertions(+), 1107 deletions(-)
[PATCH 00/25] qemu-option, keyval, vl: switch -object/-M/-accel to keyval parsing
Posted by Paolo Bonzini 3 years, 2 months ago
This series switches -object, -M and -accel from QemuOpts to keyval.
Monitor commands device_add and netdev_add are also switched to keyval,
though -device and -netdev for now are not.

Along the way, the syntax of keyval and QemuOpts becomes more consistent
and support for keyval-based options is added to -readconfig.  -writeconfig
instead is removed (see patch 13 for rationale).

The reason to do this is:

- to make qemu-io, qemu-nbd, qemu-img and QEMU's parsing of -object
  consistent with qemu-storage-daemon's

- to allow using compound properties in -object, -M and -accel

Patch 1-3: make QemuOpts parsing a bit more restrictive, warning for
short-form boolean options and removing weird ways to request help
such as "help=foo" or "no?".

Patch 4-10: let keyval accept escaped commas in implied options,
switch comma-separated syntax for HMP from QemuOpts to keyval,
add help support to object_add

Patch 11-16: plumbing for reading keyval-based options in vl.c,
including -set and -readconfig.  The patches up to this point are
the ones that I'd like to get a relatively fast review, since the
remaining nine are more "boring".

Patch 17-21: switch -object to keyval everywhere

Patch 22-25: switch -M and -accel to keyval

Based-on: <20210118162537.779542-1-pbonzini@redhat.com>

Paolo Bonzini (25):
  qemu-option: clean up id vs. list->merge_lists
  qemu-option: move help handling to get_opt_name_value
  qemu-option: warn for short-form boolean options
  keyval: accept escaped commas in implied option
  keyval: simplify keyval_parse_one
  tests: convert check-qom-proplist to keyval
  keyval: introduce keyval_parse_into
  hmp: replace "O" parser with keyval
  qom: use qemu_printf to print help for user-creatable objects
  hmp: special case help options for object_add
  remove -writeconfig
  qemu-config: add error propagation to qemu_config_parse
  qemu-option: support accept-any QemuOptsList in qemu_opts_absorb_qdict
  qemu-config: parse configuration files to a QDict
  vl: plumb keyval-based options into -set and -readconfig
  qom: do not modify QDict argument in user_creatable_add_dict
  qemu-io: use keyval for -object parsing
  qemu-nbd: use keyval for -object parsing
  qemu-img: use keyval for -object parsing
  qemu: use keyval for -object parsing
  storage-daemon: do not register the "object" group with QemuOpts
  qom: export more functions for use with non-UserCreatable objects
  vl: switch -M parsing to keyval
  qemu-option: remove now-dead code
  vl: switch -accel parsing to keyval

 accel/accel.c                        |   6 +
 block/blkdebug.c                     |   3 +-
 docs/system/deprecated.rst           |   6 +
 hmp-commands.hx                      |   6 +-
 include/block/qdict.h                |   2 -
 include/qapi/qmp/qdict.h             |   3 +
 include/qemu/config-file.h           |   9 +-
 include/qemu/help_option.h           |  11 -
 include/qemu/option.h                |   6 +-
 include/qom/object.h                 |  21 +
 include/qom/object_interfaces.h      |  68 +--
 include/sysemu/accel.h               |   1 +
 monitor/hmp-cmds.c                   |  22 +-
 monitor/hmp.c                        |  20 +-
 qemu-img.c                           | 258 +++-------
 qemu-io.c                            |  42 +-
 qemu-nbd.c                           |  42 +-
 qemu-options.hx                      |  13 +-
 qom/object_interfaces.c              | 152 ++----
 softmmu/vl.c                         | 673 ++++++++++++++-------------
 storage-daemon/qemu-storage-daemon.c |  10 -
 tests/check-qom-proplist.c           |  58 ++-
 tests/test-keyval.c                  |  58 ++-
 tests/test-qemu-opts.c               |  37 +-
 util/keyval.c                        | 231 +++++----
 util/qemu-config.c                   | 141 +++---
 util/qemu-option.c                   | 126 +++--
 27 files changed, 918 insertions(+), 1107 deletions(-)

-- 
2.26.2


Re: [PATCH 00/25] qemu-option, keyval, vl: switch -object/-M/-accel to keyval parsing
Posted by no-reply@patchew.org 3 years, 2 months ago
Patchew URL: https://patchew.org/QEMU/20210118163113.780171-1-pbonzini@redhat.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20210118163113.780171-1-pbonzini@redhat.com
Subject: [PATCH 00/25] qemu-option, keyval, vl: switch -object/-M/-accel to keyval parsing

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]         patchew/20210118163113.780171-1-pbonzini@redhat.com -> patchew/20210118163113.780171-1-pbonzini@redhat.com
Switched to a new branch 'test'
ec26fa4 vl: switch -accel parsing to keyval
b9750c0 qemu-option: remove now-dead code
0ec053d vl: switch -M parsing to keyval
2bfede0 qom: export more functions for use with non-UserCreatable objects
2c8420d storage-daemon: do not register the "object" group with QemuOpts
6072877 qemu: use keyval for -object parsing
d597674 qemu-img: use keyval for -object parsing
4bf11fa qemu-nbd: use keyval for -object parsing
85a5e5a qemu-io: use keyval for -object parsing
9a44901 qom: do not modify QDict argument in user_creatable_add_dict
193c6a2 vl: plumb keyval-based options into -set and -readconfig
31579e0 qemu-config: parse configuration files to a QDict
bc20068 qemu-option: support accept-any QemuOptsList in qemu_opts_absorb_qdict
ca390c3 qemu-config: add error propagation to qemu_config_parse
59b951f remove -writeconfig
fa45a78 hmp: special case help options for object_add
2561b79 qom: use qemu_printf to print help for user-creatable objects
0cab5f9 hmp: replace "O" parser with keyval
bd6519f keyval: introduce keyval_parse_into
d3fc628 tests: convert check-qom-proplist to keyval
437fd40 keyval: simplify keyval_parse_one
ffc5547 keyval: accept escaped commas in implied option
8a251bf qemu-option: warn for short-form boolean options
c2d9889 qemu-option: move help handling to get_opt_name_value
e067ad6 qemu-option: clean up id vs. list->merge_lists

=== OUTPUT BEGIN ===
1/25 Checking commit e067ad67f18f (qemu-option: clean up id vs. list->merge_lists)
2/25 Checking commit c2d98893d095 (qemu-option: move help handling to get_opt_name_value)
3/25 Checking commit 8a251bf52737 (qemu-option: warn for short-form boolean options)
WARNING: line over 80 characters
#82: FILE: util/qemu-option.c:787:
+                warn_report("short-form boolean option '%s%s' deprecated", prefix, *name);

WARNING: line over 80 characters
#101: FILE: util/qemu-option.c:818:
+        p = get_opt_name_value(p, firstname, warn_on_flag, help_wanted, &option, &value);

total: 0 errors, 2 warnings, 127 lines checked

Patch 3/25 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
4/25 Checking commit ffc55478b1cb (keyval: accept escaped commas in implied option)
5/25 Checking commit 437fd4000b35 (keyval: simplify keyval_parse_one)
6/25 Checking commit d3fc62875f6a (tests: convert check-qom-proplist to keyval)
7/25 Checking commit bd6519ffd2d1 (keyval: introduce keyval_parse_into)
WARNING: line over 80 characters
#25: FILE: include/qemu/option.h:150:
+QDict *keyval_parse_into(QDict *qdict, const char *params, const char *implied_key,

WARNING: line over 80 characters
#44: FILE: util/keyval.c:442:
+QDict *keyval_parse_into(QDict *qdict, const char *params, const char *implied_key,

total: 0 errors, 2 warnings, 75 lines checked

Patch 7/25 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
8/25 Checking commit 0cab5f97ab3d (hmp: replace "O" parser with keyval)
9/25 Checking commit 2561b79c783e (qom: use qemu_printf to print help for user-creatable objects)
10/25 Checking commit fa45a78a9d8f (hmp: special case help options for object_add)
11/25 Checking commit 59b951f9b110 (remove -writeconfig)
12/25 Checking commit ca390c3ae7df (qemu-config: add error propagation to qemu_config_parse)
WARNING: line over 80 characters
#43: FILE: include/qemu/config-file.h:13:
+int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname, Error **errp);

WARNING: line over 80 characters
#119: FILE: util/qemu-config.c:311:
+int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname, Error **errp)

total: 0 errors, 2 warnings, 141 lines checked

Patch 12/25 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
13/25 Checking commit bc2006827446 (qemu-option: support accept-any QemuOptsList in qemu_opts_absorb_qdict)
14/25 Checking commit 31579e030854 (qemu-config: parse configuration files to a QDict)
WARNING: line over 80 characters
#28: FILE: include/qemu/config-file.h:4:
+typedef void QEMUConfigCB(const char *group, QDict *qdict, void *opaque, Error **errp);

WARNING: line over 80 characters
#38: FILE: include/qemu/config-file.h:17:
+void qemu_config_do_parse(const char *group, QDict *qdict, void *opaque, Error **errp);

WARNING: line over 80 characters
#62: FILE: softmmu/vl.c:3316:
+                qemu_read_config_file(optarg, qemu_config_do_parse, &error_fatal);

WARNING: line over 80 characters
#170: FILE: util/qemu-config.c:384:
+void qemu_config_do_parse(const char *group, QDict *qdict, void *opaque, Error **errp)

WARNING: line over 80 characters
#192: FILE: util/qemu-config.c:406:
+int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname, Error **errp)

total: 0 errors, 5 warnings, 170 lines checked

Patch 14/25 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
15/25 Checking commit 193c6a2cb171 (vl: plumb keyval-based options into -set and -readconfig)
WARNING: line over 80 characters
#115: FILE: softmmu/vl.c:2095:
+static void qemu_record_config_group(const char *group, QDict *dict, Error **errp)

WARNING: line over 80 characters
#127: FILE: softmmu/vl.c:2107:
+static void qemu_set_qdict_option(QDict *dict, const char *key, const char *value,

WARNING: line over 80 characters
#152: FILE: softmmu/vl.c:2132:
+            error_setg(errp, "Lists cannot be at top level of a configuration section");

WARNING: line over 80 characters
#250: FILE: softmmu/vl.c:3405:
+                qemu_read_config_file(optarg, qemu_parse_config_group, &error_fatal);

ERROR: line over 90 characters
#268: FILE: tests/test-keyval.c:746:
+    QDict *combined = keyval_parse("opt1=ABC,opt2.sub1=def,opt2.sub2=GHI,opt2.sub3=JKL,opt3=xyz",

WARNING: line over 80 characters
#318: FILE: util/keyval.c:319:
+static void keyval_do_merge(QDict *old, const QDict *new, GString *str, Error **errp)

WARNING: line over 80 characters
#327: FILE: util/keyval.c:328:
+            error_setg(errp, "Parameter '%s%s' used inconsistently", str->str, ent->key);

total: 1 errors, 6 warnings, 293 lines checked

Patch 15/25 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

16/25 Checking commit 9a449013c568 (qom: do not modify QDict argument in user_creatable_add_dict)
17/25 Checking commit 85a5e5a4aeee (qemu-io: use keyval for -object parsing)
18/25 Checking commit 4bf11facae8c (qemu-nbd: use keyval for -object parsing)
19/25 Checking commit d597674d23d7 (qemu-img: use keyval for -object parsing)
20/25 Checking commit 6072877b6226 (qemu: use keyval for -object parsing)
ERROR: do not initialise statics to 0 or NULL
#211: FILE: softmmu/vl.c:139:
+static GSList *object_opts_list = NULL;

WARNING: line over 80 characters
#346: FILE: softmmu/vl.c:3471:
+                    args = keyval_parse(optarg, "qom-type", &help, &error_fatal);

total: 1 errors, 1 warnings, 324 lines checked

Patch 20/25 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

21/25 Checking commit 2c8420d34e62 (storage-daemon: do not register the "object" group with QemuOpts)
22/25 Checking commit 2bfede05a80b (qom: export more functions for use with non-UserCreatable objects)
ERROR: code indent should never use tabs
#45: FILE: include/qom/object.h:882:
+^I^I^I^I       Error **errp);$

total: 1 errors, 0 warnings, 108 lines checked

Patch 22/25 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

23/25 Checking commit 0ec053de9e5e (vl: switch -M parsing to keyval)
WARNING: line over 80 characters
#187: FILE: softmmu/vl.c:1558:
+            error_setg(&local_err, "No machine specified, and there is no default");

WARNING: line over 80 characters
#200: FILE: softmmu/vl.c:1564:
+        error_append_hint(&local_err, "Use -machine help to list supported machines\n");

WARNING: line over 80 characters
#237: FILE: softmmu/vl.c:1605:
+            error_setg(errp, "Conflict between '%s' and '%s'", ent->key, new_key);

WARNING: line over 80 characters
#277: FILE: softmmu/vl.c:1629:
+        object_register_sugar_prop(ACCEL_CLASS_NAME("xen"), "igd-passthru", value);

WARNING: line over 80 characters
#283: FILE: softmmu/vl.c:1635:
+        object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), "kvm-shadow-mem", value);

WARNING: line over 80 characters
#289: FILE: softmmu/vl.c:1641:
+        object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), "kernel-irqchip", value);

WARNING: line over 80 characters
#290: FILE: softmmu/vl.c:1642:
+        object_register_sugar_prop(ACCEL_CLASS_NAME("whpx"), "kernel-irqchip", value);

WARNING: line over 80 characters
#311: FILE: softmmu/vl.c:1709:
+    object_set_properties_from_keyval(OBJECT(current_machine), qdict, &error_fatal);

ERROR: line over 90 characters
#323: FILE: softmmu/vl.c:1739:
+        semihosting_arg_fallback(current_machine->kernel_filename, current_machine->kernel_cmdline);

ERROR: line over 90 characters
#365: FILE: softmmu/vl.c:2015:
+        object_set_properties_from_keyval(OBJECT(current_machine), default_opts, &error_abort);

ERROR: line over 90 characters
#493: FILE: softmmu/vl.c:3202:
+                    keyval_parse_into(machine_opts_dict, optarg, "type", &help, &error_fatal);

total: 3 errors, 8 warnings, 523 lines checked

Patch 23/25 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

24/25 Checking commit b9750c0ad970 (qemu-option: remove now-dead code)
25/25 Checking commit ec26fa447263 (vl: switch -accel parsing to keyval)
WARNING: line over 80 characters
#29: FILE: accel/accel.c:51:
+    g_autofree char *class_name = g_strdup_printf(ACCEL_CLASS_NAME("%s"), opt_name);

ERROR: do not initialise statics to 0 or NULL
#56: FILE: softmmu/vl.c:142:
+static GSList *accel_opts_list = NULL;

WARNING: line over 80 characters
#172: FILE: softmmu/vl.c:2198:
+            error_report("failed to initialize %s: %s", ac->name, strerror(-ret));

total: 1 errors, 2 warnings, 257 lines checked

Patch 25/25 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20210118163113.780171-1-pbonzini@redhat.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com