qapi/qom: QAPIfy --object and object-add
v2 cover qapi/qom: QAPIfy --object and object-add
This series adds a QAPI type for the properties of all user creatable QOM types and finally makes the --object command line option (in all binaries) and the object-add monitor commands (in QMP and HMP) use the new ObjectOptions union.
This change improves things in more than just one way:
1. Documentation for QOM object types has always been lacking. Adding the schema, we get documentation for every property.
2. It prevents bugs by performing parts of the input validation (e.g. checking presence of mandatory properties) already in QAPI instead of relying on separate manual implementations in each class.
3. It provides QAPI introspection for user creatable objects.
4. Non-scalar properties are now supported everywhere because the command line parsers (including HMP) use the keyval parser now.
If you are in the CC list and didn't expect this series, it's probably because you're the maintainer of one of the objects for which I'm adding a QAPI schema description. Please just have a look at the specific patch for your object and check whether the schema and its documentation make sense to you. You can ignore all other patches.
In a next step after this series, we can add make use of the QAPI structs in the implementation of the object and separate their configuration from the runtime state. Specifically, the plan is to add a .configure() callback to ObjectClass that allows configuring the object in one place at creation time and keeping QOM property setters only for properties that can actually be changed at runtime. Paolo made an example of what the state could look like after this:
https://wiki.qemu.org/Features/QOM-QAPI_integration
Finally, the intention is to extend the QAPI schema to have separate 'object' entities and generate some of the code that was written manually in the intermediate state before.
This series is available as a git tag at:
https://repo.or.cz/qemu/kevin.git qapi-object-v2
v2:
- Convert not only object-add, but all external interfaces so that the schema will always be enforced and mismatch between implementation and schema can't go unnoticed.
- Rebased, covering properties and object types added since v1 (yes, things do become outdated rather quickly when you touch all user creatable objects)
- Changed the "Since:" version number in the schema documentation to refer to the version when the object was introduced rather than 6.0 where the schema will (hopefully) be added
- Probably some other minor changes
Kevin Wolf (31):
tests: Drop 'props' from object-add calls
qapi/qom: Drop deprecated 'props' from object-add qapi/qom: Add ObjectOptions for iothread
qapi/qom: Add ObjectOptions for authz-*
qapi/qom: Add ObjectOptions for cryptodev-* qapi/qom: Add ObjectOptions for dbus-vmstate qapi/qom: Add ObjectOptions for memory-backend-* qapi/qom: Add ObjectOptions for rng-*, deprecate 'opened' qapi/qom: Add ObjectOptions for throttle-group qapi/qom: Add ObjectOptions for secret*, deprecate 'loaded' qapi/qom: Add ObjectOptions for tls-*, deprecate 'loaded' qapi/qom: Add ObjectOptions for can-*
qapi/qom: Add ObjectOptions for colo-compare qapi/qom: Add ObjectOptions for filter-*
qapi/qom: Add ObjectOptions for pr-manager-helper qapi/qom: Add ObjectOptions for confidential-guest-support qapi/qom: Add ObjectOptions for input-*
qapi/qom: Add ObjectOptions for x-remote-object qapi/qom: QAPIfy object-add
qom: Make "object" QemuOptsList optional
qemu-storage-daemon: Implement --object with qmp_object_add()
qom: Remove user_creatable_add_dict()
qom: Factor out user_creatable_process_cmdline()
qemu-io: Use user_creatable_process_cmdline() for --object
qemu-img: Use user_creatable_process_cmdline() for --object
qemu-nbd: Use user_creatable_process_cmdline() for --object
qom: Add user_creatable_add_from_str()
hmp: QAPIfy object_add
qom: Add user_creatable_parse_str()
vl: QAPIfy -object
qom: Drop QemuOpts based interfaces
qapi/authz.json | 62 +++ qapi/block-core.json | 27 ++ qapi/common.json | 52 +++ qapi/crypto.json | 159 +++++++ qapi/machine.json | 22 +- qapi/net.json | 20 - qapi/qom.json | 639 ++++++++++++++++++++++++++- qapi/ui.json | 13 +- docs/system/deprecated.rst | 25 +- docs/system/removed-features.rst | 5 + include/qom/object_interfaces.h | 106 ++--- hw/block/xen-block.c | 16 +- monitor/hmp-cmds.c | 17 +- monitor/misc.c | 2 - qemu-img.c | 239 ++-------- qemu-io.c | 33 +- qemu-nbd.c | 34 +- qom/object_interfaces.c | 168 +++---- qom/qom-qmp-cmds.c | 28 +- softmmu/vl.c | 109 +++-- storage-daemon/qemu-storage-daemon.c | 25 +- tests/check-qom-proplist.c | 42 +- tests/qtest/qmp-cmd-test.c | 16 +- tests/qtest/test-netfilter.c | 54 +-- hmp-commands.hx | 2 +- storage-daemon/qapi/qapi-schema.json | 1 + tests/qemu-iotests/087 | 8 +- tests/qemu-iotests/184 | 18 +- tests/qemu-iotests/218 | 2 +- tests/qemu-iotests/235 | 2 +- tests/qemu-iotests/245 | 4 +- tests/qemu-iotests/258 | 6 +- tests/qemu-iotests/258.out | 4 +- tests/qemu-iotests/295 | 2 +- tests/qemu-iotests/296 | 2 +- 35 files changed, 1270 insertions(+), 694 deletions(-)
Signature · 1 line
2.29.2
PATCH v2 1/31 tests: Drop 'props' from object-add calls
The 'props' option has been deprecated in 5.0 in favour of a flattened object-add command. Time to change our test cases to drop the deprecated option.
--- tests/qtest/qmp-cmd-test.c | 16 +++++------ tests/qtest/test-netfilter.c | 54 ++++++++++++++++-------------------- tests/qemu-iotests/087 | 8 ++---- tests/qemu-iotests/184 | 18 ++++-------- tests/qemu-iotests/218 | 2 +- tests/qemu-iotests/235 | 2 +- tests/qemu-iotests/245 | 4 +-- tests/qemu-iotests/258 | 6 ++-- tests/qemu-iotests/258.out | 4 +-- tests/qemu-iotests/295 | 2 +- tests/qemu-iotests/296 | 2 +- 11 files changed, 51 insertions(+), 67 deletions(-)
tests/qtest/qmp-cmd-test.c +8 -8
@@ -230,14 +230,14 @@ static void test_object_add_failure_modes(void)/* attempt to create 2 objects with duplicate id */ resp =qtest_qmp (qts,"{'execute': 'object-add', 'arguments':" " {'qom-type': 'memory-backend-ram', 'id': 'ram1'," -" 'props': {'size': 1048576 } } }" ); +" 'size': 1048576 } }" );g_assert_nonnull (resp);g_assert (qdict_haskey (resp,"return" ));qobject_unref (resp); resp =qtest_qmp (qts,"{'execute': 'object-add', 'arguments':" " {'qom-type': 'memory-backend-ram', 'id': 'ram1'," -" 'props': {'size': 1048576 } } }" ); +" 'size': 1048576 } }" );g_assert_nonnull (resp);qmp_expect_error_and_unref (resp,"GenericError" );
@@ -251,14 +251,14 @@ static void test_object_add_failure_modes(void)/* attempt to create an object with a property of a wrong type */ resp =qtest_qmp (qts,"{'execute': 'object-add', 'arguments':" " {'qom-type': 'memory-backend-ram', 'id': 'ram1'," -" 'props': {'size': '1048576' } } }" ); +" 'size': '1048576' } }" );g_assert_nonnull (resp);/* now do it right */ qmp_expect_error_and_unref (resp,"GenericError" ); resp =qtest_qmp (qts,"{'execute': 'object-add', 'arguments':" " {'qom-type': 'memory-backend-ram', 'id': 'ram1'," -" 'props': {'size': 1048576 } } }" ); +" 'size': 1048576 } }" );g_assert_nonnull (resp);g_assert (qdict_haskey (resp,"return" ));qobject_unref (resp);
@@ -273,14 +273,14 @@ static void test_object_add_failure_modes(void)/* attempt to create an object without the id */ resp =qtest_qmp (qts,"{'execute': 'object-add', 'arguments':" " {'qom-type': 'memory-backend-ram'," -" 'props': {'size': 1048576 } } }" ); +" 'size': 1048576 } }" );g_assert_nonnull (resp);qmp_expect_error_and_unref (resp,"GenericError" );/* now do it right */ resp =qtest_qmp (qts,"{'execute': 'object-add', 'arguments':" " {'qom-type': 'memory-backend-ram', 'id': 'ram1'," -" 'props': {'size': 1048576 } } }" ); +" 'size': 1048576 } }" );g_assert_nonnull (resp);g_assert (qdict_haskey (resp,"return" ));qobject_unref (resp);
@@ -295,14 +295,14 @@ static void test_object_add_failure_modes(void)/* attempt to set a non existing property */ resp =qtest_qmp (qts,"{'execute': 'object-add', 'arguments':" " {'qom-type': 'memory-backend-ram', 'id': 'ram1'," -" 'props': {'sized': 1048576 } } }" ); +" 'sized': 1048576 } }" );g_assert_nonnull (resp);qmp_expect_error_and_unref (resp,"GenericError" );/* now do it right */ resp =qtest_qmp (qts,"{'execute': 'object-add', 'arguments':" " {'qom-type': 'memory-backend-ram', 'id': 'ram1'," -" 'props': {'size': 1048576 } } }" ); +" 'size': 1048576 } }" );g_assert_nonnull (resp);g_assert (qdict_haskey (resp,"return" ));qobject_unref (resp);
tests/qtest/test-netfilter.c +24 -30
90 lines not on this page · raw message
tests/qemu-iotests/087 +2 -6
@@ -143,9 +143,7 @@ run_qemu <<EOF "arguments": { "qom-type": "secret", "id": "sec0", - "props": { - "data": "123456" - } + "data": "123456" } } { "execute": "blockdev-add",
@@ -176,9 +174,7 @@ run_qemu <<EOF "arguments": { "qom-type": "secret", "id": "sec0", - "props": { - "data": "123456" - } + "data": "123456" } } { "execute": "blockdev-add",
tests/qemu-iotests/184 +6 -12
@@ -67,10 +67,8 @@ run_qemu <<EOF "arguments": { "qom-type": "throttle-group", "id": "group0", - "props": { - "limits" : { - "iops-total": 1000 - } + "limits" : { + "iops-total": 1000 } } }
@@ -96,10 +94,8 @@ run_qemu <<EOF "arguments": { "qom-type": "throttle-group", "id": "group0", - "props" : { - "limits": { - "iops-total": 1000 - } + "limits": { + "iops-total": 1000 } } }
@@ -136,10 +132,8 @@ run_qemu <<EOF "arguments": { "qom-type": "throttle-group", "id": "group0", - "props" : { - "limits": { - "iops-total": 1000 - } + "limits": { + "iops-total": 1000 } } }
tests/qemu-iotests/218 +1 -1
@@ -152,7 +152,7 @@ with iotests.VM() as vm, \ vm.launch() ret = vm.qmp('object-add', qom_type='throttle-group', id='tg', - props={'x-bps-read': 4096}) + limits={'bps-read': 4096}) assert ret['return'] == {} ret = vm.qmp('blockdev-add',
tests/qemu-iotests/235 +1 -1
@@ -57,7 +57,7 @@ vm.add_args('-drive', 'id=src,file=' + disk) vm.launch() log(vm.qmp('object-add', qom_type='throttle-group', id='tg0', - props={ 'x-bps-total': size })) + limits={ 'bps-total': size })) log(vm.qmp('blockdev-add', **{ 'node-name': 'target',
tests/qemu-iotests/245 +2 -2
@@ -644,12 +644,12 @@ class TestBlockdevReopen(iotests.QMPTestCase): ###### throttle ###### ###################### opts = { 'qom-type': 'throttle-group', 'id': 'group0', - 'props': { 'limits': { 'iops-total': 1000 } } } + 'limits': { 'iops-total': 1000 } } result = self.vm.qmp('object-add', conv_keys = False, **opts) self.assert_qmp(result, 'return', {}) opts = { 'qom-type': 'throttle-group', 'id': 'group1', - 'props': { 'limits': { 'iops-total': 2000 } } } + 'limits': { 'iops-total': 2000 } } result = self.vm.qmp('object-add', conv_keys = False, **opts) self.assert_qmp(result, 'return', {})
tests/qemu-iotests/258 +3 -3
@@ -103,9 +103,9 @@ def test_concurrent_finish(write_to_stream_node): vm.qmp_log('object-add', qom_type='throttle-group', id='tg', - props={ - 'x-iops-write': 1, - 'x-iops-write-max': 1 + limits={ + 'iops-write': 1, + 'iops-write-max': 1 }) vm.qmp_log('blockdev-add',
tests/qemu-iotests/258.out +2 -2
@@ -2,7 +2,7 @@ Running tests: === Commit and stream finish concurrently (letting stream write) === -{"execute": "object-add", "arguments": {"id": "tg", "props": {"x-iops-write": 1, "x-iops-write-max": 1}, "qom-type": "throttle-group"}} +{"execute": "object-add", "arguments": {"id": "tg", "limits": {"iops-write": 1, "iops-write-max": 1}, "qom-type": "throttle-group"}} {"return": {}} {"execute": "blockdev-add", "arguments": {"backing": {"backing": {"backing": {"backing": {"driver": "raw", "file": {"driver": "file", "filename": "TEST_DIR/PID-node0.img"}, "node-name": "node0"}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/PID-node1.img"}, "node-name": "node1"}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/PID-node2.img"}, "node-name": "node2"}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/PID-node3.img"}, "node-name": "node3"}, "driver": "IMGFMT", "file": {"driver": "throttle", "file": {"driver": "file", "filename": "TEST_DIR/PID-node4.img"}, "throttle-group": "tg"}, "node-name": "node4"}} {"return": {}}
@@ -18,7 +18,7 @@ Running tests: === Commit and stream finish concurrently (letting commit write) === -{"execute": "object-add", "arguments": {"id": "tg", "props": {"x-iops-write": 1, "x-iops-write-max": 1}, "qom-type": "throttle-group"}} +{"execute": "object-add", "arguments": {"id": "tg", "limits": {"iops-write": 1, "iops-write-max": 1}, "qom-type": "throttle-group"}} {"return": {}} {"execute": "blockdev-add", "arguments": {"backing": {"backing": {"backing": {"backing": {"driver": "raw", "file": {"driver": "throttle", "file": {"driver": "file", "filename": "TEST_DIR/PID-node0.img"}, "throttle-group": "tg"}, "node-name": "node0"}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/PID-node1.img"}, "node-name": "node1"}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/PID-node2.img"}, "node-name": "node2"}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/PID-node3.img"}, "node-name": "node3"}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/PID-node4.img"}, "node-name": "node4"}} {"return": {}}
tests/qemu-iotests/295 +1 -1
@@ -43,7 +43,7 @@ class Secret: def to_qmp_object(self): return { "qom_type" : "secret", "id": self.id(), - "props": { "data": self.secret() } } + "data": self.secret() } ################################################################################ class EncryptionSetupTestCase(iotests.QMPTestCase):
tests/qemu-iotests/296 +1 -1
@@ -43,7 +43,7 @@ class Secret: def to_qmp_object(self): return { "qom_type" : "secret", "id": self.id(), - "props": { "data": self.secret() } } + "data": self.secret() } ################################################################################
Signature · 1 line
2.29.2
Re: [PATCH v2 01/31] tests: Drop 'props' from object-add calls
Quoted 6 lines · Kevin Wolf
The 'props' option has been deprecated in 5.0 in favour of a flattened object-add command. Time to change our test cases to drop the deprecated option.
Signed-off-by Kevin Wolf <[email protected]>---
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 2/31 qapi/qom: Drop deprecated 'props' from object-add
In reply to Kevin WolfThe option has been deprecated in QEMU 5.0, remove it.
--- qapi/qom.json | 6 +----- docs/system/deprecated.rst | 5 ----- docs/system/removed-features.rst | 5 +++++ qom/qom-qmp-cmds.c | 21 --------------------- 4 files changed, 6 insertions(+), 31 deletions(-)
qapi/qom.json +1 -5
@@ -211,10 +211,6 @@ # # @id: the name of the new object # -# @props: a dictionary of properties to be passed to the backend. Deprecated -# since 5.0, specify the properties on the top level instead. It is an -# error to specify the same option both on the top level and in @props. -# # Additional arguments depend on qom-type and are passed to the backend # unchanged. #
@@ -232,7 +228,7 @@ # ## { 'command': 'object-add', - 'data': {'qom-type': 'str', 'id': 'str', '*props': 'any'}, + 'data': {'qom-type': 'str', 'id': 'str'}, 'gen': false } # so we can get the additional arguments ##
docs/system/deprecated.rst +0 -5
@@ -199,11 +199,6 @@ Use ``migrate-set-parameters`` and ``query-migrate-parameters`` instead. Use arguments ``base-node`` and ``top-node`` instead. -``object-add`` option ``props`` (since 5.0) -''''''''''''''''''''''''''''''''''''''''''' - -Specify the properties for the object as top-level arguments instead. - ``query-named-block-nodes`` and ``query-block`` result dirty-bitmaps[i].status (since 4.0) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
docs/system/removed-features.rst +5 -0
@@ -58,6 +58,11 @@ documentation of ``query-hotpluggable-cpus`` for additional details. Use ``blockdev-change-medium`` or ``change-vnc-password`` instead. +``object-add`` option ``props`` (removed in 6.0) +'''''''''''''''''''''''''''''''''''''''''''''''' + +Specify the properties for the object as top-level arguments instead. + Human Monitor Protocol (HMP) commands -------------------------------------
qom/qom-qmp-cmds.c +0 -21
@@ -225,27 +225,6 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename,void qmp_object_add (QDict *qdict,QObject **ret_data,Error **errp) { -QObject *props; -QDict *pdict; - - props =qdict_get (qdict,"props" ); -if (props) { - pdict =qobject_to (QDict, props); -if (!pdict) { -error_setg (errp,QERR_INVALID_PARAMETER_TYPE ,"props" ,"dict" ); -return ; - } -qobject_ref (pdict); -qdict_del (qdict,"props" ); -qdict_join (qdict, pdict, false); -if (qdict_size (pdict) !=0 ) { -error_setg (errp,"Option in 'props' conflicts with top level" ); -qobject_unref (pdict); -return ; - } -qobject_unref (pdict); - } -user_creatable_add_dict (qdict, false, errp); }
Signature · 1 line
2.29.2
Re: [PATCH v2 02/31] qapi/qom: Drop deprecated 'props' from object-add
Quoted 10 lines · Kevin Wolf
The option has been deprecated in QEMU 5.0, remove it.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/qom.json | 6 +----- docs/system/deprecated.rst | 5 ----- docs/system/removed-features.rst | 5 +++++ qom/qom-qmp-cmds.c | 21 --------------------- 4 files changed, 6 insertions(+), 31 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 3/31 qapi/qom: Add ObjectOptions for iothread
In reply to Kevin WolfAdd an ObjectOptions union that will eventually describe the options of all user creatable object types. As unions can't exist without any branches, also add the first object type.
This adds a QAPI schema for the properties of the iothread object.
--- qapi/qom.json | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)
qapi/qom.json +53 -0
@@ -202,6 +202,59 @@ 'returns': [ 'ObjectPropertyInfo' ], 'allow-preconfig': true } +## +# @IothreadProperties: +# +# Properties for iothread objects. +# +# @poll-max-ns: the maximum number of nanoseconds to busy wait for events. +# 0 means polling is disabled (default: 32768 on POSIX hosts, +# 0 otherwise) +# +# @poll-grow: the multiplier used to increase the polling time when the +# algorithm detects it is missing events due to not polling long +# enough. 0 selects a default behaviour (default: 0) +# +# @poll-shrink: the divisor used to decrease the polling time when the +# algorithm detects it is spending too long polling without +# encountering events. 0 selects a default behaviour (default: 0) +# +# Since: 2.0 +## +{ 'struct': 'IothreadProperties', + 'data': { '*poll-max-ns': 'int', + '*poll-grow': 'int', + '*poll-shrink': 'int' } } + +## +# @ObjectType: +# +# Since: 6.0 +## +{ 'enum': 'ObjectType', + 'data': [ + 'iothread' + ] } + +## +# @ObjectOptions: +# +# Describes the options of a user creatable QOM object. +# +# @qom-type: the class name for the object to be created +# +# @id: the name of the new object +# +# Since: 6.0 +## +{ 'union': 'ObjectOptions', + 'base': { 'qom-type': 'ObjectType', + 'id': 'str' }, + 'discriminator': 'qom-type', + 'data': { + 'iothread': 'IothreadProperties' + } } + ## # @object-add: #
Signature · 1 line
2.29.2
Re: [PATCH v2 03/31] qapi/qom: Add ObjectOptions for iothread
Quoted 25 lines · Kevin Wolf
Add an ObjectOptions union that will eventually describe the options of all user creatable object types. As unions can't exist without any branches, also add the first object type.
This adds a QAPI schema for the properties of the iothread object.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/qom.json | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)qapi/qom.json +6
-0@@ -202,6 +202,59 @@ 'returns': [ 'ObjectPropertyInfo' ], 'allow-preconfig': true } +## +# @IothreadProperties: +# +# Properties for iothread objects. +# +# @poll-max-ns: the maximum number of nanoseconds to busy wait for events.
qapi/qom.json line 220
Quoted 10 lines
qapi/qom.json +10
-0+# 0 means polling is disabled (default: 32768 on POSIX hosts, +# 0 otherwise) +# +# @poll-grow: the multiplier used to increase the polling time when the +# algorithm detects it is missing events due to not polling long +# enough. 0 selects a default behaviour (default: 0) +# +# @poll-shrink: the divisor used to decrease the polling time when the +# algorithm detects it is spending too long polling without +# encountering events. 0 selects a default behaviour (default: 0)
Matches PollParamInfo declarations in iothread.c.
qapi/qom.json line 222
Quoted 2 lines
qapi/qom.json +2
-0+# +# Since: 2.0
How did you determine this value? (I'm not questioning it being something other than 6.0, because we have indeed supported QMP configuration of these values via the untyped magic previously present in add-object).
qapi/qom.json line 227
Quoted 5 lines
qapi/qom.json +5
-0+## +{ 'struct': 'IothreadProperties', + 'data': { '*poll-max-ns': 'int', + '*poll-grow': 'int', + '*poll-shrink': 'int' } }
These are correctly typed per the code in iothread.c, but it does raise the question of whether a signed 64-bit value is the best choice, or if we might later want to revisit things to pick more constrained types. I don't think such an audit should hold up this series, though.
qapi/qom.json line 237
Quoted 10 lines
qapi/qom.json +10
-0+ +## +# @ObjectType: +# +# Since: 6.0 +## +{ 'enum': 'ObjectType', + 'data': [ + 'iothread' + ] }
Will be fun to watch this grow over the series.
Quoted 14 lines
qapi/qom.json +13
-0+ +## +# @ObjectOptions: +# +# Describes the options of a user creatable QOM object. +# +# @qom-type: the class name for the object to be created +# +# @id: the name of the new object +# +# Since: 6.0 +## +{ 'union': 'ObjectOptions',
qapi/qom.json line 260
Quoted 10 lines
qapi/qom.json +7
-0+ 'base': { 'qom-type': 'ObjectType', + 'id': 'str' }, + 'discriminator': 'qom-type', + 'data': { + 'iothread': 'IothreadProperties' + } } + ## # @object-add: #
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH v2 03/31] qapi/qom: Add ObjectOptions for iothread
Am 25.02.2021 um 23:55 hat Eric Blake geschrieben:
Quoted 39 lines · Kevin Wolf
Quoted 25 lines
Add an ObjectOptions union that will eventually describe the options of all user creatable object types. As unions can't exist without any branches, also add the first object type.
This adds a QAPI schema for the properties of the iothread object.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/qom.json | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)qapi/qom.json +6
-0@@ -202,6 +202,59 @@ 'returns': [ 'ObjectPropertyInfo' ], 'allow-preconfig': true } +## +# @IothreadProperties: +# +# Properties for iothread objects. +# +# @poll-max-ns: the maximum number of nanoseconds to busy wait for events.qapi/qom.json line 220
Quoted 10 lines
qapi/qom.json +10
-0+# 0 means polling is disabled (default: 32768 on POSIX hosts, +# 0 otherwise) +# +# @poll-grow: the multiplier used to increase the polling time when the +# algorithm detects it is missing events due to not polling long +# enough. 0 selects a default behaviour (default: 0) +# +# @poll-shrink: the divisor used to decrease the polling time when the +# algorithm detects it is spending too long polling without +# encountering events. 0 selects a default behaviour (default: 0)Matches PollParamInfo declarations in
iothread.c.
Quoted 7 lines
qapi/qom.json line 222
Quoted 2 lines
qapi/qom.json +2
-0+# +# Since: 2.0How did you determine this value? (I'm not questioning it being something other than 6.0, because we have indeed supported QMP configuration of these values via the untyped magic previously present in add-object).
I had 6.0 in v1 of the series, but Paolo requested that I make it the version when the object was introduced (which is arguably the more useful information to provice), so that's what I did.
In simple cases like here, the object type was introduced together with a new source file. In these cases it was 'git log iothread.c', finding the first commit and then 'git describe --contains $COMMIT'. In more complex cases basically the same, except that finding the right commit was sometimes a little bit harder and may have involved 'git blame'.
Quoted 10 lines
qapi/qom.json line 227
Quoted 5 lines
qapi/qom.json +5
-0+## +{ 'struct': 'IothreadProperties', + 'data': { '*poll-max-ns': 'int', + '*poll-grow': 'int', + '*poll-shrink': 'int' } }These are correctly typed per the code in
iothread.c, but it does raise the question of whether a signed 64-bit value is the best choice, or if we might later want to revisit things to pick more constrained types. I don't think such an audit should hold up this series, though.
Yes, I'm just representing in the schema what is already there in the code.
Kevin
PATCH v2 4/31 qapi/qom: Add ObjectOptions for authz-*
In reply to Kevin WolfThis adds a QAPI schema for the properties of the authz-* objects.
--- qapi/authz.json | 62 ++++++++++++++++++++++++++++ qapi/qom.json | 10 +++++ storage-daemon/qapi/qapi-schema.json | 1 + 3 files changed, 73 insertions(+)
qapi/authz.json +62 -0
@@ -59,3 +59,65 @@ ## { 'struct': 'QAuthZListRuleListHack', 'data': { 'unused': ['QAuthZListRule'] } } + +## +# @AuthZListProperties: +# +# Properties for authz-list objects. +# +# @policy: Default policy to apply when no rule matches (default: deny) +# +# @rules: Authorization rules based on matching user +# +# Since: 4.0 +## +{ 'struct': 'AuthZListProperties', + 'data': { '*policy': 'QAuthZListPolicy', + '*rules': ['QAuthZListRule'] } } + +## +# @AuthZListFileProperties: +# +# Properties for authz-listfile objects. +# +# @filename: File name to load the configuration from. The file must +# contain valid JSON for AuthZListProperties. +# +# @refresh: If true, inotify is used to monitor the file, automatically +# reloading changes. If an error occurs during reloading, all +# authorizations will fail until the file is next successfully +# loaded. (default: true if the binary was built with +# CONFIG_INOTIFY1, false otherwise) +# +# Since: 4.0 +## +{ 'struct': 'AuthZListFileProperties', + 'data': { 'filename': 'str', + '*refresh': 'bool' } } + +## +# @AuthZPAMProperties: +# +# Properties for authz-pam objects. +# +# @service: PAM service name to use for authorization +# +# Since: 4.0 +## +{ 'struct': 'AuthZPAMProperties', + 'data': { 'service': 'str' } } + +## +# @AuthZSimpleProperties: +# +# Properties for authz-simple objects. +# +# @identity: Identifies the allowed user. Its format depends on the network +# service that authorization object is associated with. For +# authorizing based on TLS x509 certificates, the identity must be +# the x509 distinguished name. +# +# Since: 4.0 +## +{ 'struct': 'AuthZSimpleProperties', + 'data': { 'identity': 'str' } }
qapi/qom.json +10 -0
@@ -4,6 +4,8 @@ # This work is licensed under the terms of the GNU GPL, version 2 or later. # See the COPYING file in the top-level directory. +{ 'include': 'authz.json' } + ## # = QEMU Object Model (QOM) ##
@@ -233,6 +235,10 @@ ## { 'enum': 'ObjectType', 'data': [ + 'authz-list', + 'authz-listfile', + 'authz-pam', + 'authz-simple', 'iothread' ] }
@@ -252,6 +258,10 @@ 'id': 'str' }, 'discriminator': 'qom-type', 'data': { + 'authz-list': 'AuthZListProperties', + 'authz-listfile': 'AuthZListFileProperties', + 'authz-pam': 'AuthZPAMProperties', + 'authz-simple': 'AuthZSimpleProperties', 'iothread': 'IothreadProperties' } }
storage-daemon/qapi/qapi-schema.json +1 -0
@@ -26,6 +26,7 @@ { 'include': '../../qapi/crypto.json' } { 'include': '../../qapi/introspect.json' } { 'include': '../../qapi/job.json' } +{ 'include': '../../qapi/authz.json' } { 'include': '../../qapi/qom.json' } { 'include': '../../qapi/sockets.json' } { 'include': '../../qapi/transaction.json' }
Signature · 1 line
2.29.2
Re: [PATCH v2 04/31] qapi/qom: Add ObjectOptions for authz-*
Quoted 14 lines · Kevin Wolf
This adds a QAPI schema for the properties of the authz-* objects.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/authz.json | 62 ++++++++++++++++++++++++++++ qapi/qom.json | 10 +++++ storage-daemon/qapi/qapi-schema.json | 1 + 3 files changed, 73 insertions(+)qapi/authz.json +0
-0
qapi/authz.json line 61
Quoted 3 lines
qapi/authz.json +0
-0@@ -59,3 +59,65 @@ ## { 'struct': 'QAuthZListRuleListHack', 'data': { 'unused': ['QAuthZListRule'] } }
This hack is no longer necessary...
Quoted 5 lines
qapi/authz.json +5
-0+ +## +# @AuthZListProperties: +# +# Properties for authz-list objects.
qapi/authz.json line 76
Quoted 10 lines
qapi/authz.json +10
-0+# +# @policy: Default policy to apply when no rule matches (default: deny) +# +# @rules: Authorization rules based on matching user +# +# Since: 4.0 +## +{ 'struct': 'AuthZListProperties', + 'data': { '*policy': 'QAuthZListPolicy', + '*rules': ['QAuthZListRule'] } }
...now that we have a real type using the same array and forcing the QAPI generator to instantiate it.
Matches authz/list.c:qauthz_list_class_init().
Quoted 10 lines
qapi/authz.json +10
-0+ +## +# @AuthZListFileProperties: +# +# Properties for authz-listfile objects. +# +# @filename: File name to load the configuration from. The file must +# contain valid JSON for AuthZListProperties. +# +# @refresh: If true, inotify is used to monitor the file, automatically
qapi/authz.json line 96
Quoted 10 lines
qapi/authz.json +10
-0+# reloading changes. If an error occurs during reloading, all +# authorizations will fail until the file is next successfully +# loaded. (default: true if the binary was built with +# CONFIG_INOTIFY1, false otherwise) +# +# Since: 4.0 +## +{ 'struct': 'AuthZListFileProperties', + 'data': { 'filename': 'str', + '*refresh': 'bool' } }
Matches authz/listfile.c:qauthz_list_file_class_init().
qapi/authz.json line 108
Quoted 12 lines
qapi/authz.json +12
-0+ +## +# @AuthZPAMProperties: +# +# Properties for authz-pam objects. +# +# @service: PAM service name to use for authorization +# +# Since: 4.0 +## +{ 'struct': 'AuthZPAMProperties', + 'data': { 'service': 'str' } }
Matches authz/pamacct.c:qauthz_pam_class_init().
Quoted 5 lines
qapi/authz.json +5
-0+ +## +# @AuthZSimpleProperties: +# +# Properties for authz-simple objects.
qapi/authz.json line 123
Quoted 10 lines
qapi/authz.json +10
-0+# +# @identity: Identifies the allowed user. Its format depends on the network +# service that authorization object is associated with. For +# authorizing based on TLS x509 certificates, the identity must be +# the x509 distinguished name. +# +# Since: 4.0 +## +{ 'struct': 'AuthZSimpleProperties', + 'data': { 'identity': 'str' } }
Matches authz/simple.c:qauthz_simple_class_init().
Quoted 41 lines
qapi/qom.json +10
-0@@ -4,6 +4,8 @@ # This work is licensed under the terms of the GNU GPL, version 2 or later. # See the COPYING file in the top-level directory. +{ 'include': 'authz.json' } + ## # = QEMU Object Model (QOM) ##@@ -233,6 +235,10 @@ ## { 'enum': 'ObjectType', 'data': [ + 'authz-list', + 'authz-listfile', + 'authz-pam', + 'authz-simple', 'iothread' ] }@@ -252,6 +258,10 @@ 'id': 'str' }, 'discriminator': 'qom-type', 'data': { + 'authz-list': 'AuthZListProperties', + 'authz-listfile': 'AuthZListFileProperties', + 'authz-pam': 'AuthZPAMProperties', + 'authz-simple': 'AuthZSimpleProperties', 'iothread': 'IothreadProperties' } }storage-daemon/qapi/qapi-schema.json +0
-0
storage-daemon/qapi/qapi-schema.json line 32
Quoted 7 lines
storage-daemon/qapi/qapi-schema.json +1
-0@@ -26,6 +26,7 @@ { 'include': '../../qapi/crypto.json' } { 'include': '../../qapi/introspect.json' } { 'include': '../../qapi/job.json' } +{ 'include': '../../qapi/authz.json' } { 'include': '../../qapi/qom.json' } { 'include': '../../qapi/sockets.json' } { 'include': '../../qapi/transaction.json' }
Once you delete the dead QAPI hack,
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 5/31 qapi/qom: Add ObjectOptions for cryptodev-*
In reply to Kevin WolfThis adds a QAPI schema for the properties of the cryptodev-* objects.
These interfaces have some questionable aspects (cryptodev-backend is really an abstract base class without function, and the queues option only makes sense for cryptodev-vhost-user), but as the goal is to represent the existing interface in QAPI, leave these things in place.
--- qapi/qom.json | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
qapi/qom.json +34 -0
@@ -204,6 +204,34 @@ 'returns': [ 'ObjectPropertyInfo' ], 'allow-preconfig': true } +## +# @CryptodevBackendProperties: +# +# Properties for cryptodev-backend and cryptodev-backend-builtin objects. +# +# @queues: the number of queues for the cryptodev backend. Ignored for +# cryptodev-backend and must be 1 for cryptodev-backend-builtin. +# (default: 1) +# +# Since: 2.8 +## +{ 'struct': 'CryptodevBackendProperties', + 'data': { '*queues': 'uint32' } } + +## +# @CryptodevVhostUserProperties: +# +# Properties for cryptodev-vhost-user objects. +# +# @chardev: the name of a unix domain socket character device that connects to +# the vhost-user server +# +# Since: 2.12 +## +{ 'struct': 'CryptodevVhostUserProperties', + 'base': 'CryptodevBackendProperties', + 'data': { 'chardev': 'str' } } + ## # @IothreadProperties: #
@@ -239,6 +267,9 @@ 'authz-listfile', 'authz-pam', 'authz-simple', + 'cryptodev-backend', + 'cryptodev-backend-builtin', + 'cryptodev-vhost-user', 'iothread' ] }
@@ -262,6 +293,9 @@ 'authz-listfile': 'AuthZListFileProperties', 'authz-pam': 'AuthZPAMProperties', 'authz-simple': 'AuthZSimpleProperties', + 'cryptodev-backend': 'CryptodevBackendProperties', + 'cryptodev-backend-builtin': 'CryptodevBackendProperties', + 'cryptodev-vhost-user': 'CryptodevVhostUserProperties', 'iothread': 'IothreadProperties' } }
Signature · 1 line
2.29.2
Re: [PATCH v2 05/31] qapi/qom: Add ObjectOptions for cryptodev-*
Quoted 23 lines · Kevin Wolf
This adds a QAPI schema for the properties of the cryptodev-* objects.
These interfaces have some questionable aspects (cryptodev-backend is really an abstract base class without function, and the queues option only makes sense for cryptodev-vhost-user), but as the goal is to represent the existing interface in QAPI, leave these things in place.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/qom.json | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)qapi/qom.json +3
-0@@ -204,6 +204,34 @@ 'returns': [ 'ObjectPropertyInfo' ], 'allow-preconfig': true } +## +# @CryptodevBackendProperties: +#
qapi/qom.json line 219
Quoted 10 lines
qapi/qom.json +10
-0+# Properties for cryptodev-backend and cryptodev-backend-builtin objects. +# +# @queues: the number of queues for the cryptodev backend. Ignored for +# cryptodev-backend and must be 1 for cryptodev-backend-builtin. +# (default: 1) +# +# Since: 2.8 +## +{ 'struct': 'CryptodevBackendProperties', + 'data': { '*queues': 'uint32' } }
Matches backend/cryptodev.c:cryptodev_backend_class_init() and backend/cryptodev-builtin.c:cryptodev_builtin_class_init().
qapi/qom.json line 226
Quoted 7 lines
qapi/qom.json +7
-0+ +## +# @CryptodevVhostUserProperties: +# +# Properties for cryptodev-vhost-user objects. +# +# @chardev: the name of a unix domain socket character device that connects to
Should that b s/unix/Unix/ ?
qapi/qom.json line 233
Quoted 7 lines
qapi/qom.json +7
-0+# the vhost-user server +# +# Since: 2.12 +## +{ 'struct': 'CryptodevVhostUserProperties', + 'base': 'CryptodevBackendProperties', + 'data': { 'chardev': 'str' } }
Matches backend/cryptodev-vhost-user.c:cryptodev_vhost_user_init_class().
Quoted 16 lines
qapi/qom.json +4
-0+ ## # @IothreadProperties: #@@ -239,6 +267,9 @@ 'authz-listfile', 'authz-pam', 'authz-simple', + 'cryptodev-backend', + 'cryptodev-backend-builtin', + 'cryptodev-vhost-user', 'iothread' ] }
qapi/qom.json line 301
Quoted 9 lines
qapi/qom.json +3
-0@@ -262,6 +293,9 @@ 'authz-listfile': 'AuthZListFileProperties', 'authz-pam': 'AuthZPAMProperties', 'authz-simple': 'AuthZSimpleProperties', + 'cryptodev-backend': 'CryptodevBackendProperties', + 'cryptodev-backend-builtin': 'CryptodevBackendProperties', + 'cryptodev-vhost-user': 'CryptodevVhostUserProperties', 'iothread': 'IothreadProperties' } }
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 6/31 qapi/qom: Add ObjectOptions for dbus-vmstate
In reply to Kevin WolfThis adds a QAPI schema for the properties of the dbus-vmstate object.
A list represented as a comma separated string is clearly not very QAPI-like, but for now just describe the existing interface.
--- qapi/qom.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
qapi/qom.json +18 -0
@@ -232,6 +232,22 @@ 'base': 'CryptodevBackendProperties', 'data': { 'chardev': 'str' } } +## +# @DBusVMStateProperties: +# +# Properties for dbus-vmstate objects. +# +# @addr: the name of the DBus bus to connect to +# +# @id-list: a comma separated list of DBus IDs of helpers whose data should be +# included in the VM state on migration +# +# Since: 5.0 +## +{ 'struct': 'DBusVMStateProperties', + 'data': { 'addr': 'str' , + '*id-list': 'str' } } + ## # @IothreadProperties: #
@@ -270,6 +286,7 @@ 'cryptodev-backend', 'cryptodev-backend-builtin', 'cryptodev-vhost-user', + 'dbus-vmstate', 'iothread' ] }
@@ -296,6 +313,7 @@ 'cryptodev-backend': 'CryptodevBackendProperties', 'cryptodev-backend-builtin': 'CryptodevBackendProperties', 'cryptodev-vhost-user': 'CryptodevVhostUserProperties', + 'dbus-vmstate': 'DBusVMStateProperties', 'iothread': 'IothreadProperties' } }
Signature · 1 line
2.29.2
Re: [PATCH v2 06/31] qapi/qom: Add ObjectOptions for dbus-vmstate
Quoted 4 lines · Kevin Wolf
This adds a QAPI schema for the properties of the dbus-vmstate object.
A list represented as a comma separated string is clearly not very QAPI-like, but for now just describe the existing interface.
Does your alias proposal give us a path forward for improving that down the road? Or maybe it's not an alias we need, but a new field with better QAPI-like semantics, deprecate the old one, and wait out the 2 release cycles?
Quoted 19 lines
Signed-off-by Kevin Wolf <[email protected]>--- qapi/qom.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)qapi/qom.json +5
-0@@ -232,6 +232,22 @@ 'base': 'CryptodevBackendProperties', 'data': { 'chardev': 'str' } } +## +# @DBusVMStateProperties: +# +# Properties for dbus-vmstate objects. +#
qapi/qom.json line 249
Quoted 10 lines
qapi/qom.json +10
-0+# @addr: the name of the DBus bus to connect to +# +# @id-list: a comma separated list of DBus IDs of helpers whose data should be +# included in the VM state on migration +# +# Since: 5.0 +## +{ 'struct': 'DBusVMStateProperties', + 'data': { 'addr': 'str' , + '*id-list': 'str' } }
Matches backends/dbus-vmstate.c:dbus_vmstate_class_init(), including splitting id-list into a GHashTable with get_id_list_set().
Since there is benefit to documenting/converting our existing API in this series without dragging it out by also trying to fix the warts,
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH v2 06/31] qapi/qom: Add ObjectOptions for dbus-vmstate
Am 26.02.2021 um 16:58 hat Eric Blake geschrieben:
Quoted 10 lines · Kevin Wolf
Quoted 4 lines
This adds a QAPI schema for the properties of the dbus-vmstate object.
A list represented as a comma separated string is clearly not very QAPI-like, but for now just describe the existing interface.
Does your alias proposal give us a path forward for improving that down the road? Or maybe it's not an alias we need, but a new field with better QAPI-like semantics, deprecate the old one, and wait out the 2 release cycles?
Aliases can just give options an alternative name, they don't change anything about the structure of the option. Splitting a string into multiple values is certainly not one of the things they solve.
So if we care, adding a replacement and deprecating the old option is probably what we would do.
Kevin
PATCH v2 7/31 qapi/qom: Add ObjectOptions for memory-backend-*
In reply to Kevin WolfThis adds a QAPI schema for the properties of the memory-backend-* objects.
HostMemPolicy has to be moved to an include file that can be used by the storage daemon, too, because ObjectOptions must be the same in all binaries if we don't want to compile the whole code multiple times.
--- qapi/common.json | 20 ++++++++ qapi/machine.json | 22 +-------- qapi/qom.json | 118 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 138 insertions(+), 22 deletions(-)
qapi/common.json +20 -0
@@ -145,3 +145,23 @@ ## { 'enum': 'PCIELinkWidth', 'data': [ '1', '2', '4', '8', '12', '16', '32' ] } + +## +# @HostMemPolicy: +# +# Host memory policy types +# +# @default: restore default policy, remove any nondefault policy +# +# @preferred: set the preferred host nodes for allocation +# +# @bind: a strict policy that restricts memory allocation to the +# host nodes specified +# +# @interleave: memory allocations are interleaved across the set +# of host nodes specified +# +# Since: 2.1 +## +{ 'enum': 'HostMemPolicy', + 'data': [ 'default', 'preferred', 'bind', 'interleave' ] }
qapi/machine.json +2 -20
@@ -8,6 +8,8 @@ # = Machines ## +{ 'include': 'common.json' } + ## # @SysEmuTarget: #
@@ -897,26 +899,6 @@ 'policy': 'HmatCacheWritePolicy', 'line': 'uint16' }} -## -# @HostMemPolicy: -# -# Host memory policy types -# -# @default: restore default policy, remove any nondefault policy -# -# @preferred: set the preferred host nodes for allocation -# -# @bind: a strict policy that restricts memory allocation to the -# host nodes specified -# -# @interleave: memory allocations are interleaved across the set -# of host nodes specified -# -# Since: 2.1 -## -{ 'enum': 'HostMemPolicy', - 'data': [ 'default', 'preferred', 'bind', 'interleave' ] } - ## # @memsave: #
qapi/qom.json +116 -2
142 lines not on this page · raw message
Signature · 1 line
2.29.2
Re: [PATCH v2 07/31] qapi/qom: Add ObjectOptions for memory-backend-*
Quoted 17 lines · Kevin Wolf
This adds a QAPI schema for the properties of the memory-backend-* objects.
HostMemPolicy has to be moved to an include file that can be used by the storage daemon, too, because ObjectOptions must be the same in all binaries if we don't want to compile the whole code multiple times.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/common.json | 20 ++++++++ qapi/machine.json | 22 +-------- qapi/qom.json | 118 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 138 insertions(+), 22 deletions(-)+++
b/qapi/qom.json
qapi/qom.json line 285
Quoted 10 lines
qapi/qom.json +10
-0+## +# @MemoryBackendProperties: +# +# Properties for objects of classes derived from memory-backend. +# +# @merge: if true, mark the memory as mergeable (default depends on the machine +# type) +# +# @dump: if true, include the memory in core dumps (default depends on the +# machine type)
Interesting choice to flip the description text from its previous wording, but fine by me:
object_class_property_set_description(oc, "dump",
"Set to 'off' to exclude from core dump");qapi/qom.json line 291
Quoted 6 lines
qapi/qom.json +6
-0+# +# @host-nodes: the list of NUMA host nodes to bind the memory to +# +# @policy: the NUMA policy (default: 'default') +# +# @prealloc: if true, preallocate memory (default: false)
Not quite in the same order as backends/hostmem.c:host_memory_backend_class_init() (alphabetic here instead of matching the C code declaration order), but that doesn't impact QMP semantics, and I was able to match everything up in the end.
Quoted 4 lines
qapi/qom.json +4
-0+# +# @prealloc-threads: number of CPU threads to use for prealloc (default: 1) +# +# @share: if false, the memory is private to QEMU; if true, it is shared
qapi/qom.json line 305
Quoted 10 lines
qapi/qom.json +10
-0+# (default: false) +# +# @size: size of the memory region in bytes +# +# @x-use-canonical-path-for-ramblock-id: if true, the canoncial path is used +# for ramblock-id. Disable this for 4.0 +# machine types or older to allow +# migration with newer QEMU versions. +# (default: false generally, but true +# for machine types <= 4.0)
The comment in the C code mentions that in spite of the x- prefix, we have to treat this as a stable interface until 4.0 machines disappear. Do we need any of that sentiment in the documentation here?
Quoted 11 lines
qapi/qom.json +11
-0+# +# Since: 2.1 +## +{ 'struct': 'MemoryBackendProperties', + 'data': { '*dump': 'bool', + '*host-nodes': ['uint16'], + '*merge': 'bool', + '*policy': 'HostMemPolicy', + '*prealloc': 'bool', + '*prealloc-threads': 'uint32', + '*share': 'bool',
qapi/qom.json line 326
Quoted 10 lines
qapi/qom.json +10
-0+ 'size': 'size', + '*x-use-canonical-path-for-ramblock-id': 'bool' } } + +## +# @MemoryBackendFileProperties: +# +# Properties for memory-backend-file objects. +# +# @align: the base address alignment when QEMU mmap(2) @mem-path. Some +# backend store specified by @mem-path requires an alignment different
Grammar feels off. Would it read better as
...when QEMU mmap(2)s @mem-path. Some backend stores specified by @mem-path require an...
qapi/qom.json line 330
Quoted 4 lines
qapi/qom.json +4
-0+# than the default one used by QEMU, e.g. the device DAX /dev/dax0.0 +# requires 2M alignment rather than 4K. In such cases, users can +# specify the required alignment via this option. +# 0 selects a default alignment (currently the page size). (default: 0)
Again, not in the same order as backends/hostmem-file.c:file_backend_class_init(), but it matches up.
Quoted 14 lines
qapi/qom.json +14
-0+# +# @discard-data: if true, the file contents can be destroyed when QEMU exits, +# to avoid unnecessarily flushing data to the backing file. Note +# that ``discard-data`` is only an optimization, and QEMU might +# not discard file contents if it aborts unexpectedly or is +# terminated using SIGKILL. (default: false) +# +# @mem-path: the path to either a shared memory or huge page filesystem mount +# +# @pmem: specifies whether the backing file specified by @mem-path is in +# host persistent memory that can be accessed using the SNIA NVM +# programming model (e.g. Intel NVDIMM). +# +# @readonly: if true, the backing file is opened read-only; if false, it is
qapi/qom.json line 354
Quoted 10 lines
qapi/qom.json +10
-0+# opened read-write. (default: false) +# +# Since: 2.1 +## +{ 'struct': 'MemoryBackendFileProperties', + 'base': 'MemoryBackendProperties', + 'data': { '*align': 'size', + '*discard-data': 'bool', + 'mem-path': 'str', + '*pmem': 'bool',
To match the C code, this should be
'*pmem': { 'type':'bool', 'if':'defined(CONFIG_LIBPMEM)' },
Quoted 17 lines
qapi/qom.json +17
-0+ '*readonly': 'bool' } } + +## +# @MemoryBackendMemfdProperties: +# +# Properties for memory-backend-memfd objects. +# +# The @share boolean option is true by default with memfd. +# +# @hugetlb: if true, the file to be created resides in the hugetlbfs filesystem +# (default: false) +# +# @hugetlbsize: the hugetlb page size on systems that support multiple hugetlb +# page sizes (it must be a power of 2 value supported by the +# system). 0 selects a default page size. This option is ignored +# if @hugetlb is false. (default: 0) +#
qapi/qom.json line 381
Quoted 10 lines
qapi/qom.json +10
-0+# @seal: if true, create a sealed-file, which will block further resizing of +# the memory (default: true) +# +# Since: 2.12 +## +{ 'struct': 'MemoryBackendMemfdProperties', + 'base': 'MemoryBackendProperties', + 'data': { '*hugetlb': 'bool', + '*hugetlbsize': 'size', + '*seal': 'bool' } }
backends/hostmem-memfd.c makes 'hugetlb' and 'hugetlbsize' conditional on qemu_memfd_check(MFD_HUGETLB), and only registers the overal type based on qemu_memfd_check(MFD_ALLOW_SEALING). In turn, qemu_memfd_check returns false except for CONFIG_LINUX,...
Quoted 17 lines
qapi/qom.json +5
-1+ ## # @ObjectType: #@@ -287,7 +395,10 @@ 'cryptodev-backend-builtin', 'cryptodev-vhost-user', 'dbus-vmstate', - 'iothread' + 'iothread', + 'memory-backend-file', + 'memory-backend-memfd', + 'memory-backend-ram' ] } ##
qapi/qom.json line 430
Quoted 7 lines
qapi/qom.json +3
-1@@ -314,7 +425,10 @@ 'cryptodev-backend-builtin': 'CryptodevBackendProperties', 'cryptodev-vhost-user': 'CryptodevVhostUserProperties', 'dbus-vmstate': 'DBusVMStateProperties', - 'iothread': 'IothreadProperties' + 'iothread': 'IothreadProperties', + 'memory-backend-file': 'MemoryBackendFileProperties', + 'memory-backend-memfd': 'MemoryBackendMemfdProperties',
...so I'm wondering if this branch should be:
'memory-backend-memfd', { 'type':'MemoryBackendMemfdProperties',
'if': 'defined(CONFIG_LINUX)' },
and whether we are risking problems by always having the 'hugetlb*' fields even when the runtime does not register them.
qapi/qom.json line 434
Quoted 5 lines
qapi/qom.json +1
-0+ 'memory-backend-ram': 'MemoryBackendProperties' } } ##
Because of my questions on conditional compilation, I'm not comfortable with R-b yet.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH v2 07/31] qapi/qom: Add ObjectOptions for memory-backend-*
Am 26.02.2021 um 17:23 hat Eric Blake geschrieben:
Quoted 31 lines · Kevin Wolf
Quoted 17 lines
This adds a QAPI schema for the properties of the memory-backend-* objects.
HostMemPolicy has to be moved to an include file that can be used by the storage daemon, too, because ObjectOptions must be the same in all binaries if we don't want to compile the whole code multiple times.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/common.json | 20 ++++++++ qapi/machine.json | 22 +-------- qapi/qom.json | 118 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 138 insertions(+), 22 deletions(-)+++
b/qapi/qom.jsonqapi/qom.json line 285
Quoted 10 lines
qapi/qom.json +10
-0+## +# @MemoryBackendProperties: +# +# Properties for objects of classes derived from memory-backend. +# +# @merge: if true, mark the memory as mergeable (default depends on the machine +# type) +# +# @dump: if true, include the memory in core dumps (default depends on the +# machine type)Interesting choice to flip the description text from its previous wording, but fine by me:
Quoted 2 lines
object_class_property_set_description(oc, "dump",
"Set to 'off' to exclude from core dump");I feel that for booleans, describing what happens if they are false often turns out a bit confusing with double negatives etc. But if you think that in some cases, describing the negative is actually better, I'm open for that.
Quoted 22 lines
qapi/qom.json line 291
Quoted 6 lines
qapi/qom.json +6
-0+# +# @host-nodes: the list of NUMA host nodes to bind the memory to +# +# @policy: the NUMA policy (default: 'default') +# +# @prealloc: if true, preallocate memory (default: false)Not quite in the same order as backends/hostmem.c:host_memory_backend_class_init() (alphabetic here instead of matching the C code declaration order), but that doesn't impact QMP semantics, and I was able to match everything up in the end.
Quoted 10 lines
qapi/qom.json +10
-0+# +# @prealloc-threads: number of CPU threads to use for prealloc (default: 1) +# +# @share: if false, the memory is private to QEMU; if true, it is shared +# (default: false) +# +# @size: size of the memory region in bytes +# +# @x-use-canonical-path-for-ramblock-id: if true, the canoncial path is used +# for ramblock-id. Disable this for 4.0
Quoted 8 lines
qapi/qom.json line 305
Quoted 4 lines
qapi/qom.json +4
-0+# machine types or older to allow +# migration with newer QEMU versions. +# (default: false generally, but true +# for machine types <= 4.0)The comment in the C code mentions that in spite of the x- prefix, we have to treat this as a stable interface until 4.0 machines disappear. Do we need any of that sentiment in the documentation here?
"This option is considered stable despite the x- prefix."
Does this work or should I be more verbose? (The indentation makes me want to keep it terse... :-))
Quoted 24 lines
Quoted 11 lines
qapi/qom.json +11
-0+# +# Since: 2.1 +## +{ 'struct': 'MemoryBackendProperties', + 'data': { '*dump': 'bool', + '*host-nodes': ['uint16'], + '*merge': 'bool', + '*policy': 'HostMemPolicy', + '*prealloc': 'bool', + '*prealloc-threads': 'uint32', + '*share': 'bool',qapi/qom.json line 326
Quoted 10 lines
qapi/qom.json +10
-0+ 'size': 'size', + '*x-use-canonical-path-for-ramblock-id': 'bool' } } + +## +# @MemoryBackendFileProperties: +# +# Properties for memory-backend-file objects. +# +# @align: the base address alignment when QEMU mmap(2) @mem-path. Some +# backend store specified by @mem-path requires an alignment differentGrammar feels off. Would it read better as
Quoted 2 lines
...when QEMU mmap(2)s @mem-path. Some backend stores specified by @mem-path require an...
This description is stolen from qemu-options.hx (I actually tried to copy existing documentation whenever it seemed to explain things well), but that's no reason not to improve it.
Quoted 27 lines
qapi/qom.json line 330
Quoted 4 lines
qapi/qom.json +4
-0+# than the default one used by QEMU, e.g. the device DAX /dev/dax0.0 +# requires 2M alignment rather than 4K. In such cases, users can +# specify the required alignment via this option. +# 0 selects a default alignment (currently the page size). (default: 0)Again, not in the same order as backends/hostmem-file.c:file_backend_class_init(), but it matches up.
Quoted 19 lines
qapi/qom.json +19
-0+# +# @discard-data: if true, the file contents can be destroyed when QEMU exits, +# to avoid unnecessarily flushing data to the backing file. Note +# that ``discard-data`` is only an optimization, and QEMU might +# not discard file contents if it aborts unexpectedly or is +# terminated using SIGKILL. (default: false) +# +# @mem-path: the path to either a shared memory or huge page filesystem mount +# +# @pmem: specifies whether the backing file specified by @mem-path is in +# host persistent memory that can be accessed using the SNIA NVM +# programming model (e.g. Intel NVDIMM). +# +# @readonly: if true, the backing file is opened read-only; if false, it is +# opened read-write. (default: false) +# +# Since: 2.1 +## +{ 'struct': 'MemoryBackendFileProperties',
Quoted 8 lines
qapi/qom.json line 354
Quoted 5 lines
qapi/qom.json +5
-0+ 'base': 'MemoryBackendProperties', + 'data': { '*align': 'size', + '*discard-data': 'bool', + 'mem-path': 'str', + '*pmem': 'bool',To match the C code, this should be
'*pmem': { 'type':'bool', 'if':'defined(CONFIG_LIBPMEM)' },
Good catch, will fix.
Quoted 60 lines
Quoted 17 lines
qapi/qom.json +17
-0+ '*readonly': 'bool' } } + +## +# @MemoryBackendMemfdProperties: +# +# Properties for memory-backend-memfd objects. +# +# The @share boolean option is true by default with memfd. +# +# @hugetlb: if true, the file to be created resides in the hugetlbfs filesystem +# (default: false) +# +# @hugetlbsize: the hugetlb page size on systems that support multiple hugetlb +# page sizes (it must be a power of 2 value supported by the +# system). 0 selects a default page size. This option is ignored +# if @hugetlb is false. (default: 0) +#qapi/qom.json line 381
Quoted 10 lines
qapi/qom.json +10
-0+# @seal: if true, create a sealed-file, which will block further resizing of +# the memory (default: true) +# +# Since: 2.12 +## +{ 'struct': 'MemoryBackendMemfdProperties', + 'base': 'MemoryBackendProperties', + 'data': { '*hugetlb': 'bool', + '*hugetlbsize': 'size', + '*seal': 'bool' } }
backends/hostmem-memfd.cmakes 'hugetlb' and 'hugetlbsize' conditional onqemu_memfd_check(MFD_HUGETLB), and only registers the overal type based onqemu_memfd_check(MFD_ALLOW_SEALING). In turn,qemu_memfd_checkreturns false except forCONFIG_LINUX,...Quoted 17 lines
qapi/qom.json +5
-1+ ## # @ObjectType: #@@ -287,7 +395,10 @@ 'cryptodev-backend-builtin', 'cryptodev-vhost-user', 'dbus-vmstate', - 'iothread' + 'iothread', + 'memory-backend-file', + 'memory-backend-memfd', + 'memory-backend-ram' ] } ##qapi/qom.json line 430
Quoted 7 lines
qapi/qom.json +3
-1@@ -314,7 +425,10 @@ 'cryptodev-backend-builtin': 'CryptodevBackendProperties', 'cryptodev-vhost-user': 'CryptodevVhostUserProperties', 'dbus-vmstate': 'DBusVMStateProperties', - 'iothread': 'IothreadProperties' + 'iothread': 'IothreadProperties', + 'memory-backend-file': 'MemoryBackendFileProperties', + 'memory-backend-memfd': 'MemoryBackendMemfdProperties',...so I'm wondering if this branch should be:
Quoted 5 lines
'memory-backend-memfd', { 'type':'MemoryBackendMemfdProperties',
'if': 'defined(CONFIG_LINUX)' },and whether we are risking problems by always having the 'hugetlb*' fields even when the runtime does not register them.
I don't think that's necessarily a problem.
Later in the series we'll have some more object types in here that don't actually work: Some of them are target dependent, but the code generated from the schema is compiled only once. So if you configured multiple targets, you'll get all of them in the schema for all system emulators, even those that emulate a different target.
I'm hesitant to change this one because it feels a bit indirect. It would be a much clearer case if we only compiled the source file for CONFIG_LINUX instead of deciding at runtime.
*checks meson.build*
Wait, scratch that... We already do that in addition, so you can get your 'if'. :-)
And while I'm at it, cryptodev-vhost-user is conditional on CONFIG_VIRTIO_CRYPTO and CONFIG_VHOST_CRYPTO. The QAPI schema language doesn't have a way to split strings across multiple lines? Because I'll need more than 80 characters for this line then...
Kevin
PATCH v2 8/31 qapi/qom: Add ObjectOptions for rng-*, deprecate 'opened'
In reply to Kevin WolfThis adds a QAPI schema for the properties of the rng-* objects.
The 'opened' property doesn't seem to make sense as an external
interface: It is automatically set to true in ucc->complete, and explicitly setting it to true earlier just means that trying to set additional options will result in an error. After the property has once been set to true (i.e. when the object construction has completed), it can never be reset to false. In other words, the 'opened' property is useless. Mark it as deprecated in the schema from the start.
--- qapi/qom.json | 56 ++++++++++++++++++++++++++++++++++++-- docs/system/deprecated.rst | 9 ++++++ 2 files changed, 63 insertions(+), 2 deletions(-)
qapi/qom.json +54 -2
@@ -380,6 +380,52 @@ '*hugetlbsize': 'size', '*seal': 'bool' } } +## +# @RngProperties: +# +# Properties for objects of classes derived from rng. +# +# @opened: if true, the device is opened immediately when applying this option +# and will probably fail when processing the next option. Don't use; +# only provided for compatibility. (default: false) +# +# Features: +# @deprecated: Member @opened is deprecated. Setting true doesn't make sense, +# and false is already the default. +# +# Since: 1.3 +## +{ 'struct': 'RngProperties', + 'data': { '*opened': { 'type': 'bool', 'features': ['deprecated'] } } } + +## +# @RngEgdProperties: +# +# Properties for rng-egd objects. +# +# @chardev: the name of a character device backend that provides the connection +# to the RNG daemon +# +# Since: 1.3 +## +{ 'struct': 'RngEgdProperties', + 'base': 'RngProperties', + 'data': { 'chardev': 'str' } } + +## +# @RngRandomProperties: +# +# Properties for rng-random objects. +# +# @filename: the filename of the device on the host to obtain entropy from +# (default: "/dev/urandom") +# +# Since: 1.3 +## +{ 'struct': 'RngRandomProperties', + 'base': 'RngProperties', + 'data': { '*filename': 'str' } } + ## # @ObjectType: #
@@ -398,7 +444,10 @@ 'iothread', 'memory-backend-file', 'memory-backend-memfd', - 'memory-backend-ram' + 'memory-backend-ram', + 'rng-builtin', + 'rng-egd', + 'rng-random' ] } ##
@@ -428,7 +477,10 @@ 'iothread': 'IothreadProperties', 'memory-backend-file': 'MemoryBackendFileProperties', 'memory-backend-memfd': 'MemoryBackendMemfdProperties', - 'memory-backend-ram': 'MemoryBackendProperties' + 'memory-backend-ram': 'MemoryBackendProperties', + 'rng-builtin': 'RngProperties', + 'rng-egd': 'RngEgdProperties', + 'rng-random': 'RngRandomProperties' } } ##
docs/system/deprecated.rst +9 -0
@@ -146,6 +146,15 @@ library enabled as a cryptography provider. Neither the ``nettle`` library, or the built-in cryptography provider are supported on FIPS enabled hosts. +``opened`` property of ``rng-*`` objects (since 6.0.0) +'''''''''''''''''''''''''''''''''''''''''''''''''''''' + +The only effect of specifying ``opened=on`` in the command line or QMP +``object-add`` is that the device is opened immediately, possibly before all +other options have been processed. This will either have no effect (if +``opened`` was the last option) or cause errors. The property is therefore +useless and should not be specified. + QEMU Machine Protocol (QMP) commands ------------------------------------
Signature · 1 line
2.29.2
Re: [PATCH v2 08/31] qapi/qom: Add ObjectOptions for rng-*, deprecate 'opened'
Quoted 31 lines · Kevin Wolf
This adds a QAPI schema for the properties of the rng-* objects.
The 'opened' property doesn't seem to make sense as an external
interface: It is automatically set to true inucc->complete, and explicitly setting it to true earlier just means that trying to set additional options will result in an error. After the property has once been set to true (i.e. when the object construction has completed), it can never be reset to false. In other words, the 'opened' property is useless. Mark it as deprecated in the schema from the start.Signed-off-by Kevin Wolf <[email protected]>--- qapi/qom.json | 56 ++++++++++++++++++++++++++++++++++++-- docs/system/deprecated.rst | 9 ++++++ 2 files changed, 63 insertions(+), 2 deletions(-)qapi/qom.json +7
-0@@ -380,6 +380,52 @@ '*hugetlbsize': 'size', '*seal': 'bool' } } +## +# @RngProperties: +# +# Properties for objects of classes derived from rng. +# +# @opened: if true, the device is opened immediately when applying this option +# and will probably fail when processing the next option. Don't use;
qapi/qom.json line 399
Quoted 10 lines
qapi/qom.json +10
-0+# only provided for compatibility. (default: false) +# +# Features: +# @deprecated: Member @opened is deprecated. Setting true doesn't make sense, +# and false is already the default. +# +# Since: 1.3 +## +{ 'struct': 'RngProperties', + 'data': { '*opened': { 'type': 'bool', 'features': ['deprecated'] } } }
Matches backends/rng.c:rng_backend_class_init(), and I concur with the deprecation.
Quoted 4 lines
qapi/qom.json +4
-0+ +## +# @RngEgdProperties: +#
qapi/qom.json line 413
Quoted 10 lines
qapi/qom.json +10
-0+# Properties for rng-egd objects. +# +# @chardev: the name of a character device backend that provides the connection +# to the RNG daemon +# +# Since: 1.3 +## +{ 'struct': 'RngEgdProperties', + 'base': 'RngProperties', + 'data': { 'chardev': 'str' } }
Matches backends/rng-egd.c:rng_egd_class_init().
Quoted 4 lines
qapi/qom.json +4
-0+ +## +# @RngRandomProperties: +#
qapi/qom.json line 427
Quoted 10 lines
qapi/qom.json +10
-0+# Properties for rng-random objects. +# +# @filename: the filename of the device on the host to obtain entropy from +# (default: "/dev/urandom") +# +# Since: 1.3 +## +{ 'struct': 'RngRandomProperties', + 'base': 'RngProperties', + 'data': { '*filename': 'str' } }
Matches backends/rng-random.c:rng_random_class_init().
Quoted 34 lines
qapi/qom.json +9
-2+ ## # @ObjectType: #@@ -398,7 +444,10 @@ 'iothread', 'memory-backend-file', 'memory-backend-memfd', - 'memory-backend-ram' + 'memory-backend-ram', + 'rng-builtin', + 'rng-egd', + 'rng-random' ] } ##@@ -428,7 +477,10 @@ 'iothread': 'IothreadProperties', 'memory-backend-file': 'MemoryBackendFileProperties', 'memory-backend-memfd': 'MemoryBackendMemfdProperties', - 'memory-backend-ram': 'MemoryBackendProperties' + 'memory-backend-ram': 'MemoryBackendProperties', + 'rng-builtin': 'RngProperties', + 'rng-egd': 'RngEgdProperties', + 'rng-random': 'RngRandomProperties' } } ##docs/system/deprecated.rst +0
-0@@ -146,6 +146,15 @@ library enabled as a cryptography provider. Neither the ``nettle`` library, or the built-in cryptography provider are
docs/system/deprecated.rst library enabled as a cryptography provider. · line 156
Quoted 10 lines
docs/system/deprecated.rst +8
-0supported on FIPS enabled hosts. +``opened`` property of ``rng-*`` objects (since 6.0.0) +'''''''''''''''''''''''''''''''''''''''''''''''''''''' + +The only effect of specifying ``opened=on`` in the command line or QMP +``object-add`` is that the device is opened immediately, possibly before all +other options have been processed. This will either have no effect (if +``opened`` was the last option) or cause errors. The property is therefore +useless and should not be specified.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 9/31 qapi/qom: Add ObjectOptions for throttle-group
In reply to Kevin WolfThis adds a QAPI schema for the properties of the throttle-group object.
The only purpose of the x-* properties is to make the nested options in 'limits' available for a command line parser that doesn't support structs. Any parser that will use the QAPI schema will supports structs, though, so they will not be needed in the schema in the future.
To keep the conversion straightforward, add them to the schema anyway. We can then remove the options and adjust documentation, test cases etc. in a separate patch.
--- qapi/block-core.json | 27 +++++++++++++++++++++++++++ qapi/qom.json | 7 +++++-- 2 files changed, 32 insertions(+), 2 deletions(-)
qapi/block-core.json +27 -0
@@ -2504,6 +2504,33 @@ '*bps-write-max' : 'int', '*bps-write-max-length' : 'int', '*iops-size' : 'int' } } +## +# @ThrottleGroupProperties: +# +# Properties for throttle-group objects. +# +# The options starting with x- are aliases for the same key without x- in +# the @limits object. As indicated by the x- prefix, this is not a stable +# interface and may be removed or changed incompatibly in the future. Use +# @limits for a supported stable interface. +# +# @limits: limits to apply for this throttle group +# +# Since: 2.11 +## +{ 'struct': 'ThrottleGroupProperties', + 'data': { '*limits': 'ThrottleLimits', + '*x-iops-total' : 'int', '*x-iops-total-max' : 'int', + '*x-iops-total-max-length' : 'int', '*x-iops-read' : 'int', + '*x-iops-read-max' : 'int', '*x-iops-read-max-length' : 'int', + '*x-iops-write' : 'int', '*x-iops-write-max' : 'int', + '*x-iops-write-max-length' : 'int', '*x-bps-total' : 'int', + '*x-bps-total-max' : 'int', '*x-bps-total-max-length' : 'int', + '*x-bps-read' : 'int', '*x-bps-read-max' : 'int', + '*x-bps-read-max-length' : 'int', '*x-bps-write' : 'int', + '*x-bps-write-max' : 'int', '*x-bps-write-max-length' : 'int', + '*x-iops-size' : 'int' } } + ## # @block-stream: #
qapi/qom.json +5 -2
@@ -5,6 +5,7 @@ # See the COPYING file in the top-level directory. { 'include': 'authz.json' } +{ 'include': 'block-core.json' } { 'include': 'common.json' } ##
@@ -447,7 +448,8 @@ 'memory-backend-ram', 'rng-builtin', 'rng-egd', - 'rng-random' + 'rng-random', + 'throttle-group' ] } ##
@@ -480,7 +482,8 @@ 'memory-backend-ram': 'MemoryBackendProperties', 'rng-builtin': 'RngProperties', 'rng-egd': 'RngEgdProperties', - 'rng-random': 'RngRandomProperties' + 'rng-random': 'RngRandomProperties', + 'throttle-group': 'ThrottleGroupProperties' } } ##
Signature · 1 line
2.29.2
Re: [PATCH v2 09/31] qapi/qom: Add ObjectOptions for throttle-group
Quoted 22 lines · Kevin Wolf
This adds a QAPI schema for the properties of the throttle-group object.
The only purpose of the x-* properties is to make the nested options in 'limits' available for a command line parser that doesn't support structs. Any parser that will use the QAPI schema will supports structs, though, so they will not be needed in the schema in the future.
To keep the conversion straightforward, add them to the schema anyway. We can then remove the options and adjust documentation, test cases etc. in a separate patch.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/block-core.json | 27 +++++++++++++++++++++++++++ qapi/qom.json | 7 +++++-- 2 files changed, 32 insertions(+), 2 deletions(-)qapi/block-core.json +0
-0
qapi/block-core.json line 2510
Quoted 7 lines
qapi/block-core.json +4
-0@@ -2504,6 +2504,33 @@ '*bps-write-max' : 'int', '*bps-write-max-length' : 'int', '*iops-size' : 'int' } } +## +# @ThrottleGroupProperties: +# +# Properties for throttle-group objects.
Corresponds to block/throttle-groups.c:throttle_group_obj_class_init() with its ThrottleParamInfo struct for the x- fields, and limits as-is.
qapi/block-core.json line 2517
Quoted 7 lines
qapi/block-core.json +7
-0+# +# The options starting with x- are aliases for the same key without x- in +# the @limits object. As indicated by the x- prefix, this is not a stable +# interface and may be removed or changed incompatibly in the future. Use +# @limits for a supported stable interface. +# +# @limits: limits to apply for this throttle group
And I did check that qapi/block-core.json:ThrottleLimits has the same fields as the ThrottleParamInfo x- fields. All this duplication! But we're getting to a state where it will be easier to clean up the cruft.
Quoted 43 lines
qapi/block-core.json +16
-0+# +# Since: 2.11 +## +{ 'struct': 'ThrottleGroupProperties', + 'data': { '*limits': 'ThrottleLimits', + '*x-iops-total' : 'int', '*x-iops-total-max' : 'int', + '*x-iops-total-max-length' : 'int', '*x-iops-read' : 'int', + '*x-iops-read-max' : 'int', '*x-iops-read-max-length' : 'int', + '*x-iops-write' : 'int', '*x-iops-write-max' : 'int', + '*x-iops-write-max-length' : 'int', '*x-bps-total' : 'int', + '*x-bps-total-max' : 'int', '*x-bps-total-max-length' : 'int', + '*x-bps-read' : 'int', '*x-bps-read-max' : 'int', + '*x-bps-read-max-length' : 'int', '*x-bps-write' : 'int', + '*x-bps-write-max' : 'int', '*x-bps-write-max-length' : 'int', + '*x-iops-size' : 'int' } } + ## # @block-stream: #qapi/qom.json +3
-1@@ -5,6 +5,7 @@ # See the COPYING file in the top-level directory. { 'include': 'authz.json' } +{ 'include': 'block-core.json' } { 'include': 'common.json' } ##@@ -447,7 +448,8 @@ 'memory-backend-ram', 'rng-builtin', 'rng-egd', - 'rng-random' + 'rng-random', + 'throttle-group' ] } ##
qapi/qom.json line 489
Quoted 9 lines
qapi/qom.json +2
-1@@ -480,7 +482,8 @@ 'memory-backend-ram': 'MemoryBackendProperties', 'rng-builtin': 'RngProperties', 'rng-egd': 'RngEgdProperties', - 'rng-random': 'RngRandomProperties' + 'rng-random': 'RngRandomProperties', + 'throttle-group': 'ThrottleGroupProperties' } } ##
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH v2 09/31] qapi/qom: Add ObjectOptions for throttle-group
Am 26.02.2021 um 18:26 hat Eric Blake geschrieben:
Quoted 34 lines · Kevin Wolf
Quoted 22 lines
This adds a QAPI schema for the properties of the throttle-group object.
The only purpose of the x-* properties is to make the nested options in 'limits' available for a command line parser that doesn't support structs. Any parser that will use the QAPI schema will supports structs, though, so they will not be needed in the schema in the future.
To keep the conversion straightforward, add them to the schema anyway. We can then remove the options and adjust documentation, test cases etc. in a separate patch.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/block-core.json | 27 +++++++++++++++++++++++++++ qapi/qom.json | 7 +++++-- 2 files changed, 32 insertions(+), 2 deletions(-)qapi/block-core.json +0
-0qapi/block-core.json line 2510
Quoted 7 lines
qapi/block-core.json +4
-0@@ -2504,6 +2504,33 @@ '*bps-write-max' : 'int', '*bps-write-max-length' : 'int', '*iops-size' : 'int' } } +## +# @ThrottleGroupProperties: +# +# Properties for throttle-group objects.Corresponds to block/throttle-groups.c:throttle_group_obj_class_init() with its ThrottleParamInfo struct for the x- fields, and limits as-is.
Quoted 11 lines
qapi/block-core.json line 2517
Quoted 7 lines
qapi/block-core.json +7
-0+# +# The options starting with x- are aliases for the same key without x- in +# the @limits object. As indicated by the x- prefix, this is not a stable +# interface and may be removed or changed incompatibly in the future. Use +# @limits for a supported stable interface. +# +# @limits: limits to apply for this throttle groupAnd I did check that qapi/block-core.json:ThrottleLimits has the same fields as the ThrottleParamInfo x- fields. All this duplication! But we're getting to a state where it will be easier to clean up the cruft.
Indeed, after this series you can use 'limit' everywhere, so there is no real reason for the x- fields to stay. I almost included the removal in this series, but then it turned out that some more test cases depend on it than I wanted to fix up on the side. But it's an obvious follow-up series.
Kevin
PATCH v2 10/31 qapi/qom: Add ObjectOptions for secret*, deprecate 'loaded'
In reply to Kevin WolfThis adds a QAPI schema for the properties of the secret* objects.
The 'loaded' property doesn't seem to make sense as an external
interface: It is automatically set to true in ucc->complete, and explicitly setting it to true earlier just means that additional options will be silently ignored.
In other words, the 'loaded' property is useless. Mark it as deprecated in the schema from the start.
--- qapi/crypto.json | 61 ++++++++++++++++++++++++++++++++++++++ qapi/qom.json | 5 ++++ docs/system/deprecated.rst | 11 +++++++ 3 files changed, 77 insertions(+)
qapi/crypto.json +61 -0
@@ -381,3 +381,64 @@ 'discriminator': 'format', 'data': { 'luks': 'QCryptoBlockAmendOptionsLUKS' } } + +## +# @SecretCommonProperties: +# +# Properties for objects of classes derived from secret-common. +# +# @loaded: if true, the secret is loaded immediately when applying this option +# and will probably fail when processing the next option. Don't use; +# only provided for compatibility. (default: false) +# +# @format: the data format that the secret is provided in (default: raw) +# +# @keyid: the name of another secret that should be used to decrypt the +# provided data. If not present, the data is assumed to be unencrypted. +# +# @iv: the random initialization vector used for encryption of this particular +# secret. Should be a base64 encrypted string of the 16-byte IV. Mandatory +# if @keyid is given. Ignored if @keyid is absent. +# +# Features: +# @deprecated: Member @loaded is deprecated. Setting true doesn't make sense, +# and false is already the default. +# +# Since: 2.6 +## +{ 'struct': 'SecretCommonProperties', + 'data': { '*loaded': { 'type': 'bool', 'features': ['deprecated'] }, + '*format': 'QCryptoSecretFormat', + '*keyid': 'str', + '*iv': 'str' } } + +## +# @SecretProperties: +# +# Properties for secret objects. +# +# Either @data or @file must be provided, but not both. +# +# @data: the associated with the secret from +# +# @file: the filename to load the data associated with the secret from +# +# Since: 2.6 +## +{ 'struct': 'SecretProperties', + 'base': 'SecretCommonProperties', + 'data': { '*data': 'str', + '*file': 'str' } } + +## +# @SecretKeyringProperties: +# +# Properties for secret_keyring objects. +# +# @serial: serial number that identifies a key to get from the kernel +# +# Since: 5.1 +## +{ 'struct': 'SecretKeyringProperties', + 'base': 'SecretCommonProperties', + 'data': { 'serial': 'int32' } }
qapi/qom.json +5 -0
@@ -7,6 +7,7 @@ { 'include': 'authz.json' } { 'include': 'block-core.json' } { 'include': 'common.json' } +{ 'include': 'crypto.json' } ## # = QEMU Object Model (QOM)
@@ -449,6 +450,8 @@ 'rng-builtin', 'rng-egd', 'rng-random', + 'secret', + 'secret_keyring', 'throttle-group' ] }
@@ -483,6 +486,8 @@ 'rng-builtin': 'RngProperties', 'rng-egd': 'RngEgdProperties', 'rng-random': 'RngRandomProperties', + 'secret': 'SecretProperties', + 'secret_keyring': 'SecretKeyringProperties', 'throttle-group': 'ThrottleGroupProperties' } }
docs/system/deprecated.rst +11 -0
@@ -155,6 +155,17 @@ other options have been processed. This will either have no effect (if ``opened`` was the last option) or cause errors. The property is therefore useless and should not be specified. +``loaded`` property of ``secret`` and ``secret_keyring`` objects (since 6.0.0) +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +The only effect of specifying ``loaded=on`` in the command line or QMP +``object-add`` is that the secret is loaded immediately, possibly before all +other options have been processed. This will either have no effect (if +``loaded`` was the last option) or cause options to be effectively ignored as +if they were not given. The property is therefore useless and should not be +specified. + + QEMU Machine Protocol (QMP) commands ------------------------------------
Signature · 1 line
2.29.2
Re: [PATCH v2 10/31] qapi/qom: Add ObjectOptions for secret*, deprecate 'loaded'
Quoted 45 lines · Kevin Wolf
This adds a QAPI schema for the properties of the secret* objects.
The 'loaded' property doesn't seem to make sense as an external
interface: It is automatically set to true inucc->complete, and explicitly setting it to true earlier just means that additional options will be silently ignored.In other words, the 'loaded' property is useless. Mark it as deprecated in the schema from the start.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/crypto.json | 61 ++++++++++++++++++++++++++++++++++++++ qapi/qom.json | 5 ++++ docs/system/deprecated.rst | 11 +++++++ 3 files changed, 77 insertions(+)qapi/crypto.json +20
-0@@ -381,3 +381,64 @@ 'discriminator': 'format', 'data': { 'luks': 'QCryptoBlockAmendOptionsLUKS' } } + +## +# @SecretCommonProperties: +# +# Properties for objects of classes derived from secret-common. +# +# @loaded: if true, the secret is loaded immediately when applying this option +# and will probably fail when processing the next option. Don't use; +# only provided for compatibility. (default: false) +# +# @format: the data format that the secret is provided in (default: raw) +# +# @keyid: the name of another secret that should be used to decrypt the +# provided data. If not present, the data is assumed to be unencrypted. +# +# @iv: the random initialization vector used for encryption of this particular +# secret. Should be a base64 encrypted string of the 16-byte IV. Mandatory +# if @keyid is given. Ignored if @keyid is absent. +# +# Features:
qapi/crypto.json line 413
Quoted 10 lines
qapi/crypto.json +10
-0+# @deprecated: Member @loaded is deprecated. Setting true doesn't make sense, +# and false is already the default. +# +# Since: 2.6 +## +{ 'struct': 'SecretCommonProperties', + 'data': { '*loaded': { 'type': 'bool', 'features': ['deprecated'] }, + '*format': 'QCryptoSecretFormat', + '*keyid': 'str', + '*iv': 'str' } }
Matches crypto/secret_common.c:qcrypto_secret_class_init(), and I concur with the deprecation.
Quoted 8 lines
qapi/crypto.json +8
-0+ +## +# @SecretProperties: +# +# Properties for secret objects. +# +# Either @data or @file must be provided, but not both. +#
qapi/crypto.json line 431
Quoted 10 lines
qapi/crypto.json +10
-0+# @data: the associated with the secret from +# +# @file: the filename to load the data associated with the secret from +# +# Since: 2.6 +## +{ 'struct': 'SecretProperties', + 'base': 'SecretCommonProperties', + 'data': { '*data': 'str', + '*file': 'str' } }
Matches crypto/secret.c:qcrypto_secret_class_init() (ugh, we really do reuse the same static function name in two different files, but not your fault)
qapi/crypto.json line 444
Quoted 13 lines
qapi/crypto.json +13
-0+ +## +# @SecretKeyringProperties: +# +# Properties for secret_keyring objects. +# +# @serial: serial number that identifies a key to get from the kernel +# +# Since: 5.1 +## +{ 'struct': 'SecretKeyringProperties', + 'base': 'SecretCommonProperties', + 'data': { 'serial': 'int32' } }
Matches crypto/secret_keyring.c:qcrypto_secret_keyring_class_init().
Quoted 13 lines
qapi/qom.json +1
-0@@ -7,6 +7,7 @@ { 'include': 'authz.json' } { 'include': 'block-core.json' } { 'include': 'common.json' } +{ 'include': 'crypto.json' } ## # = QEMU Object Model (QOM)
qapi/qom.json line 454
Quoted 5 lines
qapi/qom.json +2
-0@@ -449,6 +450,8 @@ 'rng-builtin', 'rng-egd', 'rng-random', + 'secret', + 'secret_keyring',
What is stopping us from naming this 'secret-keyring'?
Quoted 19 lines
qapi/qom.json +2
-0'throttle-group' ] }@@ -483,6 +486,8 @@ 'rng-builtin': 'RngProperties', 'rng-egd': 'RngEgdProperties', 'rng-random': 'RngRandomProperties', + 'secret': 'SecretProperties', + 'secret_keyring': 'SecretKeyringProperties', 'throttle-group': 'ThrottleGroupProperties' } }docs/system/deprecated.rst +0
-0@@ -155,6 +155,17 @@ other options have been processed. This will either have no effect (if ``opened`` was the last option) or cause errors. The property is therefore useless and should not be specified.
docs/system/deprecated.rst other options have been processed. This will either have no effect (if · line 166
Quoted 10 lines
docs/system/deprecated.rst +9
-0+``loaded`` property of ``secret`` and ``secret_keyring`` objects (since 6.0.0) +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +The only effect of specifying ``loaded=on`` in the command line or QMP +``object-add`` is that the secret is loaded immediately, possibly before all +other options have been processed. This will either have no effect (if +``loaded`` was the last option) or cause options to be effectively ignored as +if they were not given. The property is therefore useless and should not be +specified.
May be impacted if we rename to secret-keyring (in fact, if we rename, the new name wouldn't even need the deprecated field), but that may be trickier to coordinate. So with regards to just the mechanical conversion,
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH v2 10/31] qapi/qom: Add ObjectOptions for secret*, deprecate 'loaded'
Am 26.02.2021 um 20:17 hat Eric Blake geschrieben:
Quoted 11 lines · Kevin Wolf
Quoted 10 lines
qapi/qom.json +1
-0@@ -7,6 +7,7 @@ { 'include': 'authz.json' } { 'include': 'block-core.json' } { 'include': 'common.json' } +{ 'include': 'crypto.json' }
Quoted 10 lines
qapi/qom.json line 454
Quoted 8 lines
qapi/qom.json +2
-0## # = QEMU Object Model (QOM)@@ -449,6 +450,8 @@ 'rng-builtin', 'rng-egd', 'rng-random', + 'secret', + 'secret_keyring',What is stopping us from naming this 'secret-keyring'?
That it's not the name of the QOM type, so it wouldn't be possible to create an object from it any more ('secret_keyring' would be rejected by QAPI, but 'secret-keyring' would be rejected by QOM).
If we ever want to rename the type, this might be a case where QAPI aliases could help. But I'm almost sure that there would be more compatibility concerns than just with object creation for renaming a user creatable QOM type.
Kevin
PATCH v2 11/31 qapi/qom: Add ObjectOptions for tls-*, deprecate 'loaded'
In reply to Kevin WolfThis adds a QAPI schema for the properties of the tls-* objects.
The 'loaded' property doesn't seem to make sense as an external
interface: It is automatically set to true in ucc->complete, and explicitly setting it to true earlier just means that additional options will be silently ignored.
In other words, the 'loaded' property is useless. Mark it as deprecated in the schema from the start.
--- qapi/crypto.json | 98 ++++++++++++++++++++++++++++++++++++++++++++++++ qapi/qom.json | 12 +++++- 2 files changed, 108 insertions(+), 2 deletions(-)
qapi/crypto.json +98 -0
@@ -442,3 +442,101 @@ { 'struct': 'SecretKeyringProperties', 'base': 'SecretCommonProperties', 'data': { 'serial': 'int32' } } + +## +# @TlsCredsProperties: +# +# Properties for objects of classes derived from tls-creds. +# +# @verify-peer: if true the peer credentials will be verified once the +# handshake is completed. This is a no-op for anonymous +# credentials. (default: true) +# +# @dir: the path of the directory that contains the credential files +# +# @endpoint: whether the QEMU network backend that uses the credentials will be +# acting as a client or as a server (default: client) +# +# @priority: a gnutls priority string as described at +# https://gnutls.org/manual/html_node/Priority-Strings.html +# +# Since: 2.5 +## +{ 'struct': 'TlsCredsProperties', + 'data': { '*verify-peer': 'bool', + '*dir': 'str', + '*endpoint': 'QCryptoTLSCredsEndpoint', + '*priority': 'str' } } + +## +# @TlsCredsAnonProperties: +# +# Properties for tls-creds-anon objects. +# +# @loaded: if true, the credentials are loaded immediately when applying this +# option and will ignore options that are processed later. Don't use; +# only provided for compatibility. (default: false) +# +# Features: +# @deprecated: Member @loaded is deprecated. Setting true doesn't make sense, +# and false is already the default. +# +# Since: 2.5 +## +{ 'struct': 'TlsCredsAnonProperties', + 'base': 'TlsCredsProperties', + 'data': { '*loaded': { 'type': 'bool', 'features': ['deprecated'] } } } + +## +# @TlsCredsPskProperties: +# +# Properties for tls-creds-psk objects. +# +# @loaded: if true, the credentials are loaded immediately when applying this +# option and will ignore options that are processed later. Don't use; +# only provided for compatibility. (default: false) +# +# @username: the username which will be sent to the server. For clients only. +# If absent, "qemu" is sent and the property will read back as an +# empty string. +# +# Features: +# @deprecated: Member @loaded is deprecated. Setting true doesn't make sense, +# and false is already the default. +# +# Since: 3.0 +## +{ 'struct': 'TlsCredsPskProperties', + 'base': 'TlsCredsProperties', + 'data': { '*loaded': { 'type': 'bool', 'features': ['deprecated'] }, + '*username': 'str' } } + +## +# @TlsCredsX509Properties: +# +# Properties for tls-creds-x509 objects. +# +# @loaded: if true, the credentials are loaded immediately when applying this +# option and will ignore options that are processed later. Don't use; +# only provided for compatibility. (default: false) +# +# @sanity-check: if true, perform some sanity checks before using the +# credentials (default: true) +# +# @passwordid: For the server-key.pem and client-key.pem files which contain +# sensitive private keys, it is possible to use an encrypted +# version by providing the @passwordid parameter. This provides +# the ID of a previously created secret object containing the +# password for decryption. +# +# Features: +# @deprecated: Member @loaded is deprecated. Setting true doesn't make sense, +# and false is already the default. +# +# Since: 2.5 +## +{ 'struct': 'TlsCredsX509Properties', + 'base': 'TlsCredsProperties', + 'data': { '*loaded': { 'type': 'bool', 'features': ['deprecated'] }, + '*sanity-check': 'bool', + '*passwordid': 'str' } }
qapi/qom.json +10 -2
@@ -452,7 +452,11 @@ 'rng-random', 'secret', 'secret_keyring', - 'throttle-group' + 'throttle-group', + 'tls-creds-anon', + 'tls-creds-psk', + 'tls-creds-x509', + 'tls-cipher-suites' ] } ##
@@ -488,7 +492,11 @@ 'rng-random': 'RngRandomProperties', 'secret': 'SecretProperties', 'secret_keyring': 'SecretKeyringProperties', - 'throttle-group': 'ThrottleGroupProperties' + 'throttle-group': 'ThrottleGroupProperties', + 'tls-creds-anon': 'TlsCredsAnonProperties', + 'tls-creds-psk': 'TlsCredsPskProperties', + 'tls-creds-x509': 'TlsCredsX509Properties', + 'tls-cipher-suites': 'TlsCredsProperties' } } ##
Signature · 1 line
2.29.2
Re: [PATCH v2 11/31] qapi/qom: Add ObjectOptions for tls-*, deprecate 'loaded'
Quoted 39 lines · Kevin Wolf
This adds a QAPI schema for the properties of the tls-* objects.
The 'loaded' property doesn't seem to make sense as an external
interface: It is automatically set to true inucc->complete, and explicitly setting it to true earlier just means that additional options will be silently ignored.In other words, the 'loaded' property is useless. Mark it as deprecated in the schema from the start.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/crypto.json | 98 ++++++++++++++++++++++++++++++++++++++++++++++++ qapi/qom.json | 12 +++++- 2 files changed, 108 insertions(+), 2 deletions(-)qapi/crypto.json +15
-0@@ -442,3 +442,101 @@ { 'struct': 'SecretKeyringProperties', 'base': 'SecretCommonProperties', 'data': { 'serial': 'int32' } } + +## +# @TlsCredsProperties: +# +# Properties for objects of classes derived from tls-creds. +# +# @verify-peer: if true the peer credentials will be verified once the +# handshake is completed. This is a no-op for anonymous +# credentials. (default: true) +# +# @dir: the path of the directory that contains the credential files +# +# @endpoint: whether the QEMU network backend that uses the credentials will be +# acting as a client or as a server (default: client) +#
qapi/crypto.json line 469
Quoted 10 lines
qapi/crypto.json +10
-0+# @priority: a gnutls priority string as described at +# https://gnutls.org/manual/html_node/Priority-Strings.html +# +# Since: 2.5 +## +{ 'struct': 'TlsCredsProperties', + 'data': { '*verify-peer': 'bool', + '*dir': 'str', + '*endpoint': 'QCryptoTLSCredsEndpoint', + '*priority': 'str' } }
Matches crypto/tlscreds.c:qcrypto_tls_creds_class_init().
Quoted 9 lines
qapi/crypto.json +9
-0+ +## +# @TlsCredsAnonProperties: +# +# Properties for tls-creds-anon objects. +# +# @loaded: if true, the credentials are loaded immediately when applying this +# option and will ignore options that are processed later. Don't use; +# only provided for compatibility. (default: false)
qapi/crypto.json line 488
Quoted 10 lines
qapi/crypto.json +10
-0+# +# Features: +# @deprecated: Member @loaded is deprecated. Setting true doesn't make sense, +# and false is already the default. +# +# Since: 2.5 +## +{ 'struct': 'TlsCredsAnonProperties', + 'base': 'TlsCredsProperties', + 'data': { '*loaded': { 'type': 'bool', 'features': ['deprecated'] } } }
Since we documented that 'verify-peer' is a no-op for this struct, is it worth altering our type hierarchy to make it explicit, as in:
TlsCredsCommonProperties - dir, endpoint, priority TlsCredsProperties - TlsCredsCommonProperties + verify-peer TlsCredsAnonProperties - TlsCredsCommonProperties + loaded TlsCredsPskProperties - TlsCredsProperties + loaded, username
But even if not, this matches crypto/tlscredsanon.c:qcrypto_tls_creds_anon_class_init().
Quoted 14 lines
qapi/crypto.json +14
-0+ +## +# @TlsCredsPskProperties: +# +# Properties for tls-creds-psk objects. +# +# @loaded: if true, the credentials are loaded immediately when applying this +# option and will ignore options that are processed later. Don't use; +# only provided for compatibility. (default: false) +# +# @username: the username which will be sent to the server. For clients only. +# If absent, "qemu" is sent and the property will read back as an +# empty string. +#
qapi/crypto.json line 512
Quoted 10 lines
qapi/crypto.json +10
-0+# Features: +# @deprecated: Member @loaded is deprecated. Setting true doesn't make sense, +# and false is already the default. +# +# Since: 3.0 +## +{ 'struct': 'TlsCredsPskProperties', + 'base': 'TlsCredsProperties', + 'data': { '*loaded': { 'type': 'bool', 'features': ['deprecated'] }, + '*username': 'str' } }
This matches crypto/tlscredspsk.c:qcrypto_tls_creds_psk_class_init().
Do we want to use QAPI type inheritance to declare a union where 'endpoint' is the union discriminator, and 'username' is only present for 'endpoint':'client'? (Hmm, we'd have to improve the QAPI code generator to allow a flat union as the branch of yet another flat union...)
Quoted 20 lines
qapi/crypto.json +20
-0+ +## +# @TlsCredsX509Properties: +# +# Properties for tls-creds-x509 objects. +# +# @loaded: if true, the credentials are loaded immediately when applying this +# option and will ignore options that are processed later. Don't use; +# only provided for compatibility. (default: false) +# +# @sanity-check: if true, perform some sanity checks before using the +# credentials (default: true) +# +# @passwordid: For the server-key.pem and client-key.pem files which contain +# sensitive private keys, it is possible to use an encrypted +# version by providing the @passwordid parameter. This provides +# the ID of a previously created secret object containing the +# password for decryption. +# +# Features:
qapi/crypto.json line 542
Quoted 10 lines
qapi/crypto.json +10
-0+# @deprecated: Member @loaded is deprecated. Setting true doesn't make sense, +# and false is already the default. +# +# Since: 2.5 +## +{ 'struct': 'TlsCredsX509Properties', + 'base': 'TlsCredsProperties', + 'data': { '*loaded': { 'type': 'bool', 'features': ['deprecated'] }, + '*sanity-check': 'bool', + '*passwordid': 'str' } }
This matches crypto/tlscredsx509.c:qcrypto_tls_creds_x509_class_init().
Quoted 5 lines
qapi/qom.json +0
-0
qapi/qom.json line 459
Quoted 9 lines
qapi/qom.json +5
-1@@ -452,7 +452,11 @@ 'rng-random', 'secret', 'secret_keyring', - 'throttle-group' + 'throttle-group', + 'tls-creds-anon', + 'tls-creds-psk', + 'tls-creds-x509', + 'tls-cipher-suites'
Matches crypto/tls-cipher-suites.c:qcrypto_tls_cipher_suites_class_init().
qapi/qom.json line 499
Quoted 13 lines
qapi/qom.json +5
-1] } ##@@ -488,7 +492,11 @@ 'rng-random': 'RngRandomProperties', 'secret': 'SecretProperties', 'secret_keyring': 'SecretKeyringProperties', - 'throttle-group': 'ThrottleGroupProperties' + 'throttle-group': 'ThrottleGroupProperties', + 'tls-creds-anon': 'TlsCredsAnonProperties', + 'tls-creds-psk': 'TlsCredsPskProperties', + 'tls-creds-x509': 'TlsCredsX509Properties', + 'tls-cipher-suites': 'TlsCredsProperties'
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH v2 11/31] qapi/qom: Add ObjectOptions for tls-*, deprecate 'loaded'
Am 26.02.2021 um 20:33 hat Eric Blake geschrieben:
Quoted 76 lines · Kevin Wolf
Quoted 39 lines
This adds a QAPI schema for the properties of the tls-* objects.
The 'loaded' property doesn't seem to make sense as an external
interface: It is automatically set to true inucc->complete, and explicitly setting it to true earlier just means that additional options will be silently ignored.In other words, the 'loaded' property is useless. Mark it as deprecated in the schema from the start.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/crypto.json | 98 ++++++++++++++++++++++++++++++++++++++++++++++++ qapi/qom.json | 12 +++++- 2 files changed, 108 insertions(+), 2 deletions(-)qapi/crypto.json +15
-0@@ -442,3 +442,101 @@ { 'struct': 'SecretKeyringProperties', 'base': 'SecretCommonProperties', 'data': { 'serial': 'int32' } } + +## +# @TlsCredsProperties: +# +# Properties for objects of classes derived from tls-creds. +# +# @verify-peer: if true the peer credentials will be verified once the +# handshake is completed. This is a no-op for anonymous +# credentials. (default: true) +# +# @dir: the path of the directory that contains the credential files +# +# @endpoint: whether the QEMU network backend that uses the credentials will be +# acting as a client or as a server (default: client) +#qapi/crypto.json line 469
Quoted 10 lines
qapi/crypto.json +10
-0+# @priority: a gnutls priority string as described at +# https://gnutls.org/manual/html_node/Priority-Strings.html +# +# Since: 2.5 +## +{ 'struct': 'TlsCredsProperties', + 'data': { '*verify-peer': 'bool', + '*dir': 'str', + '*endpoint': 'QCryptoTLSCredsEndpoint', + '*priority': 'str' } }Matches crypto/tlscreds.c:qcrypto_tls_creds_class_init().
Quoted 9 lines
qapi/crypto.json +9
-0+ +## +# @TlsCredsAnonProperties: +# +# Properties for tls-creds-anon objects. +# +# @loaded: if true, the credentials are loaded immediately when applying this +# option and will ignore options that are processed later. Don't use; +# only provided for compatibility. (default: false)qapi/crypto.json line 488
Quoted 10 lines
qapi/crypto.json +10
-0+# +# Features: +# @deprecated: Member @loaded is deprecated. Setting true doesn't make sense, +# and false is already the default. +# +# Since: 2.5 +## +{ 'struct': 'TlsCredsAnonProperties', + 'base': 'TlsCredsProperties', + 'data': { '*loaded': { 'type': 'bool', 'features': ['deprecated'] } } }Since we documented that 'verify-peer' is a no-op for this struct, is it worth altering our type hierarchy to make it explicit, as in:
Quoted 7 lines
TlsCredsCommonProperties - dir, endpoint, priority TlsCredsProperties - TlsCredsCommonProperties + verify-peer TlsCredsAnonProperties - TlsCredsCommonProperties + loaded TlsCredsPskProperties - TlsCredsProperties + loaded, username
But even if not, this matches crypto/tlscredsanon.c:qcrypto_tls_creds_anon_class_init().
We can't turn a no-op into an error without a deprecation period.
Quoted 27 lines
Quoted 14 lines
qapi/crypto.json +14
-0+ +## +# @TlsCredsPskProperties: +# +# Properties for tls-creds-psk objects. +# +# @loaded: if true, the credentials are loaded immediately when applying this +# option and will ignore options that are processed later. Don't use; +# only provided for compatibility. (default: false) +# +# @username: the username which will be sent to the server. For clients only. +# If absent, "qemu" is sent and the property will read back as an +# empty string. +#qapi/crypto.json line 512
Quoted 10 lines
qapi/crypto.json +10
-0+# Features: +# @deprecated: Member @loaded is deprecated. Setting true doesn't make sense, +# and false is already the default. +# +# Since: 3.0 +## +{ 'struct': 'TlsCredsPskProperties', + 'base': 'TlsCredsProperties', + 'data': { '*loaded': { 'type': 'bool', 'features': ['deprecated'] }, + '*username': 'str' } }This matches crypto/tlscredspsk.c:qcrypto_tls_creds_psk_class_init().
Quoted 5 lines
Do we want to use QAPI type inheritance to declare a union where 'endpoint' is the union discriminator, and 'username' is only present for 'endpoint':'client'? (Hmm, we'd have to improve the QAPI code generator to allow a flat union as the branch of yet another flat union...)
Probably not now then.
It also has the same problem as above, but I guess you could use the deprecation period to build the required QAPI infrastructure. :-)
Kevin
PATCH v2 12/31 qapi/qom: Add ObjectOptions for can-*
In reply to Kevin WolfThis adds a QAPI schema for the properties of the can-* objects.
can-bus doesn't have any properties, so it only needs to be added to the ObjectType enum without adding a new branch to ObjectOptions.
--- qapi/qom.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
qapi/qom.json +18 -0
@@ -207,6 +207,21 @@ 'returns': [ 'ObjectPropertyInfo' ], 'allow-preconfig': true } +## +# @CanHostSocketcanProperties: +# +# Properties for can-host-socketcan objects. +# +# @if: interface name of the host system CAN bus to connect to +# +# @canbus: object ID of the can-bus object to connect to the host interface +# +# Since: 2.12 +## +{ 'struct': 'CanHostSocketcanProperties', + 'data': { 'if': 'str', + 'canbus': 'str' } } + ## # @CryptodevBackendProperties: #
@@ -439,6 +454,8 @@ 'authz-listfile', 'authz-pam', 'authz-simple', + 'can-bus', + 'can-host-socketcan', 'cryptodev-backend', 'cryptodev-backend-builtin', 'cryptodev-vhost-user',
@@ -479,6 +496,7 @@ 'authz-listfile': 'AuthZListFileProperties', 'authz-pam': 'AuthZPAMProperties', 'authz-simple': 'AuthZSimpleProperties', + 'can-host-socketcan': 'CanHostSocketcanProperties', 'cryptodev-backend': 'CryptodevBackendProperties', 'cryptodev-backend-builtin': 'CryptodevBackendProperties', 'cryptodev-vhost-user': 'CryptodevVhostUserProperties',
Signature · 1 line
2.29.2
Re: [PATCH v2 12/31] qapi/qom: Add ObjectOptions for can-*
Quoted 4 lines · Kevin Wolf
This adds a QAPI schema for the properties of the can-* objects.
can-bus doesn't have any properties, so it only needs to be added to the ObjectType enum without adding a new branch to ObjectOptions.
I somewhat prefer
'can-bus': {},
to make it explicit that we thought about it, but since we allow defaulted union branches, your approach works too.
Quoted 19 lines
Signed-off-by Kevin Wolf <[email protected]>--- qapi/qom.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)qapi/qom.json +5
-0@@ -207,6 +207,21 @@ 'returns': [ 'ObjectPropertyInfo' ], 'allow-preconfig': true } +## +# @CanHostSocketcanProperties: +# +# Properties for can-host-socketcan objects. +#
qapi/qom.json line 224
Quoted 10 lines
qapi/qom.json +10
-0+# @if: interface name of the host system CAN bus to connect to +# +# @canbus: object ID of the can-bus object to connect to the host interface +# +# Since: 2.12 +## +{ 'struct': 'CanHostSocketcanProperties', + 'data': { 'if': 'str', + 'canbus': 'str' } } +
Okay, matches net/can/can_socketcan.c:can_host_socketcan_class_init() (after chasing down the parent class in net/can/can_host.c:can_host_class_init() to find "canbus").
Quoted 14 lines
qapi/qom.json +2
-0## # @CryptodevBackendProperties: #@@ -439,6 +454,8 @@ 'authz-listfile', 'authz-pam', 'authz-simple', + 'can-bus', + 'can-host-socketcan', 'cryptodev-backend', 'cryptodev-backend-builtin', 'cryptodev-vhost-user',
qapi/qom.json line 502
Quoted 7 lines
qapi/qom.json +1
-0@@ -479,6 +496,7 @@ 'authz-listfile': 'AuthZListFileProperties', 'authz-pam': 'AuthZPAMProperties', 'authz-simple': 'AuthZSimpleProperties', + 'can-host-socketcan': 'CanHostSocketcanProperties', 'cryptodev-backend': 'CryptodevBackendProperties', 'cryptodev-backend-builtin': 'CryptodevBackendProperties', 'cryptodev-vhost-user': 'CryptodevVhostUserProperties',
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH v2 12/31] qapi/qom: Add ObjectOptions for can-*
Am 26.02.2021 um 20:42 hat Eric Blake geschrieben:
Quoted 6 lines · Kevin Wolf
Quoted 4 lines
This adds a QAPI schema for the properties of the can-* objects.
can-bus doesn't have any properties, so it only needs to be added to the ObjectType enum without adding a new branch to ObjectOptions.
Quoted 6 lines
I somewhat prefer
'can-bus': {},
to make it explicit that we thought about it, but since we allow defaulted union branches, your approach works too.
The QAPI generator disagrees:
../qapi/qom.json: In union 'ObjectOptions':../qapi/qom.json:492: 'data' member 'can-bus' misses key 'type'
It seems we can't use inline definitions of struct types because we already use that for the extended description of branch types. And adding a whole named struct without content is probably a bit too much?
Kevin
Re: [PATCH v2 12/31] qapi/qom: Add ObjectOptions for can-*
Quoted 14 lines · Kevin Wolf
Am 26.02.2021 um 20:42 hat Eric Blake geschrieben:
Quoted 6 lines · Kevin Wolf
Quoted 4 lines
This adds a QAPI schema for the properties of the can-* objects.
can-bus doesn't have any properties, so it only needs to be added to the ObjectType enum without adding a new branch to ObjectOptions.
Quoted 6 lines
I somewhat prefer
'can-bus': {},
to make it explicit that we thought about it, but since we allow defaulted union branches, your approach works too.
Quoted 8 lines
The QAPI generator disagrees:
../qapi/qom.json: In union 'ObjectOptions':../qapi/qom.json:492: 'data' member 'can-bus' misses key 'type'It seems we can't use inline definitions of struct types because we already use that for the extended description of branch types. And adding a whole named struct without content is probably a bit too much?
Oh, maybe I'm remembering an experiment I did with a patch to add that once, but it never went anywhere, since in the meantime we added the 'any enum not listed is acceptable as adding no additional members'. So my preference stems from (faulty?) memory on my part, and your patch is fine as is.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 13/31 qapi/qom: Add ObjectOptions for colo-compare
In reply to Kevin WolfThis adds a QAPI schema for the properties of the colo-compare object.
--- qapi/qom.json | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
qapi/qom.json +49 -0
@@ -222,6 +222,53 @@ 'data': { 'if': 'str', 'canbus': 'str' } } +## +# @ColoCompareProperties: +# +# Properties for colo-compare objects. +# +# @primary_in: name of the character device backend to use for the primary +# input (incoming packets are redirected to @outdev) +# +# @secondary_in: name of the character device backend to use for secondary +# input (incoming packets are only compared to the input on +# @primary_in and then dropped) +# +# @outdev: name of the character device backend to use for output +# +# @iothread: name of the iothread to run in +# +# @notify_dev: name of the character device backend to be used to communicate +# with the remote colo-frame (only for Xen COLO) +# +# @compare_timeout: the maximum time to hold a packet from @primary_in for +# comparison with an incoming packet on @secondary_in in +# milliseconds (default: 3000) +# +# @expired_scan_cycle: the interval at which colo-compare checks whether +# packets from @primary have timed out, in milliseconds +# (default: 3000) +# +# @max_queue_size: the maximum number of packets to keep in the queue for +# comparing with incoming packets from @secondary_in. If the +# queue is full and addtional packets are received, the +# addtional packets are dropped. (default: 1024) +# +# @vnet_hdr_support: if true, vnet header support is enabled (default: false) +# +# Since: 2.8 +## +{ 'struct': 'ColoCompareProperties', + 'data': { 'primary_in': 'str', + 'secondary_in': 'str', + 'outdev': 'str', + 'iothread': 'str', + '*notify_dev': 'str', + '*compare_timeout': 'uint64', + '*expired_scan_cycle': 'uint32', + '*max_queue_size': 'uint32', + '*vnet_hdr_support': 'bool' } } + ## # @CryptodevBackendProperties: #
@@ -456,6 +503,7 @@ 'authz-simple', 'can-bus', 'can-host-socketcan', + 'colo-compare', 'cryptodev-backend', 'cryptodev-backend-builtin', 'cryptodev-vhost-user',
@@ -497,6 +545,7 @@ 'authz-pam': 'AuthZPAMProperties', 'authz-simple': 'AuthZSimpleProperties', 'can-host-socketcan': 'CanHostSocketcanProperties', + 'colo-compare': 'ColoCompareProperties', 'cryptodev-backend': 'CryptodevBackendProperties', 'cryptodev-backend-builtin': 'CryptodevBackendProperties', 'cryptodev-vhost-user': 'CryptodevVhostUserProperties',
Signature · 1 line
2.29.2
Re: [PATCH v2 13/31] qapi/qom: Add ObjectOptions for colo-compare
Quoted 17 lines · Kevin Wolf
This adds a QAPI schema for the properties of the colo-compare object.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/qom.json | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)qapi/qom.json +2
-0@@ -222,6 +222,53 @@ 'data': { 'if': 'str', 'canbus': 'str' } } +## +# @ColoCompareProperties:
qapi/qom.json line 236
Quoted 10 lines
qapi/qom.json +10
-0+# +# Properties for colo-compare objects. +# +# @primary_in: name of the character device backend to use for the primary +# input (incoming packets are redirected to @outdev) +# +# @secondary_in: name of the character device backend to use for secondary +# input (incoming packets are only compared to the input on +# @primary_in and then dropped) +#
Idea for future improvement: use aliases to shift over to 'primary-in', 'secondary-in', and so on as our preferred name. But not for this patch, which is a mechanical conversion of what exists.
Quoted 24 lines
qapi/qom.json +24
-0+# @outdev: name of the character device backend to use for output +# +# @iothread: name of the iothread to run in +# +# @notify_dev: name of the character device backend to be used to communicate +# with the remote colo-frame (only for Xen COLO) +# +# @compare_timeout: the maximum time to hold a packet from @primary_in for +# comparison with an incoming packet on @secondary_in in +# milliseconds (default: 3000) +# +# @expired_scan_cycle: the interval at which colo-compare checks whether +# packets from @primary have timed out, in milliseconds +# (default: 3000) +# +# @max_queue_size: the maximum number of packets to keep in the queue for +# comparing with incoming packets from @secondary_in. If the +# queue is full and addtional packets are received, the +# addtional packets are dropped. (default: 1024) +# +# @vnet_hdr_support: if true, vnet header support is enabled (default: false) +# +# Since: 2.8 +##
qapi/qom.json line 270
Quoted 10 lines
qapi/qom.json +10
-0+{ 'struct': 'ColoCompareProperties', + 'data': { 'primary_in': 'str', + 'secondary_in': 'str', + 'outdev': 'str', + 'iothread': 'str', + '*notify_dev': 'str', + '*compare_timeout': 'uint64', + '*expired_scan_cycle': 'uint32', + '*max_queue_size': 'uint32', + '*vnet_hdr_support': 'bool' } }
Matches net/colo-compare.c:colo_compare_init().
Quoted 13 lines
qapi/qom.json +2
-0+ ## # @CryptodevBackendProperties: #@@ -456,6 +503,7 @@ 'authz-simple', 'can-bus', 'can-host-socketcan', + 'colo-compare', 'cryptodev-backend', 'cryptodev-backend-builtin', 'cryptodev-vhost-user',
qapi/qom.json line 551
Quoted 7 lines
qapi/qom.json +1
-0@@ -497,6 +545,7 @@ 'authz-pam': 'AuthZPAMProperties', 'authz-simple': 'AuthZSimpleProperties', 'can-host-socketcan': 'CanHostSocketcanProperties', + 'colo-compare': 'ColoCompareProperties', 'cryptodev-backend': 'CryptodevBackendProperties', 'cryptodev-backend-builtin': 'CryptodevBackendProperties', 'cryptodev-vhost-user': 'CryptodevVhostUserProperties',
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 14/31 qapi/qom: Add ObjectOptions for filter-*
In reply to Kevin WolfThis adds a QAPI schema for the properties of the filter-* objects.
Some parts of the interface (in particular NetfilterProperties.position) are very unusual for QAPI, but for now just describe the existing interface.
net.json can't be included in qom.json because the storage daemon doesn't have it. NetFilterDirection is still required in the new object property definitions in qom.json, so move this enum to common.json.
--- qapi/common.json | 20 +++++++ qapi/net.json | 20 ------- qapi/qom.json | 143 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 163 insertions(+), 20 deletions(-)
qapi/common.json +20 -0
@@ -165,3 +165,23 @@ ## { 'enum': 'HostMemPolicy', 'data': [ 'default', 'preferred', 'bind', 'interleave' ] } + +## +# @NetFilterDirection: +# +# Indicates whether a netfilter is attached to a netdev's transmit queue or +# receive queue or both. +# +# @all: the filter is attached both to the receive and the transmit +# queue of the netdev (default). +# +# @rx: the filter is attached to the receive queue of the netdev, +# where it will receive packets sent to the netdev. +# +# @tx: the filter is attached to the transmit queue of the netdev, +# where it will receive packets sent by the netdev. +# +# Since: 2.5 +## +{ 'enum': 'NetFilterDirection', + 'data': [ 'all', 'rx', 'tx' ] }
qapi/net.json +0 -20
@@ -492,26 +492,6 @@ 'vhost-user': 'NetdevVhostUserOptions', 'vhost-vdpa': 'NetdevVhostVDPAOptions' } } -## -# @NetFilterDirection: -# -# Indicates whether a netfilter is attached to a netdev's transmit queue or -# receive queue or both. -# -# @all: the filter is attached both to the receive and the transmit -# queue of the netdev (default). -# -# @rx: the filter is attached to the receive queue of the netdev, -# where it will receive packets sent to the netdev. -# -# @tx: the filter is attached to the transmit queue of the netdev, -# where it will receive packets sent by the netdev. -# -# Since: 2.5 -## -{ 'enum': 'NetFilterDirection', - 'data': [ 'all', 'rx', 'tx' ] } - ## # @RxState: #
qapi/qom.json +143 -0
161 lines not on this page · raw message
Signature · 1 line
2.29.2
Re: [PATCH v2 14/31] qapi/qom: Add ObjectOptions for filter-*
Quoted 38 lines · Kevin Wolf
This adds a QAPI schema for the properties of the filter-* objects.
Some parts of the interface (in particular NetfilterProperties.position) are very unusual for QAPI, but for now just describe the existing interface.
net.json can't be included in qom.json because the storage daemon doesn't have it. NetFilterDirection is still required in the new object property definitions in qom.json, so move this enum to common.json.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/common.json | 20 +++++++ qapi/net.json | 20 ------- qapi/qom.json | 143 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 163 insertions(+), 20 deletions(-)+++
b/qapi/qom.jsonqapi/qom.json +15
-0@@ -313,6 +313,137 @@ 'data': { 'addr': 'str' , '*id-list': 'str' } } +## +# @NetfilterInsert: +# +# Indicates where to insert a netfilter relative to a given other filter. +# +# @before: insert before the specified filter +# +# @behind: insert behind the specified filter +# +# Since: 5.0 +## +{ 'enum': 'NetfilterInsert', + 'data': [ 'before', 'behind' ] } + +##
qapi/qom.json line 340
Quoted 10 lines
qapi/qom.json +10
-0+# @NetfilterProperties: +# +# Properties for objects of classes derived from netfilter. +# +# @netdev: id of the network device backend to filter +# +# @queue: indicates which queue(s) to filter (default: all) +# +# @status: indicates whether the filter is enabled ("on") or disabled ("off") +# (default: "on")
An enum would be nicer than 'str', but your commit message is accurate.
qapi/qom.json line 350
Quoted 10 lines
qapi/qom.json +10
-0+# +# @position: specifies where the filter should be inserted in the filter list. +# "head" means the filter is inserted at the head of the filter list, +# before any existing filters. +# "tail" means the filter is inserted at the tail of the filter list, +# behind any existing filters (default). +# "id=<id>" means the filter is inserted before or behind the filter +# specified by <id>, depending on the @insert property. +# (default: "tail") +#
Wow, you're not kidding about this not being typical QAPI. Oh well.
qapi/qom.json line 352
Quoted 2 lines
qapi/qom.json +2
-0+# @insert: where to insert the filter relative to the filter given in @position. +# Ignored if @position is "head" or "tail". (default: behind)
Back to the question of if it is worth updating the QAPI generator to allow a flat union as the branch of yet another flat union. If we did that, we could have (untested):
{ 'enum': 'NetfilterPosition', 'data': [ 'head', 'tail', 'id' ] } { 'union': 'NetfilterBase',
'base': { 'position': 'NetfilterPosition',
'netdev'..., 'queue', 'status'... },
'discriminator': 'position',
'data': { 'head': {}, 'tail': {},
'id': { '*insert': 'NetfilterInsert', 'id': 'str' } }but that is a change to our existing id=xyz parsing, so we may need an alias or deprecation period...
Quoted 13 lines
qapi/qom.json +13
-0+# +# Since: 2.5 +## +{ 'struct': 'NetfilterProperties', + 'data': { 'netdev': 'str', + '*queue': 'NetFilterDirection', + '*status': 'str', + '*position': 'str', + '*insert': 'NetfilterInsert' } } + +## +# @FilterBufferProperties: +#
qapi/qom.json line 375
Quoted 10 lines
qapi/qom.json +10
-0+# Properties for filter-buffer objects. +# +# @interval: a non-zero interval in microseconds. All packets arriving in the +# given interval are delayed until the end of the interval. +# +# Since: 2.5 +## +{ 'struct': 'FilterBufferProperties', + 'base': 'NetfilterProperties', + 'data': { 'interval': 'uint32' } }
matches net/filter-buffer.c:filter_buffer_class_init().
Quoted 6 lines
qapi/qom.json +6
-0+ +## +# @FilterDumpProperties: +# +# Properties for filter-dump objects. +#
qapi/qom.json line 391
Quoted 10 lines
qapi/qom.json +10
-0+# @file: the filename where the dumped packets should be stored +# +# @maxlen: maximum number of bytes in a packet that are stored (default: 65536) +# +# Since: 2.5 +## +{ 'struct': 'FilterDumpProperties', + 'base': 'NetfilterProperties', + 'data': { 'file': 'str', + '*maxlen': 'uint32' } }
Matches net/dump.c:filter_dump_class_init().
Quoted 7 lines
qapi/qom.json +7
-0+ +## +# @FilterMirrorProperties: +# +# Properties for filter-mirror objects. +# +# @outdev: the name of a character device backend to which all incoming packets
qapi/qom.json line 408
Quoted 10 lines
qapi/qom.json +10
-0+# are mirrored +# +# @vnet_hdr_support: if true, vnet header support is enabled (default: false) +# +# Since: 2.6 +## +{ 'struct': 'FilterMirrorProperties', + 'base': 'NetfilterProperties', + 'data': { 'outdev': 'str', + '*vnet_hdr_support': 'bool' } }
Matches filter-mirror.c:filter_mirror_class_init(). For the future, can we rename to vnet-hdr-support?
Quoted 14 lines
qapi/qom.json +14
-0+ +## +# @FilterRedirectorProperties: +# +# Properties for filter-redirector objects. +# +# At least one of @indev or @outdev must be present. If both are present, they +# must not refer to the same character device backend. +# +# @indev: the name of a character device backend from which packets are +# received and redirected to the filtered network device +# +# @outdev: the name of a character device backend to which all incoming packets +# are redirected
qapi/qom.json line 432
Quoted 10 lines
qapi/qom.json +10
-0+# +# @vnet_hdr_support: if true, vnet header support is enabled (default: false) +# +# Since: 2.6 +## +{ 'struct': 'FilterRedirectorProperties', + 'base': 'NetfilterProperties', + 'data': { '*indev': 'str', + '*outdev': 'str', + '*vnet_hdr_support': 'bool' } }
Matches net/filter-mirror.c:filter_redirector_class_init().
Quoted 4 lines
qapi/qom.json +4
-0+ +## +# @FilterRewriterProperties: +#
qapi/qom.json line 446
Quoted 10 lines
qapi/qom.json +10
-0+# Properties for filter-rewriter objects. +# +# @vnet_hdr_support: if true, vnet header support is enabled (default: false) +# +# Since: 2.8 +## +{ 'struct': 'FilterRewriterProperties', + 'base': 'NetfilterProperties', + 'data': { '*vnet_hdr_support': 'bool' } } +
Matches net/filter-rewriter.c:filter_rewriter_class_init().
Quoted 20 lines
qapi/qom.json +6
-0## # @IothreadProperties: #@@ -508,6 +639,12 @@ 'cryptodev-backend-builtin', 'cryptodev-vhost-user', 'dbus-vmstate', + 'filter-buffer', + 'filter-dump', + 'filter-mirror', + 'filter-redirector', + 'filter-replay', + 'filter-rewriter', 'iothread', 'memory-backend-file', 'memory-backend-memfd',@@ -550,6 +687,12 @@ 'cryptodev-backend-builtin': 'CryptodevBackendProperties', 'cryptodev-vhost-user': 'CryptodevVhostUserProperties',
qapi/qom.json line 698
Quoted 10 lines
qapi/qom.json +6
-0'dbus-vmstate': 'DBusVMStateProperties', + 'filter-buffer': 'FilterBufferProperties', + 'filter-dump': 'FilterDumpProperties', + 'filter-mirror': 'FilterMirrorProperties', + 'filter-redirector': 'FilterRedirectorProperties', + 'filter-replay': 'NetfilterProperties', + 'filter-rewriter': 'FilterRewriterProperties', 'iothread': 'IothreadProperties', 'memory-backend-file': 'MemoryBackendFileProperties', 'memory-backend-memfd': 'MemoryBackendMemfdProperties',
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 15/31 qapi/qom: Add ObjectOptions for pr-manager-helper
In reply to Kevin WolfThis adds a QAPI schema for the properties of the pr-manager-helper object.
--- qapi/qom.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
qapi/qom.json +14 -0
@@ -575,6 +575,18 @@ '*hugetlbsize': 'size', '*seal': 'bool' } } +## +# @PrManagerHelperProperties: +# +# Properties for pr-manager-helper objects. +# +# @path: the path to a Unix domain socket for connecting to the external helper +# +# Since: 2.11 +## +{ 'struct': 'PrManagerHelperProperties', + 'data': { 'path': 'str' } } + ## # @RngProperties: #
@@ -649,6 +661,7 @@ 'memory-backend-file', 'memory-backend-memfd', 'memory-backend-ram', + 'pr-manager-helper', 'rng-builtin', 'rng-egd', 'rng-random',
@@ -697,6 +710,7 @@ 'memory-backend-file': 'MemoryBackendFileProperties', 'memory-backend-memfd': 'MemoryBackendMemfdProperties', 'memory-backend-ram': 'MemoryBackendProperties', + 'pr-manager-helper': 'PrManagerHelperProperties', 'rng-builtin': 'RngProperties', 'rng-egd': 'RngEgdProperties', 'rng-random': 'RngRandomProperties',
Signature · 1 line
2.29.2
Re: [PATCH v2 15/31] qapi/qom: Add ObjectOptions for pr-manager-helper
Quoted 18 lines · Kevin Wolf
This adds a QAPI schema for the properties of the pr-manager-helper object.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/qom.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+)qapi/qom.json +2
-0@@ -575,6 +575,18 @@ '*hugetlbsize': 'size', '*seal': 'bool' } } +## +# @PrManagerHelperProperties:
qapi/qom.json line 589
Quoted 10 lines
qapi/qom.json +10
-0+# +# Properties for pr-manager-helper objects. +# +# @path: the path to a Unix domain socket for connecting to the external helper +# +# Since: 2.11 +## +{ 'struct': 'PrManagerHelperProperties', + 'data': { 'path': 'str' } } +
Matches scsi/pr-manager-helper.c:pr_manager_helper_class_init().
Quoted 13 lines
qapi/qom.json +1
-0## # @RngProperties: #@@ -649,6 +661,7 @@ 'memory-backend-file', 'memory-backend-memfd', 'memory-backend-ram', + 'pr-manager-helper', 'rng-builtin', 'rng-egd', 'rng-random',
qapi/qom.json line 716
Quoted 7 lines
qapi/qom.json +1
-0@@ -697,6 +710,7 @@ 'memory-backend-file': 'MemoryBackendFileProperties', 'memory-backend-memfd': 'MemoryBackendMemfdProperties', 'memory-backend-ram': 'MemoryBackendProperties', + 'pr-manager-helper': 'PrManagerHelperProperties', 'rng-builtin': 'RngProperties', 'rng-egd': 'RngEgdProperties', 'rng-random': 'RngRandomProperties',
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 16/31 qapi/qom: Add ObjectOptions for confidential-guest-support
In reply to Kevin WolfThis adds a QAPI schema for the properties of the objects implementing the confidential-guest-support interface.
pef-guest and s390x-pv-guest don't have any properties, so they only need to be added to the ObjectType enum without adding a new branch to ObjectOptions.
--- qapi/qom.json | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
qapi/qom.json +37 -0
@@ -633,6 +633,38 @@ 'base': 'RngProperties', 'data': { '*filename': 'str' } } +## +# @SevGuestProperties: +# +# Properties for sev-guest objects. +# +# @sev-device: SEV device to use (default: "/dev/sev") +# +# @dh-cert-file: guest owners DH certificate (encoded with base64) +# +# @session-file: guest owners session parameters (encoded with base64) +# +# @policy: SEV policy value (default: 0x1) +# +# @handle: SEV firmware handle (default: 0) +# +# @cbitpos: C-bit location in page table entry (default: 0) +# +# @reduced-phys-bits: number of bits in physical addresses that become +# unavailable when SEV is enabled +# +# Since: 2.12 +## +{ 'struct': 'SevGuestProperties', + 'data': { '*sev-device': 'str', + '*dh-cert-file': 'str', + '*session-file': 'str', + '*policy': 'uint32', + '*handle': 'uint32', + '*cbitpos': 'uint32', + 'reduced-phys-bits': 'uint32' }, + 'if': 'defined(CONFIG_SEV)' } + ## # @ObjectType: #
@@ -661,12 +693,15 @@ 'memory-backend-file', 'memory-backend-memfd', 'memory-backend-ram', + {'name': 'pef-guest', 'if': 'defined(CONFIG_PSERIES)' }, 'pr-manager-helper', 'rng-builtin', 'rng-egd', 'rng-random', 'secret', 'secret_keyring', + {'name': 'sev-guest', 'if': 'defined(CONFIG_SEV)' }, + 's390-pv-guest', 'throttle-group', 'tls-creds-anon', 'tls-creds-psk',
@@ -716,6 +751,8 @@ 'rng-random': 'RngRandomProperties', 'secret': 'SecretProperties', 'secret_keyring': 'SecretKeyringProperties', + 'sev-guest': { 'type': 'SevGuestProperties', + 'if': 'defined(CONFIG_SEV)' }, 'throttle-group': 'ThrottleGroupProperties', 'tls-creds-anon': 'TlsCredsAnonProperties', 'tls-creds-psk': 'TlsCredsPskProperties',
Signature · 1 line
2.29.2
Re: [PATCH v2 16/31] qapi/qom: Add ObjectOptions for confidential-guest-support
Quoted 58 lines · * Kevin Wolf ([email protected]) wrote:
This adds a QAPI schema for the properties of the objects implementing the confidential-guest-support interface.
pef-guest and s390x-pv-guest don't have any properties, so they only need to be added to the ObjectType enum without adding a new branch to ObjectOptions.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/qom.json | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)qapi/qom.json +32
-0@@ -633,6 +633,38 @@ 'base': 'RngProperties', 'data': { '*filename': 'str' } } +## +# @SevGuestProperties: +# +# Properties for sev-guest objects. +# +# @sev-device: SEV device to use (default: "/dev/sev") +# +# @dh-cert-file: guest owners DH certificate (encoded with base64) +# +# @session-file: guest owners session parameters (encoded with base64) +# +# @policy: SEV policy value (default: 0x1) +# +# @handle: SEV firmware handle (default: 0) +# +# @cbitpos: C-bit location in page table entry (default: 0) +# +# @reduced-phys-bits: number of bits in physical addresses that become +# unavailable when SEV is enabled +# +# Since: 2.12 +## +{ 'struct': 'SevGuestProperties', + 'data': { '*sev-device': 'str', + '*dh-cert-file': 'str', + '*session-file': 'str', + '*policy': 'uint32', + '*handle': 'uint32', + '*cbitpos': 'uint32', + 'reduced-phys-bits': 'uint32' }, + 'if': 'defined(CONFIG_SEV)' } + ## # @ObjectType: #@@ -661,12 +693,15 @@ 'memory-backend-file', 'memory-backend-memfd',
qapi/qom.json line 704
Quoted 10 lines
qapi/qom.json +3
-0'memory-backend-ram', + {'name': 'pef-guest', 'if': 'defined(CONFIG_PSERIES)' }, 'pr-manager-helper', 'rng-builtin', 'rng-egd', 'rng-random', 'secret', 'secret_keyring', + {'name': 'sev-guest', 'if': 'defined(CONFIG_SEV)' }, + 's390-pv-guest',
If pef-guest is conditional on PSERIES< shouldn't this be dependent on s390?
Dave
Quoted 15 lines
qapi/qom.json +2
-0'throttle-group', 'tls-creds-anon', 'tls-creds-psk',@@ -716,6 +751,8 @@ 'rng-random': 'RngRandomProperties', 'secret': 'SecretProperties', 'secret_keyring': 'SecretKeyringProperties', + 'sev-guest': { 'type': 'SevGuestProperties', + 'if': 'defined(CONFIG_SEV)' }, 'throttle-group': 'ThrottleGroupProperties', 'tls-creds-anon': 'TlsCredsAnonProperties', 'tls-creds-psk': 'TlsCredsPskProperties',Signature · 1 line
2.29.2
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [PATCH v2 16/31] qapi/qom: Add ObjectOptions for confidential-guest-support
Am 24.02.2021 um 16:21 hat Dr. David Alan Gilbert geschrieben:
Quoted 64 lines · * Kevin Wolf ([email protected]) wrote:
Quoted 63 lines
This adds a QAPI schema for the properties of the objects implementing the confidential-guest-support interface.
pef-guest and s390x-pv-guest don't have any properties, so they only need to be added to the ObjectType enum without adding a new branch to ObjectOptions.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/qom.json | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)qapi/qom.json +33
-0@@ -633,6 +633,38 @@ 'base': 'RngProperties', 'data': { '*filename': 'str' } } +## +# @SevGuestProperties: +# +# Properties for sev-guest objects. +# +# @sev-device: SEV device to use (default: "/dev/sev") +# +# @dh-cert-file: guest owners DH certificate (encoded with base64) +# +# @session-file: guest owners session parameters (encoded with base64) +# +# @policy: SEV policy value (default: 0x1) +# +# @handle: SEV firmware handle (default: 0) +# +# @cbitpos: C-bit location in page table entry (default: 0) +# +# @reduced-phys-bits: number of bits in physical addresses that become +# unavailable when SEV is enabled +# +# Since: 2.12 +## +{ 'struct': 'SevGuestProperties', + 'data': { '*sev-device': 'str', + '*dh-cert-file': 'str', + '*session-file': 'str', + '*policy': 'uint32', + '*handle': 'uint32', + '*cbitpos': 'uint32', + 'reduced-phys-bits': 'uint32' }, + 'if': 'defined(CONFIG_SEV)' } + ## # @ObjectType: #@@ -661,12 +693,15 @@ 'memory-backend-file', 'memory-backend-memfd', 'memory-backend-ram', + {'name': 'pef-guest', 'if': 'defined(CONFIG_PSERIES)' }, 'pr-manager-helper', 'rng-builtin', 'rng-egd',
Quoted 8 lines
qapi/qom.json line 704
Quoted 5 lines
qapi/qom.json +2
-0'rng-random', 'secret', 'secret_keyring', + {'name': 'sev-guest', 'if': 'defined(CONFIG_SEV)' }, + 's390-pv-guest',If pef-guest is conditional on PSERIES< shouldn't this be dependent on s390?
The difference is that s390-pv-guest is compiled unconditionally if the s390x target is built, whereas CONFIG_PSERIES is a separate thing from building a ppc target.
I actually tried making it conditional on TARGET_S390X at first, but the code generated from this schema is supposed to be target independent, so it rightly failed to build because TARGET_* are marked as poisoned in most of the codebase.
Kevin
Re: [PATCH v2 16/31] qapi/qom: Add ObjectOptions for confidential-guest-support
In reply to Kevin WolfQuoted 20 lines · Kevin Wolf
This adds a QAPI schema for the properties of the objects implementing the confidential-guest-support interface.
pef-guest and s390x-pv-guest don't have any properties, so they only need to be added to the ObjectType enum without adding a new branch to ObjectOptions.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/qom.json | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)qapi/qom.json +0
-0@@ -633,6 +633,38 @@ 'base': 'RngProperties', 'data': { '*filename': 'str' } }
qapi/qom.json line 645
Quoted 10 lines
qapi/qom.json +10
-0+## +# @SevGuestProperties: +# +# Properties for sev-guest objects. +# +# @sev-device: SEV device to use (default: "/dev/sev") +# +# @dh-cert-file: guest owners DH certificate (encoded with base64) +# +# @session-file: guest owners session parameters (encoded with base64)
Matches target/i386/sev.c:sev_guest_class_init()...
qapi/qom.json line 654
Quoted 9 lines
qapi/qom.json +9
-0+# +# @policy: SEV policy value (default: 0x1) +# +# @handle: SEV firmware handle (default: 0) +# +# @cbitpos: C-bit location in page table entry (default: 0) +# +# @reduced-phys-bits: number of bits in physical addresses that become +# unavailable when SEV is enabled
...and sev_guest_instance_init().
Quoted 34 lines
qapi/qom.json +16
-0+# +# Since: 2.12 +## +{ 'struct': 'SevGuestProperties', + 'data': { '*sev-device': 'str', + '*dh-cert-file': 'str', + '*session-file': 'str', + '*policy': 'uint32', + '*handle': 'uint32', + '*cbitpos': 'uint32', + 'reduced-phys-bits': 'uint32' }, + 'if': 'defined(CONFIG_SEV)' } + ## # @ObjectType: #@@ -661,12 +693,15 @@ 'memory-backend-file', 'memory-backend-memfd', 'memory-backend-ram', + {'name': 'pef-guest', 'if': 'defined(CONFIG_PSERIES)' }, 'pr-manager-helper', 'rng-builtin', 'rng-egd', 'rng-random', 'secret', 'secret_keyring', + {'name': 'sev-guest', 'if': 'defined(CONFIG_SEV)' }, + 's390-pv-guest', 'throttle-group', 'tls-creds-anon', 'tls-creds-psk',
qapi/qom.json line 758
Quoted 8 lines
qapi/qom.json +2
-0@@ -716,6 +751,8 @@ 'rng-random': 'RngRandomProperties', 'secret': 'SecretProperties', 'secret_keyring': 'SecretKeyringProperties', + 'sev-guest': { 'type': 'SevGuestProperties', + 'if': 'defined(CONFIG_SEV)' }, 'throttle-group': 'ThrottleGroupProperties', 'tls-creds-anon': 'TlsCredsAnonProperties', 'tls-creds-psk': 'TlsCredsPskProperties',
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 17/31 qapi/qom: Add ObjectOptions for input-*
In reply to Kevin WolfThis adds a QAPI schema for the properties of the input-* objects.
ui.json cannot be included in qom.json because the storage daemon can't use it, so move GrabToggleKeys to common.json.
--- qapi/common.json | 12 ++++++++++ qapi/qom.json | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ qapi/ui.json | 13 +---------- 3 files changed, 71 insertions(+), 12 deletions(-)
qapi/common.json +12 -0
@@ -185,3 +185,15 @@ ## { 'enum': 'NetFilterDirection', 'data': [ 'all', 'rx', 'tx' ] } + +## +# @GrabToggleKeys: +# +# Keys to toggle input-linux between host and guest. +# +# Since: 4.0 +# +## +{ 'enum': 'GrabToggleKeys', + 'data': [ 'ctrl-ctrl', 'alt-alt', 'shift-shift','meta-meta', 'scrolllock', + 'ctrl-scrolllock' ] }
qapi/qom.json +58 -0
76 lines not on this page · raw message
qapi/ui.json +1 -12
@@ -6,6 +6,7 @@ # = Remote desktop ## +{ 'include': 'common.json' } { 'include': 'sockets.json' } ##
@@ -1021,18 +1022,6 @@ '*head' : 'int', 'events' : [ 'InputEvent' ] } } -## -# @GrabToggleKeys: -# -# Keys to toggle input-linux between host and guest. -# -# Since: 4.0 -# -## -{ 'enum': 'GrabToggleKeys', - 'data': [ 'ctrl-ctrl', 'alt-alt', 'shift-shift','meta-meta', 'scrolllock', - 'ctrl-scrolllock' ] } - ## # @DisplayGTK: #
Signature · 1 line
2.29.2
Re: [PATCH v2 17/31] qapi/qom: Add ObjectOptions for input-*
Quoted 13 lines · Kevin Wolf
This adds a QAPI schema for the properties of the input-* objects.
ui.json cannot be included in qom.json because the storage daemon can't use it, so move GrabToggleKeys to common.json.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/common.json | 12 ++++++++++ qapi/qom.json | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ qapi/ui.json | 13 +---------- 3 files changed, 71 insertions(+), 12 deletions(-)
qapi/qom.json line 456
Quoted 10 lines
qapi/qom.json +10
-0+## +# @InputBarrierProperties: +# +# Properties for input-barrier objects. +# +# @name: the screen name as declared in the screens section of barrier.conf +# +# @server: hostname of the Barrier server (default: "localhost") +# +# @port: TCP port of the Barrier server (default: "24800")
I can understand this being a string (if non-numeric, it can be treated as a well-known service name instead), but...
qapi/qom.json line 459
Quoted 3 lines
qapi/qom.json +3
-0+# +# @x-origin: x coordinate of the leftmost pixel on the guest screen +# (default: "0")
...why are these other fields a string instead of an integer? But you are just doing faithful translation of what we already have.
Bummer - our naming for this member implies that it is experimental, which is a misnomer (it is quite stable, when viewed in tandem with y-origin). Not your fault. Would 'origin-x' and 'origin-y' be any better as new aliases in a followup patch?
Review
Quoted 2 lines
(quoted diff) +2
-0+# +# @y-origin: y coordinate of he topmost pixel on the guest screen (default: "0")
"the", long line
Quoted 5 lines
qapi/qom.json +5
-0+# +# @width: the width of secondary screen in pixels (default: "1920") +# +# @height: the height of secondary screen in pixels (default: "1080") +#
qapi/qom.json line 476
Quoted 10 lines
qapi/qom.json +10
-0+# Since: 4.2 +## +{ 'struct': 'InputBarrierProperties', + 'data': { 'name': 'str', + '*server': 'str', + '*port': 'str', + '*x-origin': 'str', + '*y-origin': 'str', + '*width': 'str', + '*height': 'str' } }
Matches ui/input-barrier.c:input_barrier_class_init().
qapi/qom.json line 486
Quoted 10 lines
qapi/qom.json +10
-0+ +## +# @InputLinuxProperties: +# +# Properties for input-linux objects. +# +# @evdev: the path of the host evdev device to use +# +# @grab_all: if true, grab is toggled for all devices (e.g. both keyboard and +# mouse) instead of just one device (default: false)
We have inconsistent naming within this object (see grab-toggle); a good followup would be an alias for 'grab-all'.
qapi/qom.json line 499
Quoted 13 lines
qapi/qom.json +13
-0+# +# @repeat: enables auto-repeat events (default: false) +# +# @grab-toggle: the key or key combination that toggles device grab +# (default: ctrl-ctrl) +# +# Since: 2.6 +## +{ 'struct': 'InputLinuxProperties', + 'data': { 'evdev': 'str', + '*grab_all': 'bool', + '*repeat': 'bool', + '*grab-toggle': 'GrabToggleKeys' } }
matches ui/input-linux.c.
Quoted 14 lines
qapi/qom.json +3
-0+ ## # @IothreadProperties: #@@ -689,6 +743,8 @@ 'filter-redirector', 'filter-replay', 'filter-rewriter', + 'input-barrier', + 'input-linux', 'iothread', 'memory-backend-file', 'memory-backend-memfd',
qapi/qom.json line 804
Quoted 8 lines
qapi/qom.json +2
-0@@ -741,6 +797,8 @@ 'filter-redirector': 'FilterRedirectorProperties', 'filter-replay': 'NetfilterProperties', 'filter-rewriter': 'FilterRewriterProperties', + 'input-barrier': 'InputBarrierProperties', + 'input-linux': 'InputLinuxProperties', 'iothread': 'IothreadProperties', 'memory-backend-file': 'MemoryBackendFileProperties', 'memory-backend-memfd': 'MemoryBackendMemfdProperties',
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH v2 17/31] qapi/qom: Add ObjectOptions for input-*
Am 26.02.2021 um 21:55 hat Eric Blake geschrieben:
Quoted 28 lines · Kevin Wolf
Quoted 13 lines
This adds a QAPI schema for the properties of the input-* objects.
ui.json cannot be included in qom.json because the storage daemon can't use it, so move GrabToggleKeys to common.json.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/common.json | 12 ++++++++++ qapi/qom.json | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ qapi/ui.json | 13 +---------- 3 files changed, 71 insertions(+), 12 deletions(-)qapi/qom.json line 456
Quoted 10 lines
qapi/qom.json +10
-0+## +# @InputBarrierProperties: +# +# Properties for input-barrier objects. +# +# @name: the screen name as declared in the screens section of barrier.conf +# +# @server: hostname of the Barrier server (default: "localhost") +# +# @port: TCP port of the Barrier server (default: "24800")I can understand this being a string (if non-numeric, it can be treated as a well-known service name instead), but...
Quoted 6 lines
qapi/qom.json line 459
Quoted 3 lines
qapi/qom.json +3
-0+# +# @x-origin: x coordinate of the leftmost pixel on the guest screen +# (default: "0")...why are these other fields a string instead of an integer? But you are just doing faithful translation of what we already have.
I wondered the same. Most properties of the user creatable objects make sense, but for some, I can't imagine why we thought this was a good idea.
Well, moving descriptions to the QAPI schema can hopefully help to avoid introducing new cases in the future because they become more obvious.
Quoted 4 lines
Bummer - our naming for this member implies that it is experimental, which is a misnomer (it is quite stable, when viewed in tandem with y-origin). Not your fault. Would 'origin-x' and 'origin-y' be any better as new aliases in a followup patch?
Oh, good point. Makes sense, once the alias series is in.
Kevin
PATCH v2 18/31 qapi/qom: Add ObjectOptions for x-remote-object
In reply to Kevin WolfThis adds a QAPI schema for the properties of the x-remote-object object.
--- qapi/qom.json | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
qapi/qom.json +18 -2
@@ -641,6 +641,20 @@ { 'struct': 'PrManagerHelperProperties', 'data': { 'path': 'str' } } +## +# @RemoteObjectProperties: +# +# Properties for x-remote-object objects. +# +# @fd: file descriptor name previously passed via 'getfd' command +# +# @devid: the id of the device to be associated with the file descriptor +# +# Since: 6.0 +## +{ 'struct': 'RemoteObjectProperties', + 'data': { 'fd': 'str', 'devid': 'str' } } + ## # @RngProperties: #
@@ -762,7 +776,8 @@ 'tls-creds-anon', 'tls-creds-psk', 'tls-creds-x509', - 'tls-cipher-suites' + 'tls-cipher-suites', + 'x-remote-object' ] } ##
@@ -815,7 +830,8 @@ 'tls-creds-anon': 'TlsCredsAnonProperties', 'tls-creds-psk': 'TlsCredsPskProperties', 'tls-creds-x509': 'TlsCredsX509Properties', - 'tls-cipher-suites': 'TlsCredsProperties' + 'tls-cipher-suites': 'TlsCredsProperties', + 'x-remote-object': 'RemoteObjectProperties' } } ##
Signature · 1 line
2.29.2
Re: [PATCH v2 18/31] qapi/qom: Add ObjectOptions for x-remote-object
Quoted 20 lines · Kevin Wolf
This adds a QAPI schema for the properties of the x-remote-object object.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/qom.json | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)qapi/qom.json +4
-0@@ -641,6 +641,20 @@ { 'struct': 'PrManagerHelperProperties', 'data': { 'path': 'str' } } +## +# @RemoteObjectProperties: +# +# Properties for x-remote-object objects.
qapi/qom.json line 657
Quoted 10 lines
qapi/qom.json +10
-0+# +# @fd: file descriptor name previously passed via 'getfd' command +# +# @devid: the id of the device to be associated with the file descriptor +# +# Since: 6.0 +## +{ 'struct': 'RemoteObjectProperties', + 'data': { 'fd': 'str', 'devid': 'str' } } +
Matches hw/remote/remote-obj.c:remote_object_class_init().
Quoted 15 lines
qapi/qom.json +2
-1## # @RngProperties: #@@ -762,7 +776,8 @@ 'tls-creds-anon', 'tls-creds-psk', 'tls-creds-x509', - 'tls-cipher-suites' + 'tls-cipher-suites', + 'x-remote-object' ] } ##
qapi/qom.json line 837
Quoted 9 lines
qapi/qom.json +2
-1@@ -815,7 +830,8 @@ 'tls-creds-anon': 'TlsCredsAnonProperties', 'tls-creds-psk': 'TlsCredsPskProperties', 'tls-creds-x509': 'TlsCredsX509Properties', - 'tls-cipher-suites': 'TlsCredsProperties' + 'tls-cipher-suites': 'TlsCredsProperties', + 'x-remote-object': 'RemoteObjectProperties' } } ##
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 19/31 qapi/qom: QAPIfy object-add
In reply to Kevin WolfThis converts object-add from 'gen': false to the ObjectOptions QAPI type. As an immediate benefit, clients can now use QAPI schema introspection for user creatable QOM objects.
It is also the first step towards making the QAPI schema the only external interface for the creation of user creatable objects. Once all other places (HMP and command lines of the system emulator and all tools) go through QAPI, too, some object implementations can be simplified because some checks (e.g. that mandatory options are set) are already performed by QAPI, and in another step, QOM boilerplate code could be generated from the schema.
--- qapi/qom.json | 11 +---------- include/qom/object_interfaces.h | 7 ------- hw/block/xen-block.c | 16 ++++++++-------- monitor/misc.c | 2 -- qom/qom-qmp-cmds.c | 25 +++++++++++++++++++++++-- storage-daemon/qemu-storage-daemon.c | 2 -- 6 files changed, 32 insertions(+), 31 deletions(-)
qapi/qom.json +1 -10
@@ -839,13 +839,6 @@ # # Create a QOM object. # -# @qom-type: the class name for the object to be created -# -# @id: the name of the new object -# -# Additional arguments depend on qom-type and are passed to the backend -# unchanged. -# # Returns: Nothing on success # Error if @qom-type is not a valid class name #
@@ -859,9 +852,7 @@ # <- { "return": {} } # ## -{ 'command': 'object-add', - 'data': {'qom-type': 'str', 'id': 'str'}, - 'gen': false } # so we can get the additional arguments +{ 'command': 'object-add', 'data': 'ObjectOptions', 'boxed': true } ## # @object-del:
include/qom/object_interfaces.h +0 -7
@@ -196,11 +196,4 @@ bool user_creatable_del(const char *id, Error **errp);*/ void user_creatable_cleanup (void ); -/** -* qmp_object_add: -* -* QMP command handler for object-add. See the QAPI schema for documentation. -*/ -void qmp_object_add (QDict *qdict,QObject **ret_data,Error **errp); -#endif
hw/block/xen-block.c +8 -8
@@ -836,17 +836,17 @@ static XenBlockIOThread *xen_block_iothread_create(const char *id, {ERRP_GUARD ();XenBlockIOThread *iothread =g_new (XenBlockIOThread,1 ); -QDict *opts; -QObject *ret_data =NULL ; +ObjectOptions *opts; iothread->id =g_strdup (id); - opts =qdict_new (); -qdict_put_str (opts,"qom-type" ,TYPE_IOTHREAD ); -qdict_put_str (opts,"id" , id); -qmp_object_add (opts, &ret_data, errp); -qobject_unref (opts); -qobject_unref (ret_data); + opts =g_new (ObjectOptions,1 ); + *opts = (ObjectOptions ) { + .qom_type =OBJECT_TYPE_IOTHREAD , + .id =g_strdup (id), + }; +qmp_object_add (opts, errp); +qapi_free_ObjectOptions (opts);if (*errp) {g_free (iothread->id);
monitor/misc.c +0 -2
@@ -235,8 +235,6 @@ static void monitor_init_qmp_commands(void) qmp_query_qmp_schema, QCO_ALLOW_PRECONFIG);qmp_register_command (&qmp_commands,"device_add" , qmp_device_add,QCO_NO_OPTIONS ); -qmp_register_command (&qmp_commands,"object-add" , qmp_object_add, -QCO_NO_OPTIONS );QTAILQ_INIT (&qmp_cap_negotiation_commands); qmp_register_command(&qmp_cap_negotiation_commands, "qmp_capabilities",
qom/qom-qmp-cmds.c +23 -2
@@ -19,8 +19,11 @@#include "qapi/error.h" #include "qapi/qapi-commands-qdev.h" #include "qapi/qapi-commands-qom.h" +#include "qapi/qapi-visit-qom.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" +#include "qapi/qobject-input-visitor.h" +#include "qapi/qobject-output-visitor.h" #include "qemu/cutils.h" #include "qom/object_interfaces.h" #include "qom/qom-qobject.h"
@@ -223,9 +226,27 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename,return prop_list; } -void qmp_object_add (QDict *qdict,QObject **ret_data,Error **errp) +void qmp_object_add (ObjectOptions *options,Error **errp) { -user_creatable_add_dict (qdict, false, errp); +Visitor *v; +QObject *qobj; +QDict *props; +Object *obj; + + v =qobject_output_visitor_new (&qobj); +visit_type_ObjectOptions (v,NULL , &options, &error_abort); +visit_complete (v, &qobj); +visit_free (v); + + props =qobject_to (QDict, qobj); +qdict_del (props,"qom-type" ); +qdict_del (props,"id" ); + + v =qobject_input_visitor_new (QOBJECT (props)); + obj =user_creatable_add_type (ObjectType_str (options->qom_type), + options->id, props, v, errp); +object_unref (obj); +visit_free (v); }void qmp_object_del (const char *id,Error **errp)
storage-daemon/qemu-storage-daemon.c +0 -2
@@ -144,8 +144,6 @@ static void init_qmp_commands(void)qmp_init_marshal (&qmp_commands);qmp_register_command (&qmp_commands,"query-qmp-schema" , qmp_query_qmp_schema,QCO_ALLOW_PRECONFIG ); -qmp_register_command (&qmp_commands,"object-add" , qmp_object_add, -QCO_NO_OPTIONS );QTAILQ_INIT (&qmp_cap_negotiation_commands); qmp_register_command(&qmp_cap_negotiation_commands, "qmp_capabilities",
Signature · 1 line
2.29.2
Re: [PATCH v2 19/31] qapi/qom: QAPIfy object-add
qom/qom-qmp-cmds.c ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename, · line 248
Quoted 13 lines · Kevin Wolf
qom/qom-qmp-cmds.c +13
-0+ v =qobject_output_visitor_new (&qobj); +visit_type_ObjectOptions (v,NULL , &options, &error_abort); +visit_complete (v, &qobj); +visit_free (v); + + props =qobject_to (QDict, qobj); +qdict_del (props,"qom-type" ); +qdict_del (props,"id" ); + + v =qobject_input_visitor_new (QOBJECT (props)); + obj =user_creatable_add_type (ObjectType_str (options->qom_type), + options->id, props, v, errp); +object_unref (obj);
Please add a check in object_property_add_child that the id is well formed (using the id_wellformed function). This is pre-existing, but it becomes a regression for -object later in the series.
Thanks,
Paolo
Re: [PATCH v2 19/31] qapi/qom: QAPIfy object-add
Am 26.02.2021 um 12:30 hat Paolo Bonzini geschrieben:
Quoted 10 lines · Kevin Wolf
Quoted 9 lines
qom/qom-qmp-cmds.c +9
-0+ v =qobject_output_visitor_new (&qobj); +visit_type_ObjectOptions (v,NULL , &options, &error_abort); +visit_complete (v, &qobj); +visit_free (v); + + props =qobject_to (QDict, qobj); +qdict_del (props,"qom-type" ); +qdict_del (props,"id" ); +
Quoted 8 lines
qom/qom-qmp-cmds.c ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename, · line 248
Quoted 4 lines
qom/qom-qmp-cmds.c +4
-0+ v =qobject_input_visitor_new (QOBJECT (props)); + obj =user_creatable_add_type (ObjectType_str (options->qom_type), + options->id, props, v, errp); +object_unref (obj);Please add a check in
object_property_add_childthat the id is well formed (using theid_wellformedfunction). This is pre-existing, but it becomes a regression for -object later in the series.
Are the conditions for internally called object_property_add_child() actually the same as for IDs specified by the user? For example, I seem to remember some array-ish properties with [] in their name which aren't allowed by id_wellformed().
The obvious place to affect only the external interfaces would be user_creatable_add_type().
Kevin
Re: [PATCH v2 19/31] qapi/qom: QAPIfy object-add
Quoted 7 lines · Kevin Wolf
Quoted 3 lines
Please add a check in
object_property_add_childthat the id is well formed (using theid_wellformedfunction). This is pre-existing, but it becomes a regression for -object later in the series.Are the conditions for internally called
object_property_add_child()actually the same as for IDs specified by the user? For example, I seem to remember some array-ish properties with [] in their name which aren't allowed byid_wellformed().
Yes, you are right.
Quoted 2 lines
The obvious place to affect only the external interfaces would be
user_creatable_add_type().
Makes sense, thanks.
Paolo
Re: [PATCH v2 19/31] qapi/qom: QAPIfy object-add
In reply to Kevin WolfQuoted 38 lines · Kevin Wolf
This converts object-add from 'gen': false to the ObjectOptions QAPI type. As an immediate benefit, clients can now use QAPI schema introspection for user creatable QOM objects.
It is also the first step towards making the QAPI schema the only external interface for the creation of user creatable objects. Once all other places (HMP and command lines of the system emulator and all tools) go through QAPI, too, some object implementations can be simplified because some checks (e.g. that mandatory options are set) are already performed by QAPI, and in another step, QOM boilerplate code could be generated from the schema.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/qom.json | 11 +---------- include/qom/object_interfaces.h | 7 ------- hw/block/xen-block.c | 16 ++++++++-------- monitor/misc.c | 2 -- qom/qom-qmp-cmds.c | 25 +++++++++++++++++++++++-- storage-daemon/qemu-storage-daemon.c | 2 -- 6 files changed, 32 insertions(+), 31 deletions(-)+++
b/qapi/qom.jsonqapi/qom.json +0
-7@@ -839,13 +839,6 @@ # # Create a QOM object. # -# @qom-type: the class name for the object to be created -# -# @id: the name of the new object -# -# Additional arguments depend on qom-type and are passed to the backend -# unchanged. -# # Returns: Nothing on success # Error if @qom-type is not a valid class name #
qapi/qom.json line 855
Quoted 7 lines
qapi/qom.json +1
-3@@ -859,9 +852,7 @@ # <- { "return": {} } # ## -{ 'command': 'object-add', - 'data': {'qom-type': 'str', 'id': 'str'}, - 'gen': false } # so we can get the additional arguments +{ 'command': 'object-add', 'data': 'ObjectOptions', 'boxed': true }
So much more concise ;) A grep for TYPE_USER_CREATABLE doesn't seem to turn up any *_class_init() functions that your earlier patches in the series missed, so I think you captured an accurate 1:1 mapping. There is include/chardev/char.h with the comment about "TODO: eventually use TYPE_USER_CREATABLE" which may point to the next item to be added to ObjectOptions, but that's not for this series.
Quoted 6 lines
qom/qom-qmp-cmds.c +2
-1+++ b/qom/qom-qmp-cmds.c -void qmp_object_add (QDict *qdict,QObject **ret_data,Error **errp) +void qmp_object_add (ObjectOptions *options,Error **errp) {
qom/qom-qmp-cmds.c ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename, · line 239
Quoted 10 lines
qom/qom-qmp-cmds.c +9
-1-user_creatable_add_dict (qdict, false, errp); +Visitor *v; +QObject *qobj; +QDict *props; +Object *obj; + + v =qobject_output_visitor_new (&qobj); +visit_type_ObjectOptions (v,NULL , &options, &error_abort); +visit_complete (v, &qobj); +visit_free (v);
This part is nice...
qom/qom-qmp-cmds.c ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename, · line 243
Quoted 4 lines
qom/qom-qmp-cmds.c +4
-0+ + props =qobject_to (QDict, qobj); +qdict_del (props,"qom-type" ); +qdict_del (props,"id" );
...while this part makes it seem like we still have more cleanup to come later. But hey, progress!
qom/qom-qmp-cmds.c ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename, · line 250
Quoted 8 lines
qom/qom-qmp-cmds.c +6
-0+ + v =qobject_input_visitor_new (QOBJECT (props)); + obj =user_creatable_add_type (ObjectType_str (options->qom_type), + options->id, props, v, errp); +object_unref (obj); +visit_free (v); }
Once you address Paolo's comment, you can also add
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH v2 19/31] qapi/qom: QAPIfy object-add
Am 26.02.2021 um 22:18 hat Eric Blake geschrieben:
Quoted 57 lines · Kevin Wolf
Quoted 38 lines
This converts object-add from 'gen': false to the ObjectOptions QAPI type. As an immediate benefit, clients can now use QAPI schema introspection for user creatable QOM objects.
It is also the first step towards making the QAPI schema the only external interface for the creation of user creatable objects. Once all other places (HMP and command lines of the system emulator and all tools) go through QAPI, too, some object implementations can be simplified because some checks (e.g. that mandatory options are set) are already performed by QAPI, and in another step, QOM boilerplate code could be generated from the schema.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/qom.json | 11 +---------- include/qom/object_interfaces.h | 7 ------- hw/block/xen-block.c | 16 ++++++++-------- monitor/misc.c | 2 -- qom/qom-qmp-cmds.c | 25 +++++++++++++++++++++++-- storage-daemon/qemu-storage-daemon.c | 2 -- 6 files changed, 32 insertions(+), 31 deletions(-)+++
b/qapi/qom.jsonqapi/qom.json +0
-7@@ -839,13 +839,6 @@ # # Create a QOM object. # -# @qom-type: the class name for the object to be created -# -# @id: the name of the new object -# -# Additional arguments depend on qom-type and are passed to the backend -# unchanged. -# # Returns: Nothing on success # Error if @qom-type is not a valid class name #qapi/qom.json line 855
Quoted 7 lines
qapi/qom.json +1
-3@@ -859,9 +852,7 @@ # <- { "return": {} } # ## -{ 'command': 'object-add', - 'data': {'qom-type': 'str', 'id': 'str'}, - 'gen': false } # so we can get the additional arguments +{ 'command': 'object-add', 'data': 'ObjectOptions', 'boxed': true }So much more concise ;) A grep for
TYPE_USER_CREATABLEdoesn't seem to turn up any*_class_init()functions that your earlier patches in the series missed, so I think you captured an accurate 1:1 mapping. There isinclude/chardev/char.hwith the comment about "TODO: eventually useTYPE_USER_CREATABLE" which may point to the next item to be added to ObjectOptions, but that's not for this series.Quoted 3 lines
(quoted diff) +1
-0+++ b/qom/qom-qmp-cmds.c
Quoted 15 lines
qom/qom-qmp-cmds.c ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename, · line 239
Quoted 13 lines
qom/qom-qmp-cmds.c +10
-2-void qmp_object_add (QDict *qdict,QObject **ret_data,Error **errp) +void qmp_object_add (ObjectOptions *options,Error **errp) { -user_creatable_add_dict (qdict, false, errp); +Visitor *v; +QObject *qobj; +QDict *props; +Object *obj; + + v =qobject_output_visitor_new (&qobj); +visit_type_ObjectOptions (v,NULL , &options, &error_abort); +visit_complete (v, &qobj); +visit_free (v);This part is nice...
It's not really, though.
We're going from ObjectOptions to QDict just to feed the QDict back into a visitor. The QDict step feels unnecessary, but we don't have a visitor that visits existing QAPI objects. I think it would be somewhat similar to the clone visitor, but not exactly the same thing.
Quoted 7 lines
qom/qom-qmp-cmds.c ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename, · line 243
Quoted 4 lines
qom/qom-qmp-cmds.c +4
-0+ + props =qobject_to (QDict, qobj); +qdict_del (props,"qom-type" ); +qdict_del (props,"id" );...while this part makes it seem like we still have more cleanup to come later. But hey, progress!
Ideally, I would like the whole function to look more or less like this:
void qmp_object_add(ObjectOptions *options, Error **errp)
{
Visitor *v = qapi_object_visitor_new(options);
Object *obj = user_creatable_add_type(v, errp);
object_unref(obj);
visit_free(v);
}Can be done later (or never).
Kevin
Quoted 17 lines
qom/qom-qmp-cmds.c ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename, · line 250
Quoted 8 lines
qom/qom-qmp-cmds.c +6
-0+ + v =qobject_input_visitor_new (QOBJECT (props)); + obj =user_creatable_add_type (ObjectType_str (options->qom_type), + options->id, props, v, errp); +object_unref (obj); +visit_free (v); }Once you address Paolo's comment, you can also add
Reviewed-by Eric Blake <[email protected]>Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 20/31 qom: Make "object" QemuOptsList optional
In reply to Kevin WolfThis code is going away anyway, but for a few more commits, we'll be in a state where some binaries still use QemuOpts and others don't. If the "object" QemuOptsList doesn't even exist, we don't have to remove (or fail to remove, and therefore abort) a user creatable object from it.
--- qom/object_interfaces.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
qom/object_interfaces.c +5 -2
@@ -290,6 +290,7 @@ void user_creatable_print_help_from_qdict(QDict *args)bool user_creatable_del (const char *id,Error **errp) { +QemuOptsList *opts_list;Object *container;Object *obj;
@@ -309,8 +310,10 @@ bool user_creatable_del(const char *id, Error **errp)* if object was defined on the command-line, remove its corresponding * option group entry */ -qemu_opts_del (qemu_opts_find (qemu_find_opts_err ("object" , &error_abort), - id)); + opts_list =qemu_find_opts_err ("object" ,NULL ); +if (opts_list) { +qemu_opts_del (qemu_opts_find (opts_list, id)); + }object_unparent (obj);return true;
Signature · 1 line
2.29.2
Re: [PATCH v2 20/31] qom: Make "object" QemuOptsList optional
Quoted 10 lines · Kevin Wolf
This code is going away anyway, but for a few more commits, we'll be in a state where some binaries still use QemuOpts and others don't. If the "object" QemuOptsList doesn't even exist, we don't have to remove (or fail to remove, and therefore abort) a user creatable object from it.
Signed-off-by Kevin Wolf <[email protected]>--- qom/object_interfaces.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 21/31 qemu-storage-daemon: Implement --object with qmp_object_add()
In reply to Kevin WolfThis QAPIfies --object and ensures that QMP and the command line option behave the same.
--- storage-daemon/qemu-storage-daemon.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
storage-daemon/qemu-storage-daemon.c +10 -11
@@ -38,6 +38,7 @@#include "qapi/qapi-visit-block-core.h" #include "qapi/qapi-visit-block-export.h" #include "qapi/qapi-visit-control.h" +#include "qapi/qapi-visit-qom.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" #include "qapi/qobject-input-visitor.h"
@@ -130,15 +131,6 @@ enum {extern QemuOptsList qemu_chardev_opts; -static QemuOptsList qemu_object_opts = { - .name ="object" , - .implied_opt_name ="qom-type" , - .head =QTAILQ_HEAD_INITIALIZER (qemu_object_opts.head), - .desc = { - { } - }, -}; -static void init_qmp_commands (void ) {qmp_init_marshal (&qmp_commands);
@@ -263,14 +255,22 @@ static void process_options(int argc, char *argv[]) {QDict *args;bool help; +Visitor *v; +ObjectOptions *options; args =keyval_parse (optarg,"qom-type" , &help, &error_fatal);if (help) {user_creatable_print_help_from_qdict (args);exit (EXIT_SUCCESS ); } -user_creatable_add_dict (args, true, &error_fatal); + + v =qobject_input_visitor_new_keyval (QOBJECT (args)); +visit_type_ObjectOptions (v,NULL , &options, &error_fatal); +visit_free (v);qobject_unref (args); + +qmp_object_add (options, &error_fatal); +qapi_free_ObjectOptions (options);break ; }default :
@@ -295,7 +295,6 @@ int main(int argc, char *argv[])module_call_init (MODULE_INIT_QOM );module_call_init (MODULE_INIT_TRACE ); -qemu_add_opts (&qemu_object_opts);qemu_add_opts (&qemu_trace_opts);qcrypto_init (&error_fatal);bdrv_init ();
Signature · 1 line
2.29.2
Re: [PATCH v2 21/31] qemu-storage-daemon: Implement --object with qmp_object_add()
Quoted 8 lines · Kevin Wolf
This QAPIfies --object and ensures that QMP and the command line option behave the same.
Signed-off-by Kevin Wolf <[email protected]>--- storage-daemon/qemu-storage-daemon.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 22/31 qom: Remove user_creatable_add_dict()
In reply to Kevin WolfThis function is now unused and can be removed.
--- include/qom/object_interfaces.h | 18 ------------------ qom/object_interfaces.c | 32 -------------------------------- 2 files changed, 50 deletions(-)
include/qom/object_interfaces.h +0 -18
@@ -86,24 +86,6 @@ Object *user_creatable_add_type(const char *type, const char *id,const QDict *qdict, Visitor *v, Error **errp); -/** -* user_creatable_add_dict: -* @qdict: the object definition -* @keyval: if true, use a keyval visitor for processing @qdict (i.e. -* assume that all @qdict values are strings); otherwise, use -* the normal QObject visitor (i.e. assume all @qdict values -* have the QType expected by the QOM object type) -* @errp: if an error occurs, a pointer to an area to store the error -* -* Create an instance of the user creatable object that is defined by -* @qdict. The object type is taken from the QDict key 'qom-type', its -* ID from the key 'id'. The remaining entries in @qdict are used to -* initialize the object properties. -* -* Returns: %true on success, %false on failure. -*/ -bool user_creatable_add_dict (QDict *qdict,bool keyval,Error **errp); -/** * user_creatable_add_opts: * @opts: the object definition
qom/object_interfaces.c +0 -32
@@ -104,38 +104,6 @@ out:return obj; } -bool user_creatable_add_dict (QDict *qdict,bool keyval,Error **errp) -{ -Visitor *v; -Object *obj; - g_autofree char *type = NULL; - g_autofree char *id = NULL; - - type =g_strdup (qdict_get_try_str (qdict,"qom-type" )); -if (!type) { -error_setg (errp,QERR_MISSING_PARAMETER ,"qom-type" ); -return false; - } -qdict_del (qdict,"qom-type" ); - - id =g_strdup (qdict_get_try_str (qdict,"id" )); -if (!id) { -error_setg (errp,QERR_MISSING_PARAMETER ,"id" ); -return false; - } -qdict_del (qdict,"id" ); - -if (keyval) { - v =qobject_input_visitor_new_keyval (QOBJECT (qdict)); - }else { - v =qobject_input_visitor_new (QOBJECT (qdict)); - } - obj =user_creatable_add_type (type, id, qdict, v, errp); -visit_free (v); -object_unref (obj); -return !!obj; -} -Object *user_creatable_add_opts (QemuOpts *opts,Error **errp) {Visitor *v;
Signature · 1 line
2.29.2
Re: [PATCH v2 22/31] qom: Remove user_creatable_add_dict()
Quoted 8 lines · Kevin Wolf
This function is now unused and can be removed.
Signed-off-by Kevin Wolf <[email protected]>--- include/qom/object_interfaces.h | 18 ------------------ qom/object_interfaces.c | 32 -------------------------------- 2 files changed, 50 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 23/31 qom: Factor out user_creatable_process_cmdline()
In reply to Kevin WolfThe implementation for --object can be shared between qemu-storage-daemon and other binaries, so move it into a function in qom/object_interfaces.c that is accessible from everywhere.
This also requires moving the implementation of qmp_object_add() into a new user_creatable_add_qapi(), because qom/qom-qmp-cmds.c is not linked for tools.
user_creatable_print_help_from_qdict() can become static now.
--- include/qom/object_interfaces.h | 41 +++++++++++++++-------- qom/object_interfaces.c | 50 +++++++++++++++++++++++++++- qom/qom-qmp-cmds.c | 20 +---------- storage-daemon/qemu-storage-daemon.c | 22 +----------- 4 files changed, 79 insertions(+), 54 deletions(-)
include/qom/object_interfaces.h +28 -13
@@ -2,6 +2,7 @@#define OBJECT_INTERFACES_H #include "qom/object.h" +#include "qapi/qapi-types-qom.h" #include "qapi/visitor.h" #define TYPE_USER_CREATABLE "user-creatable"
@@ -86,6 +87,18 @@ Object *user_creatable_add_type(const char *type, const char *id,const QDict *qdict, Visitor *v, Error **errp); +/** +* user_creatable_add_qapi: +* @options: the object definition +* @errp: if an error occurs, a pointer to an area to store the error +* +* Create an instance of the user creatable object according to the +* options passed in @opts as described in the QAPI schema documentation. +* +* Returns: the newly created object or NULL on error +*/ +void user_creatable_add_qapi (ObjectOptions *options,Error **errp); +/** * user_creatable_add_opts: * @opts: the object definition
@@ -131,6 +144,21 @@ typedef bool (*user_creatable_add_opts_predicate)(const char *type);int user_creatable_add_opts_foreach (void *opaque,QemuOpts *opts,Error **errp); +/** +* user_creatable_process_cmdline: +* @optarg: the object definition string as passed on the command line +* +* Create an instance of the user creatable object by parsing optarg +* with a keyval parser and implicit key 'qom-type', converting the +* result to ObjectOptions and calling into qmp_object_add(). +* +* If a help option is given, print help instead and exit. +* +* This function is only meant to be called during command line parsing. +* It exits the process on failure or after printing help. +*/ +void user_creatable_process_cmdline (const char *optarg); +/** * user_creatable_print_help: * @type: the QOM type to be added
@@ -145,19 +173,6 @@ int user_creatable_add_opts_foreach(void *opaque,*/ bool user_creatable_print_help (const char *type,QemuOpts *opts); -/** -* user_creatable_print_help_from_qdict: -* @args: options to create -* -* Prints help considering the other options given in @args (if "qom-type" is -* given and valid, print properties for the type, otherwise print valid types) -* -* In contrast to user_creatable_print_help(), this function can't return that -* no help was requested. It should only be called if we know that help is -* requested and it will always print some help. -*/ -void user_creatable_print_help_from_qdict (QDict *args); -/** * user_creatable_del: * @id: the unique ID for the object
qom/object_interfaces.c +49 -1
78 lines not on this page · raw message
qom/qom-qmp-cmds.c +1 -19
@@ -228,25 +228,7 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename,void qmp_object_add (ObjectOptions *options,Error **errp) { -Visitor *v; -QObject *qobj; -QDict *props; -Object *obj; - - v =qobject_output_visitor_new (&qobj); -visit_type_ObjectOptions (v,NULL , &options, &error_abort); -visit_complete (v, &qobj); -visit_free (v); - - props =qobject_to (QDict, qobj); -qdict_del (props,"qom-type" ); -qdict_del (props,"id" ); - - v =qobject_input_visitor_new (QOBJECT (props)); - obj =user_creatable_add_type (ObjectType_str (options->qom_type), - options->id, props, v, errp); -object_unref (obj); -visit_free (v); +user_creatable_add_qapi (options, errp); }void qmp_object_del (const char *id,Error **errp)
storage-daemon/qemu-storage-daemon.c +1 -21
@@ -38,7 +38,6 @@#include "qapi/qapi-visit-block-core.h" #include "qapi/qapi-visit-block-export.h" #include "qapi/qapi-visit-control.h" -#include "qapi/qapi-visit-qom.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" #include "qapi/qobject-input-visitor.h"
@@ -252,27 +251,8 @@ static void process_options(int argc, char *argv[])break ; }case OPTION_OBJECT : - { -QDict *args; -bool help; -Visitor *v; -ObjectOptions *options; - - args =keyval_parse (optarg,"qom-type" , &help, &error_fatal); -if (help) { -user_creatable_print_help_from_qdict (args); -exit (EXIT_SUCCESS ); - } - - v =qobject_input_visitor_new_keyval (QOBJECT (args)); -visit_type_ObjectOptions (v,NULL , &options, &error_fatal); -visit_free (v); -qobject_unref (args); - -qmp_object_add (options, &error_fatal); -qapi_free_ObjectOptions (options); +user_creatable_process_cmdline (optarg);break ; - }default :g_assert_not_reached (); }
Signature · 1 line
2.29.2
Re: [PATCH v2 23/31] qom: Factor out user_creatable_process_cmdline()
Quoted 4 lines · Kevin Wolf
The implementation for --object can be shared between qemu-storage-daemon and other binaries, so move it into a function in
qom/object_interfaces.cthat is accessible from everywhere.
Quoted 8 lines
This also requires moving the implementation of
qmp_object_add()into a newuser_creatable_add_qapi(), becauseqom/qom-qmp-cmds.cis not linked for tools.
user_creatable_print_help_from_qdict()can become static now.Signed-off-by Kevin Wolf <[email protected]>---
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 24/31 qemu-io: Use user_creatable_process_cmdline() for --object
In reply to Kevin WolfThis switches qemu-io from a QemuOpts-based parser for --object to user_creatable_process_cmdline() which uses a keyval parser and enforces the QAPI schema.
Apart from being a cleanup, this makes non-scalar properties accessible.
--- qemu-io.c | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-)
qemu-io.c +3 -30
@@ -477,23 +477,6 @@ enum { OPTION_IMAGE_OPTS = 257, }; -static QemuOptsList qemu_object_opts = { - .name ="object" , - .implied_opt_name ="qom-type" , - .head =QTAILQ_HEAD_INITIALIZER (qemu_object_opts.head), - .desc = { - { } - }, -}; - -static bool qemu_io_object_print_help (const char *type,QemuOpts *opts) -{ -if (user_creatable_print_help (type, opts)) { -exit (0 ); - } -return true; -} -static QemuOptsList file_opts = { .name ="file" , .implied_opt_name ="file" ,
@@ -550,7 +533,6 @@ int main(int argc, char **argv)qcrypto_init (&error_fatal);module_call_init (MODULE_INIT_QOM ); -qemu_add_opts (&qemu_object_opts);qemu_add_opts (&qemu_trace_opts);bdrv_init ();
@@ -612,14 +594,9 @@ int main(int argc, char **argv)case 'U' : force_share = true;break ; -case OPTION_OBJECT : { -QemuOpts *qopts; - qopts =qemu_opts_parse_noisily (&qemu_object_opts, - optarg, true); -if (!qopts) { -exit (1 ); - } - }break ; +case OPTION_OBJECT : +user_creatable_process_cmdline (optarg); +break ;case OPTION_IMAGE_OPTS : imageOpts = true;break ;
@@ -644,10 +621,6 @@ int main(int argc, char **argv)exit (1 ); } -qemu_opts_foreach (&qemu_object_opts, - user_creatable_add_opts_foreach, - qemu_io_object_print_help, &error_fatal); -if (!trace_init_backends ()) {exit (1 ); }
Signature · 1 line
2.29.2
Re: [PATCH v2 24/31] qemu-io: Use user_creatable_process_cmdline() for --object
Quoted 11 lines · Kevin Wolf
This switches qemu-io from a QemuOpts-based parser for --object to
user_creatable_process_cmdline()which uses a keyval parser and enforces the QAPI schema.Apart from being a cleanup, this makes non-scalar properties accessible.
Signed-off-by Kevin Wolf <[email protected]>--- qemu-io.c | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 25/31 qemu-img: Use user_creatable_process_cmdline() for --object
In reply to Kevin WolfThis switches qemu-img from a QemuOpts-based parser for --object to user_creatable_process_cmdline() which uses a keyval parser and enforces the QAPI schema.
Apart from being a cleanup, this makes non-scalar properties accessible.
--- qemu-img.c | 239 ++++++++--------------------------------------------- 1 file changed, 33 insertions(+), 206 deletions(-)
qemu-img.c +33 -206
@@ -226,23 +226,6 @@ static void QEMU_NORETURN help(void)exit (EXIT_SUCCESS ); } -static QemuOptsList qemu_object_opts = { - .name ="object" , - .implied_opt_name ="qom-type" , - .head =QTAILQ_HEAD_INITIALIZER (qemu_object_opts.head), - .desc = { - { } - }, -}; - -static bool qemu_img_object_print_help (const char *type,QemuOpts *opts) -{ -if (user_creatable_print_help (type, opts)) { -exit (0 ); - } -return true; -} -/* * Is @optarg safe for accumulate_options()? * It is when multiple of them can be joined together separated by ','.
@@ -566,14 +549,9 @@ static int img_create(int argc, char **argv)case 'u' : flags |=BDRV_O_NO_BACKING ;break ; -case OPTION_OBJECT : { -QemuOpts *opts; - opts =qemu_opts_parse_noisily (&qemu_object_opts, - optarg, true); -if (!opts) { - goto fail; - } - }break ; +case OPTION_OBJECT : +user_creatable_process_cmdline (optarg); +break ; } }
@@ -589,12 +567,6 @@ static int img_create(int argc, char **argv) } optind++; -if (qemu_opts_foreach (&qemu_object_opts, - user_creatable_add_opts_foreach, - qemu_img_object_print_help, &error_fatal)) { - goto fail; - } -/* Get image size, if specified */ if (optind < argc) {int64_t sval;
@@ -804,14 +776,9 @@ static int img_check(int argc, char **argv)case 'U' : force_share = true;break ; -case OPTION_OBJECT : { -QemuOpts *opts; - opts =qemu_opts_parse_noisily (&qemu_object_opts, - optarg, true); -if (!opts) { -return 1 ; - } - }break ; +case OPTION_OBJECT : +user_creatable_process_cmdline (optarg); +break ;case OPTION_IMAGE_OPTS : image_opts = true;break ;
@@ -831,12 +798,6 @@ static int img_check(int argc, char **argv)return 1 ; } -if (qemu_opts_foreach (&qemu_object_opts, - user_creatable_add_opts_foreach, - qemu_img_object_print_help, &error_fatal)) { -return 1 ; - } - ret =bdrv_parse_cache_mode (cache, &flags, &writethrough);if (ret <0 ) {error_report ("Invalid source cache option: %s" , cache);
@@ -1034,14 +995,9 @@ static int img_commit(int argc, char **argv)return 1 ; }break ; -case OPTION_OBJECT : { -QemuOpts *opts; - opts =qemu_opts_parse_noisily (&qemu_object_opts, - optarg, true); -if (!opts) { -return 1 ; - } - }break ; +case OPTION_OBJECT : +user_creatable_process_cmdline (optarg); +break ;case OPTION_IMAGE_OPTS : image_opts = true;break ;
@@ -1058,12 +1014,6 @@ static int img_commit(int argc, char **argv) } filename = argv[optind++]; -if (qemu_opts_foreach (&qemu_object_opts, - user_creatable_add_opts_foreach, - qemu_img_object_print_help, &error_fatal)) { -return 1 ; - } - flags =BDRV_O_RDWR |BDRV_O_UNMAP ; ret =bdrv_parse_cache_mode (cache, &flags, &writethrough);if (ret <0 ) {
@@ -1423,15 +1373,9 @@ static int img_compare(int argc, char **argv)case 'U' : force_share = true;break ; -case OPTION_OBJECT : { -QemuOpts *opts; - opts =qemu_opts_parse_noisily (&qemu_object_opts, - optarg, true); -if (!opts) { - ret =2 ; - goto out4; - } - }break ; +case OPTION_OBJECT : +user_creatable_process_cmdline (optarg); +break ;case OPTION_IMAGE_OPTS : image_opts = true;break ;
@@ -1450,13 +1394,6 @@ static int img_compare(int argc, char **argv) filename1 = argv[optind++]; filename2 = argv[optind++]; -if (qemu_opts_foreach (&qemu_object_opts, - user_creatable_add_opts_foreach, - qemu_img_object_print_help, &error_fatal)) { - ret =2 ; - goto out4; - } -/* Initialize before goto out */ qemu_progress_init (progress,2.0 );
@@ -1641,7 +1578,6 @@ out2:blk_unref (blk1); out3:qemu_progress_end (); -out4:return ret; }
@@ -2342,15 +2278,9 @@ static int img_convert(int argc, char **argv) goto fail_getopt; }break ; -case OPTION_OBJECT : { -QemuOpts *object_opts; - object_opts =qemu_opts_parse_noisily (&qemu_object_opts, - optarg, true); -if (!object_opts) { - goto fail_getopt; - } +case OPTION_OBJECT : +user_creatable_process_cmdline (optarg);break ; - }case OPTION_IMAGE_OPTS : image_opts = true;break ;
@@ -2378,12 +2308,6 @@ static int img_convert(int argc, char **argv) out_fmt ="raw" ; } -if (qemu_opts_foreach (&qemu_object_opts, - user_creatable_add_opts_foreach, - qemu_img_object_print_help, &error_fatal)) { - goto fail_getopt; - } -if (s.compressed && s.copy_range) {error_report ("Cannot enable copy offloading when -c is used" ); goto fail_getopt;
@@ -2971,14 +2895,9 @@ static int img_info(int argc, char **argv)case OPTION_BACKING_CHAIN : chain = true;break ; -case OPTION_OBJECT : { -QemuOpts *opts; - opts =qemu_opts_parse_noisily (&qemu_object_opts, - optarg, true); -if (!opts) { -return 1 ; - } - }break ; +case OPTION_OBJECT : +user_creatable_process_cmdline (optarg); +break ;case OPTION_IMAGE_OPTS : image_opts = true;break ;
@@ -2998,12 +2917,6 @@ static int img_info(int argc, char **argv)return 1 ; } -if (qemu_opts_foreach (&qemu_object_opts, - user_creatable_add_opts_foreach, - qemu_img_object_print_help, &error_fatal)) { -return 1 ; - } - list =collect_image_info_list (image_opts, filename, fmt, chain, force_share);if (!list) {
@@ -3213,14 +3126,9 @@ static int img_map(int argc, char **argv)return 1 ; }break ; -case OPTION_OBJECT : { -QemuOpts *opts; - opts =qemu_opts_parse_noisily (&qemu_object_opts, - optarg, true); -if (!opts) { -return 1 ; - } - }break ; +case OPTION_OBJECT : +user_creatable_process_cmdline (optarg); +break ;case OPTION_IMAGE_OPTS : image_opts = true;break ;
@@ -3240,12 +3148,6 @@ static int img_map(int argc, char **argv)return 1 ; } -if (qemu_opts_foreach (&qemu_object_opts, - user_creatable_add_opts_foreach, - qemu_img_object_print_help, &error_fatal)) { -return 1 ; - } - blk =img_open (image_opts, filename, fmt,0 , false, false, force_share);if (!blk) {return 1 ;
@@ -3384,14 +3286,9 @@ static int img_snapshot(int argc, char **argv)case 'U' : force_share = true;break ; -case OPTION_OBJECT : { -QemuOpts *opts; - opts =qemu_opts_parse_noisily (&qemu_object_opts, - optarg, true); -if (!opts) { -return 1 ; - } - }break ; +case OPTION_OBJECT : +user_creatable_process_cmdline (optarg); +break ;case OPTION_IMAGE_OPTS : image_opts = true;break ;
@@ -3403,12 +3300,6 @@ static int img_snapshot(int argc, char **argv) } filename = argv[optind++]; -if (qemu_opts_foreach (&qemu_object_opts, - user_creatable_add_opts_foreach, - qemu_img_object_print_help, &error_fatal)) { -return 1 ; - } -/* Open the image */ blk =img_open (image_opts, filename,NULL , bdrv_oflags, false, quiet, force_share);
@@ -3542,14 +3433,9 @@ static int img_rebase(int argc, char **argv)case 'q' : quiet = true;break ; -case OPTION_OBJECT : { -QemuOpts *opts; - opts =qemu_opts_parse_noisily (&qemu_object_opts, - optarg, true); -if (!opts) { -return 1 ; - } - }break ; +case OPTION_OBJECT : +user_creatable_process_cmdline (optarg); +break ;case OPTION_IMAGE_OPTS : image_opts = true;break ;
@@ -3571,12 +3457,6 @@ static int img_rebase(int argc, char **argv) } filename = argv[optind++]; -if (qemu_opts_foreach (&qemu_object_opts, - user_creatable_add_opts_foreach, - qemu_img_object_print_help, &error_fatal)) { -return 1 ; - } -qemu_progress_init (progress,2.0 );qemu_progress_print (0 ,100 );
@@ -3967,14 +3847,9 @@ static int img_resize(int argc, char **argv)case 'q' : quiet = true;break ; -case OPTION_OBJECT : { -QemuOpts *opts; - opts =qemu_opts_parse_noisily (&qemu_object_opts, - optarg, true); -if (!opts) { -return 1 ; - } - }break ; +case OPTION_OBJECT : +user_creatable_process_cmdline (optarg); +break ;case OPTION_IMAGE_OPTS : image_opts = true;break ;
@@ -3996,12 +3871,6 @@ static int img_resize(int argc, char **argv) } filename = argv[optind++]; -if (qemu_opts_foreach (&qemu_object_opts, - user_creatable_add_opts_foreach, - qemu_img_object_print_help, &error_fatal)) { -return 1 ; - } -/* Choose grow, shrink, or absolute resize mode */ switch (size[0 ]) {case '+' :
@@ -4181,12 +4050,7 @@ static int img_amend(int argc, char **argv) quiet = true;break ;case OPTION_OBJECT : - opts =qemu_opts_parse_noisily (&qemu_object_opts, - optarg, true); -if (!opts) { - ret =-1 ; - goto out_no_progress; - } +user_creatable_process_cmdline (optarg);break ;case OPTION_IMAGE_OPTS : image_opts = true;
@@ -4201,13 +4065,6 @@ static int img_amend(int argc, char **argv)error_exit ("Must specify options (-o)" ); } -if (qemu_opts_foreach (&qemu_object_opts, - user_creatable_add_opts_foreach, - qemu_img_object_print_help, &error_fatal)) { - ret =-1 ; - goto out_no_progress; - } -if (quiet) { progress = false; }
@@ -4760,10 +4617,7 @@ static int img_bitmap(int argc, char **argv) merge = true;break ;case OPTION_OBJECT : - opts =qemu_opts_parse_noisily (&qemu_object_opts, optarg, true); -if (!opts) { - goto out; - } +user_creatable_process_cmdline (optarg);break ;case OPTION_IMAGE_OPTS : image_opts = true;
@@ -4771,12 +4625,6 @@ static int img_bitmap(int argc, char **argv) } } -if (qemu_opts_foreach (&qemu_object_opts, - user_creatable_add_opts_foreach, - qemu_img_object_print_help, &error_fatal)) { - goto out; - } -if (QSIMPLEQ_EMPTY (&actions)) {error_report ("Need at least one of --add, --remove, --clear, " "--enable, --disable, or --merge" );
@@ -5034,10 +4882,7 @@ static int img_dd(int argc, char **argv) force_share = true;break ;case OPTION_OBJECT : -if (!qemu_opts_parse_noisily (&qemu_object_opts, optarg, true)) { - ret =-1 ; - goto out; - } +user_creatable_process_cmdline (optarg);break ;case OPTION_IMAGE_OPTS : image_opts = true;
@@ -5084,13 +4929,6 @@ static int img_dd(int argc, char **argv) goto out; } -if (qemu_opts_foreach (&qemu_object_opts, - user_creatable_add_opts_foreach, - qemu_img_object_print_help, &error_fatal)) { - ret =-1 ; - goto out; - } - blk1 =img_open (image_opts, in.filename, fmt,0 , false, false, force_share);
@@ -5311,11 +5149,7 @@ static int img_measure(int argc, char **argv) force_share = true;break ;case OPTION_OBJECT : - object_opts =qemu_opts_parse_noisily (&qemu_object_opts, - optarg, true); -if (!object_opts) { - goto out; - } +user_creatable_process_cmdline (optarg);break ;case OPTION_IMAGE_OPTS : image_opts = true;
@@ -5345,12 +5179,6 @@ static int img_measure(int argc, char **argv) } } -if (qemu_opts_foreach (&qemu_object_opts, - user_creatable_add_opts_foreach, - qemu_img_object_print_help, &error_fatal)) { - goto out; - } -if (argc - optind >1 ) {error_report ("At most one filename argument is allowed." ); goto out;
@@ -5490,7 +5318,6 @@ int main(int argc, char **argv)error_exit ("Not enough arguments" ); } -qemu_add_opts (&qemu_object_opts);qemu_add_opts (&qemu_source_opts);qemu_add_opts (&qemu_trace_opts);
Signature · 1 line
2.29.2
Re: [PATCH v2 25/31] qemu-img: Use user_creatable_process_cmdline() for --object
Quoted 13 lines · Kevin Wolf
This switches qemu-img from a QemuOpts-based parser for --object to
user_creatable_process_cmdline()which uses a keyval parser and enforces the QAPI schema.Apart from being a cleanup, this makes non-scalar properties accessible.
Signed-off-by Kevin Wolf <[email protected]>--- qemu-img.c | 239 ++++++++--------------------------------------------- 1 file changed, 33 insertions(+), 206 deletions(-)
qemu-img.c static int img_compare(int argc, char **argv) · line 1432
Quoted 10 lines
qemu-img.c +0
-7@@ -1423,15 +1373,9 @@ static int img_compare(int argc, char **argv)case 'U' : force_share = true;break ; -case OPTION_OBJECT : { -QemuOpts *opts; - opts =qemu_opts_parse_noisily (&qemu_object_opts, - optarg, true); -if (!opts) { - ret =2 ; - goto out4;
Our exit status here of 2 on failure appears to be intentional (since we reserve 0 for identical, 1 for mismatch, >1 for error)...
qemu-img.c static int img_create(int argc, char **argv) · line 554
Quoted 5 lines
qemu-img.c +3
-2- } - }break ; +case OPTION_OBJECT : +user_creatable_process_cmdline (optarg); +break ;
...but becomes 1 here. Does that matter?
/me goes and tests...
Ouch: with current qemu.git master and none of this series applied:
$ ./qemu-img compare --object foo,id=x /dev/null /dev/null
qemu-img: invalid object type: foo
$ echo $?
1
$ gdb --args ./qemu-img compare --object foo,id=x /dev/null /dev/null
(gdb) b qemu_opts_pars
(gdb) r
(gdb) fin
Run till exit from #0 qemu_opts_parse_noisily (
list=0x55555578f020 <qemu_object_opts>, params=0x7fffffffd8a8
"foo,id=x",
permit_abbrev=true) at ../util/qemu-option.c:948
0x00005555555805f9 in img_compare (argc=5, argv=0x7fffffffd480)
at ../qemu-img.c:1428
1428 opts = qemu_opts_parse_noisily(&qemu_object_opts,
Value returned is $1 = (QemuOpts *) 0x55555583b4b0
(gdb) p *opts
$3 = {id = 0x5555557a0d58 <qemu_trace_opts+24> "`\264\203UUU", list = 0x51,
loc = {kind = (unknown: 0x557f08f0), num = 21845,
ptr = 0x55555578f020 <qemu_object_opts>, prev = 0x0}, head = {
tqh_first = 0x0, tqh_circ = {tql_next = 0x0, tql_prev = 0x0}}, next = {
tqe_next = 0x55555583b500, tqe_circ = {tql_next = 0x55555583b500,
tql_prev = 0x55555583b528}}}
(gdb)That looks buggy. qemu_opts_parse_noisily() is NOT returning NULL, but rather a pointer to something garbage (that id pointing to a garbage string in the middle of qemu_trace_opts is fishy), and so we've been exiting with status 1 in spite of the code.
Looks like we'll want a separate patch fixing that first.
qemu-img.c static int img_compare(int argc, char **argv) · line 1457
Quoted 12 lines
qemu-img.c +0
-5case OPTION_IMAGE_OPTS : image_opts = true;break ;@@ -1450,13 +1394,6 @@ static int img_compare(int argc, char **argv) filename1 = argv[optind++]; filename2 = argv[optind++]; -if (qemu_opts_foreach (&qemu_object_opts, - user_creatable_add_opts_foreach, - qemu_img_object_print_help, &error_fatal)) { - ret =2 ; - goto out4;
Same deal with return value. Except here we used &error_fatal (which forces an exit status of 1 rather than returning), and so never even reach the ret=2 code. Looks like we broke that in commit 334c43e2c3, where we used to pass NULL instead of &error_fatal (although that commit was in turn fixing another problem).
The rest of this patch looks fine, although maybe user_creatable_process_cmdline() should be given an 'int status' parameter for specifying 1 vs. 2 (or any other non-zero value) if we intend to fix the status of qemu-img compare failures. (Thankfully, even though qemu-img check also has a variety of documented return values other than 1, at least it documented 1 as internal errors and was already using 1 for --object failures).
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH v2 25/31] qemu-img: Use user_creatable_process_cmdline() for --object
Quoted 36 lines · Eric Blake
Quoted 13 lines · Kevin Wolf
This switches qemu-img from a QemuOpts-based parser for --object to
user_creatable_process_cmdline()which uses a keyval parser and enforces the QAPI schema.Apart from being a cleanup, this makes non-scalar properties accessible.
Signed-off-by Kevin Wolf <[email protected]>--- qemu-img.c | 239 ++++++++--------------------------------------------- 1 file changed, 33 insertions(+), 206 deletions(-)qemu-img.c static int img_compare(int argc, char **argv) · line 1432
Quoted 10 lines
qemu-img.c +0
-7@@ -1423,15 +1373,9 @@ static int img_compare(int argc, char **argv)case 'U' : force_share = true;break ; -case OPTION_OBJECT : { -QemuOpts *opts; - opts =qemu_opts_parse_noisily (&qemu_object_opts, - optarg, true); -if (!opts) { - ret =2 ; - goto out4;Our exit status here of 2 on failure appears to be intentional (since we reserve 0 for identical, 1 for mismatch, >1 for error)...
qemu-img.c static int img_create(int argc, char **argv) · line 554
Quoted 5 lines
qemu-img.c +3
-2- } - }break ; +case OPTION_OBJECT : +user_creatable_process_cmdline (optarg); +break ;...but becomes 1 here. Does that matter?
Quoted 8 lines
/me goes and tests...
Ouch: with current qemu.git master and none of this series applied:
$ ./qemu-img compare --object foo,id=x /dev/null /dev/null qemu-img: invalid object type: foo $ echo $? 1
Okay, that didn't do what I expected, but this does:
$ ./qemu-img compare --object foo,id=1 /dev/null /dev/null qemu-img: Parameter 'id' expects an identifier Identifiers consist of letters, digits, '-', '.', '_', starting with a letter. $ echo $? 2
Quoted 6 lines
$ gdb --args ./qemu-img compare --object foo,id=x /dev/null /dev/null
(gdb) b qemu_opts_pars
(gdb) r
(gdb) fin
Run till exit from #0 qemu_opts_parse_noisily (
list=0x55555578f020 <qemu_object_opts>, params=0x7fffffffd8a8Quoted 8 lines
"foo,id=x",
permit_abbrev=true) at ../util/qemu-option.c:948
0x00005555555805f9 in img_compare (argc=5, argv=0x7fffffffd480)
at ../qemu-img.c:1428
1428 opts = qemu_opts_parse_noisily(&qemu_object_opts,
Value returned is $1 = (QemuOpts *) 0x55555583b4b0
(gdb) p *opts
$3 = {id = 0x5555557a0d58 <qemu_trace_opts+24> "`\264\203UUU", list = 0x51,and this may be my confusion with gdb. Right after 'fin', *opts is not the same as *$1 (apparently gdb has stopped at a point where the 'opts' currently in scope is not the opts set by qemu_opts_parse_noisily, but before the opts in scope has actually been assigned the returned value).
Quoted 7 lines
That looks buggy.
qemu_opts_parse_noisily()is NOT returning NULL, but rather a pointer to something garbage (that id pointing to a garbage string in the middle ofqemu_trace_optsis fishy), and so we've been exiting with status 1 in spite of the code.Looks like we'll want a separate patch fixing that first.
So I was wrong on when qemu_opts_parse_noisily() returns NULL - it does NOT reject unknown object names (that was the job of the qemu_opts_foreach call later), but merely rejects bad/duplicate ids. Thus this code was indeed giving an exit status of 2 when actually triggered correctly,
Quoted 8 lines
Quoted 8 lines
qemu-img.c +0
-0case OPTION_IMAGE_OPTS : image_opts = true;break ;@@ -1450,13 +1394,6 @@ static int img_compare(int argc, char **argv) filename1 = argv[optind++]; filename2 = argv[optind++];
Quoted 11 lines
qemu-img.c static int img_compare(int argc, char **argv) · line 1457
Quoted 5 lines
qemu-img.c +0
-5-if (qemu_opts_foreach (&qemu_object_opts, - user_creatable_add_opts_foreach, - qemu_img_object_print_help, &error_fatal)) { - ret =2 ; - goto out4;Same deal with return value. Except here we used
&error_fatal(which forces an exit status of 1 rather than returning), and so never even reach the ret=2 code. Looks like we broke that in commit334c43e2c3, where we used to pass NULL instead of&error_fatal(although that commit was in turn fixing another problem).
...and THIS spot is why my original attempt to prove that your code was causing a regression was seeing an exit status of 1, where I instead ended up proving that we already regressed.
Quoted 9 lines
The rest of this patch looks fine, although maybe
user_creatable_process_cmdline()should be given an 'int status' parameter for specifying 1 vs. 2 (or any other non-zero value) if we intend to fix the status of qemu-img compare failures. (Thankfully, even though qemu-img check also has a variety of documented return values other than 1, at least it documented 1 as internal errors and was already using 1 for --object failures).
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 26/31 qemu-nbd: Use user_creatable_process_cmdline() for --object
In reply to Kevin WolfThis switches qemu-nbd from a QemuOpts-based parser for --object to user_creatable_process_cmdline() which uses a keyval parser and enforces the QAPI schema.
Apart from being a cleanup, this makes non-scalar properties accessible.
--- qemu-nbd.c | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-)
qemu-nbd.c +3 -31
@@ -401,24 +401,6 @@ static QemuOptsList file_opts = { }, }; -static QemuOptsList qemu_object_opts = { - .name ="object" , - .implied_opt_name ="qom-type" , - .head =QTAILQ_HEAD_INITIALIZER (qemu_object_opts.head), - .desc = { - { } - }, -}; - -static bool qemu_nbd_object_print_help (const char *type,QemuOpts *opts) -{ -if (user_creatable_print_help (type, opts)) { -exit (0 ); - } -return true; -} - -static QCryptoTLSCreds *nbd_get_tls_creds (const char *id,bool list,Error **errp) {
@@ -594,7 +576,6 @@ int main(int argc, char **argv)qcrypto_init (&error_fatal);module_call_init (MODULE_INIT_QOM ); -qemu_add_opts (&qemu_object_opts);qemu_add_opts (&qemu_trace_opts);qemu_init_exec_dir (argv[0 ]);
@@ -747,14 +728,9 @@ int main(int argc, char **argv)case '?' :error_report ("Try `%s --help' for more information." , argv[0 ]);exit (EXIT_FAILURE ); -case QEMU_NBD_OPT_OBJECT : { -QemuOpts *opts; - opts =qemu_opts_parse_noisily (&qemu_object_opts, - optarg, true); -if (!opts) { -exit (EXIT_FAILURE ); - } - }break ; +case QEMU_NBD_OPT_OBJECT : +user_creatable_process_cmdline (optarg); +break ;case QEMU_NBD_OPT_TLSCREDS : tlscredsid = optarg;break ;
@@ -802,10 +778,6 @@ int main(int argc, char **argv) export_name ="" ; } -qemu_opts_foreach (&qemu_object_opts, - user_creatable_add_opts_foreach, - qemu_nbd_object_print_help, &error_fatal); -if (!trace_init_backends ()) {exit (1 ); }
Signature · 1 line
2.29.2
Re: [PATCH v2 26/31] qemu-nbd: Use user_creatable_process_cmdline() for --object
Quoted 11 lines · Kevin Wolf
This switches qemu-nbd from a QemuOpts-based parser for --object to
user_creatable_process_cmdline()which uses a keyval parser and enforces the QAPI schema.Apart from being a cleanup, this makes non-scalar properties accessible.
Signed-off-by Kevin Wolf <[email protected]>--- qemu-nbd.c | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 27/31 qom: Add user_creatable_add_from_str()
In reply to Kevin WolfThis is a version of user_creatable_process_cmdline() with an Error parameter that never calls exit() and is therefore usable in HMP.
--- include/qom/object_interfaces.h | 16 ++++++++++++++++ qom/object_interfaces.c | 29 ++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 5 deletions(-)
include/qom/object_interfaces.h +16 -0
@@ -144,6 +144,22 @@ typedef bool (*user_creatable_add_opts_predicate)(const char *type);int user_creatable_add_opts_foreach (void *opaque,QemuOpts *opts,Error **errp); +/** +* user_creatable_add_from_str: +* @optarg: the object definition string as passed on the command line +* @errp: if an error occurs, a pointer to an area to store the error +* +* Create an instance of the user creatable object by parsing optarg +* with a keyval parser and implicit key 'qom-type', converting the +* result to ObjectOptions and calling into qmp_object_add(). +* +* If a help option is given, print help instead. +* +* Returns: true when an object was successfully created, false when an error +* occurred (*errp is set then) or help was printed (*errp is not set). +*/ +bool user_creatable_add_from_str (const char *optarg,Error **errp); +/** * user_creatable_process_cmdline: * @optarg: the object definition string as passed on the command line
qom/object_interfaces.c +24 -5
@@ -282,26 +282,45 @@ static void user_creatable_print_help_from_qdict(QDict *args) } } -void user_creatable_process_cmdline (const char *optarg) +bool user_creatable_add_from_str (const char *optarg,Error **errp) { +ERRP_GUARD ();QDict *args;bool help;Visitor *v;ObjectOptions *options; - args =keyval_parse (optarg,"qom-type" , &help, &error_fatal); + args =keyval_parse (optarg,"qom-type" , &help, errp); +if (*errp) { +return false; + }if (help) {user_creatable_print_help_from_qdict (args); -exit (EXIT_SUCCESS ); +qobject_unref (args); +return false; } v =qobject_input_visitor_new_keyval (QOBJECT (args)); -visit_type_ObjectOptions (v,NULL , &options, &error_fatal); +visit_type_ObjectOptions (v,NULL , &options, errp);visit_free (v);qobject_unref (args); -user_creatable_add_qapi (options, &error_fatal); +if (*errp) { + goto out; + } + +user_creatable_add_qapi (options, errp); +out:qapi_free_ObjectOptions (options); +return !*errp; +} + +void user_creatable_process_cmdline (const char *optarg) +{ +if (!user_creatable_add_from_str (optarg, &error_fatal)) { +/* Help was printed */ +exit (EXIT_SUCCESS ); + } }bool user_creatable_del (const char *id,Error **errp)
Signature · 1 line
2.29.2
Re: [PATCH v2 27/31] qom: Add user_creatable_add_from_str()
Quoted 15 lines · Kevin Wolf
This is a version of
user_creatable_process_cmdline()with an Error parameter that never callsexit()and is therefore usable in HMP.Signed-off-by Kevin Wolf <[email protected]>--- include/qom/object_interfaces.h | 16 ++++++++++++++++ qom/object_interfaces.c | 29 ++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 5 deletions(-)include/qom/object_interfaces.h +5
-0+/** +* user_creatable_add_from_str: +* @optarg: the object definition string as passed on the command line +* @errp: if an error occurs, a pointer to an area to store the error +*
include/qom/object_interfaces.h typedef bool (*user_creatable_add_opts_predicate)(const char *type); · line 161
Quoted 10 lines
include/qom/object_interfaces.h +10
-0+* Create an instance of the user creatable object by parsing optarg +* with a keyval parser and implicit key 'qom-type', converting the +* result to ObjectOptions and calling into qmp_object_add(). +* +* If a help option is given, print help instead. +* +* Returns: true when an object was successfully created, false when an error +* occurred (*errp is set then) or help was printed (*errp is not set). +*/ +bool user_creatable_add_from_str (const char *optarg,Error **errp);
This could be used to fix the exit status 2 issue in qemu-img convert, if you rearrange the series a bit.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH v2 27/31] qom: Add user_creatable_add_from_str()
Am 26.02.2021 um 23:21 hat Eric Blake geschrieben:
Quoted 21 lines · Kevin Wolf
Quoted 20 lines
This is a version of
user_creatable_process_cmdline()with an Error parameter that never callsexit()and is therefore usable in HMP.Signed-off-by Kevin Wolf <[email protected]>--- include/qom/object_interfaces.h | 16 ++++++++++++++++ qom/object_interfaces.c | 29 ++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 5 deletions(-)+/**
+ *user_creatable_add_from_str:
+ * @optarg: the object definition string as passed on the command line
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Create an instance of the user creatable object by parsing optarg
+ * with a keyval parser and implicit key 'qom-type', converting the
+ * result to ObjectOptions and calling intoqmp_object_add().
+ *
+ * If a help option is given, print help instead.
Quoted 8 lines
Quoted 5 lines
+ *
+ * Returns: true when an object was successfully created, false when an error
+ * occurred (*errp is set then) or help was printed (*errp is not set).
+ */
+booluser_creatable_add_from_str(const char *optarg, Error **errp);This could be used to fix the exit status 2 issue in qemu-img convert, if you rearrange the series a bit.
Thanks for the suggestion, with this reordering the fix became quite simple.
Kevin
PATCH v2 28/31 hmp: QAPIfy object_add
In reply to Kevin WolfThis switches the HMP command object_add from a QemuOpts-based parser to user_creatable_add_from_str() which uses a keyval parser and enforces the QAPI schema.
Apart from being a cleanup, this makes non-scalar properties and help accessible. In order for help to be printed to the monitor instead of stdout, the printf() calls in the help functions are changed to qemu_printf().
--- monitor/hmp-cmds.c | 17 ++--------------- qom/object_interfaces.c | 11 ++++++----- hmp-commands.hx | 2 +- 3 files changed, 9 insertions(+), 21 deletions(-)
monitor/hmp-cmds.c +2 -15
@@ -1670,24 +1670,11 @@ void hmp_netdev_del(Monitor *mon, const QDict *qdict)void hmp_object_add (Monitor *mon,const QDict *qdict) { +const char *options =qdict_get_str (qdict,"object" );Error *err =NULL ; -QemuOpts *opts; -Object *obj =NULL ; - - opts =qemu_opts_from_qdict (qemu_find_opts ("object" ), qdict, &err); -if (err) { - goto end; - } - obj =user_creatable_add_opts (opts, &err); -qemu_opts_del (opts); - -end: +user_creatable_add_from_str (options, &err);hmp_handle_error (mon, err); - -if (obj) { -object_unref (obj); - } }void hmp_getfd (Monitor *mon,const QDict *qdict)
qom/object_interfaces.c +6 -5
@@ -13,6 +13,7 @@#include "qemu/help_option.h" #include "qemu/module.h" #include "qemu/option.h" +#include "qemu/qemu-print.h" #include "qapi/opts-visitor.h" #include "qemu/config-file.h"
@@ -212,11 +213,11 @@ static void user_creatable_print_types(void) {GSList *l, *list; -printf ("List of user creatable objects:\n" ); +qemu_printf ("List of user creatable objects:\n" ); list =object_class_get_list_sorted (TYPE_USER_CREATABLE , false);for (l = list; l !=NULL ; l = l->next) {ObjectClass *oc =OBJECT_CLASS (l->data); -printf (" %s\n" ,object_class_get_name (oc)); +qemu_printf (" %s\n" ,object_class_get_name (oc)); }g_slist_free (list); }
@@ -247,12 +248,12 @@ static bool user_creatable_print_type_properites(const char *type) }g_ptr_array_sort (array, (GCompareFunc )qemu_pstrcmp0);if (array->len >0 ) { -printf ("%s options:\n" , type); +qemu_printf ("%s options:\n" , type); }else { -printf ("There are no options for %s.\n" , type); +qemu_printf ("There are no options for %s.\n" , type); }for (i =0 ; i < array->len; i++) { -printf ("%s\n" , (char *)array->pdata[i]); +qemu_printf ("%s\n" , (char *)array->pdata[i]); }g_ptr_array_set_free_func (array, g_free);g_ptr_array_free (array, true);
hmp-commands.hx +1 -1
@@ -1337,7 +1337,7 @@ ERST { .name = "object_add", - .args_type = "object:O", + .args_type = "object:S", .params = "[qom-type=]type,id=str[,prop=value][,...]", .help = "create QOM object", .cmd = hmp_object_add,
Signature · 1 line
2.29.2
Re: [PATCH v2 28/31] hmp: QAPIfy object_add
Quoted 10 lines · * Kevin Wolf ([email protected]) wrote:
This switches the HMP command
object_addfrom a QemuOpts-based parser touser_creatable_add_from_str()which uses a keyval parser and enforces the QAPI schema.Apart from being a cleanup, this makes non-scalar properties and help accessible. In order for help to be printed to the monitor instead of stdout, the
printf()calls in the help functions are changed toqemu_printf().Signed-off-by Kevin Wolf <[email protected]>
Quoted 95 lines
--- monitor/hmp-cmds.c | 17 ++--------------- qom/object_interfaces.c | 11 ++++++----- hmp-commands.hx | 2 +- 3 files changed, 9 insertions(+), 21 deletions(-)monitor/hmp-cmds.c +2
-15@@ -1670,24 +1670,11 @@ void hmp_netdev_del(Monitor *mon, const QDict *qdict)void hmp_object_add (Monitor *mon,const QDict *qdict) { +const char *options =qdict_get_str (qdict,"object" );Error *err =NULL ; -QemuOpts *opts; -Object *obj =NULL ; - - opts =qemu_opts_from_qdict (qemu_find_opts ("object" ), qdict, &err); -if (err) { - goto end; - } - obj =user_creatable_add_opts (opts, &err); -qemu_opts_del (opts); - -end: +user_creatable_add_from_str (options, &err);hmp_handle_error (mon, err); - -if (obj) { -object_unref (obj); - } }void hmp_getfd (Monitor *mon,const QDict *qdict)qom/object_interfaces.c +6
-5@@ -13,6 +13,7 @@#include "qemu/help_option.h" #include "qemu/module.h" #include "qemu/option.h" +#include "qemu/qemu-print.h" #include "qapi/opts-visitor.h" #include "qemu/config-file.h" @@ -212,11 +213,11 @@ static void user_creatable_print_types(void) {GSList *l, *list; -printf ("List of user creatable objects:\n" ); +qemu_printf ("List of user creatable objects:\n" ); list =object_class_get_list_sorted (TYPE_USER_CREATABLE , false);for (l = list; l !=NULL ; l = l->next) {ObjectClass *oc =OBJECT_CLASS (l->data); -printf (" %s\n" ,object_class_get_name (oc)); +qemu_printf (" %s\n" ,object_class_get_name (oc)); }g_slist_free (list); }@@ -247,12 +248,12 @@ static bool user_creatable_print_type_properites(const char *type) }g_ptr_array_sort (array, (GCompareFunc )qemu_pstrcmp0);if (array->len >0 ) { -printf ("%s options:\n" , type); +qemu_printf ("%s options:\n" , type); }else { -printf ("There are no options for %s.\n" , type); +qemu_printf ("There are no options for %s.\n" , type); }for (i =0 ; i < array->len; i++) { -printf ("%s\n" , (char *)array->pdata[i]); +qemu_printf ("%s\n" , (char *)array->pdata[i]); }g_ptr_array_set_free_func (array, g_free);g_ptr_array_free (array, true);hmp-commands.hx +1
-1@@ -1337,7 +1337,7 @@ ERST { .name = "object_add", - .args_type = "object:O", + .args_type = "object:S", .params = "[qom-type=]type,id=str[,prop=value][,...]", .help = "create QOM object", .cmd = hmp_object_add,Signature · 1 line
2.29.2
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [PATCH v2 28/31] hmp: QAPIfy object_add
In reply to Kevin WolfQuoted 9 lines · Kevin Wolf
This switches the HMP command
object_addfrom a QemuOpts-based parser touser_creatable_add_from_str()which uses a keyval parser and enforces the QAPI schema.Apart from being a cleanup, this makes non-scalar properties and help accessible. In order for help to be printed to the monitor instead of stdout, the
printf()calls in the help functions are changed toqemu_printf().
Quoted 7 lines
Signed-off-by Kevin Wolf <[email protected]>--- monitor/hmp-cmds.c | 17 ++--------------- qom/object_interfaces.c | 11 ++++++----- hmp-commands.hx | 2 +- 3 files changed, 9 insertions(+), 21 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 29/31 qom: Add user_creatable_parse_str()
In reply to Kevin WolfThe system emulator has a more complicated way of handling command line options in that it reorders options before it processes them. This means that parsing object options and creating the object happen at two different points. Split the parsing part into a separate function that can be reused by the system emulator command line.
--- include/qom/object_interfaces.h | 15 +++++++++++++++ qom/object_interfaces.c | 20 ++++++++++++++------ 2 files changed, 29 insertions(+), 6 deletions(-)
include/qom/object_interfaces.h +15 -0
@@ -144,6 +144,21 @@ typedef bool (*user_creatable_add_opts_predicate)(const char *type);int user_creatable_add_opts_foreach (void *opaque,QemuOpts *opts,Error **errp); +/** +* user_creatable_parse_str: +* @optarg: the object definition string as passed on the command line +* @errp: if an error occurs, a pointer to an area to store the error +* +* Parses the option for the user creatable object with a keyval parser and +* implicit key 'qom-type', converting the result to ObjectOptions. +* +* If a help option is given, print help instead. +* +* Returns: ObjectOptions on success, NULL when an error occurred (*errp is set +* then) or help was printed (*errp is not set). +*/ +ObjectOptions *user_creatable_parse_str (const char *optarg,Error **errp); +/** * user_creatable_add_from_str: * @optarg: the object definition string as passed on the command line
qom/object_interfaces.c +14 -6
@@ -283,7 +283,7 @@ static void user_creatable_print_help_from_qdict(QDict *args) } } -bool user_creatable_add_from_str (const char *optarg,Error **errp) +ObjectOptions *user_creatable_parse_str (const char *optarg,Error **errp) {ERRP_GUARD ();QDict *args;
@@ -293,12 +293,12 @@ bool user_creatable_add_from_str(const char *optarg, Error **errp) args =keyval_parse (optarg,"qom-type" , &help, errp);if (*errp) { -return false; +return NULL ; }if (help) {user_creatable_print_help_from_qdict (args);qobject_unref (args); -return false; +return NULL ; } v =qobject_input_visitor_new_keyval (QOBJECT (args));
@@ -306,12 +306,20 @@ bool user_creatable_add_from_str(const char *optarg, Error **errp)visit_free (v);qobject_unref (args); -if (*errp) { - goto out; +return options; +} + +bool user_creatable_add_from_str (const char *optarg,Error **errp) +{ +ERRP_GUARD (); +ObjectOptions *options; + + options =user_creatable_parse_str (optarg, errp); +if (!options) { +return false; }user_creatable_add_qapi (options, errp); -out:qapi_free_ObjectOptions (options);return !*errp; }
Signature · 1 line
2.29.2
Re: [PATCH v2 29/31] qom: Add user_creatable_parse_str()
Quoted 6 lines · Kevin Wolf
The system emulator has a more complicated way of handling command line options in that it reorders options before it processes them. This means that parsing object options and creating the object happen at two different points. Split the parsing part into a separate function that can be reused by the system emulator command line.
Quoted 6 lines
Signed-off-by Kevin Wolf <[email protected]>--- include/qom/object_interfaces.h | 15 +++++++++++++++ qom/object_interfaces.c | 20 ++++++++++++++------ 2 files changed, 29 insertions(+), 6 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 30/31 vl: QAPIfy -object
In reply to Kevin WolfThis switches the system emulator from a QemuOpts-based parser for -object to user_creatable_parse_str() which uses a keyval parser and enforces the QAPI schema.
Apart from being a cleanup, this makes non-scalar properties accessible.
This adopts a similar model as -blockdev uses: When parsing the option, create the ObjectOptions and queue them. At the later point where we used to create objects for the collected QemuOpts, the ObjectOptions queue is processed instead.
A complication compared to -blockdev is that object definitions are supported in -readconfig and -writeconfig.
After this patch, -readconfig still works, though it still goes through the QemuOpts parser, which means that improvements like non-scalar properties are still not available in config files.
-writeconfig stops working for -object. Tough luck. It has never supported all options (not even the common ones), so supporting one less isn't the end of the world. As object definitions from -readconfig still go through QemuOpts, they are still included in -writeconfig output, which at least prevents destroying your existing configuration when you just wanted to add another option.
--- softmmu/vl.c | 109 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 84 insertions(+), 25 deletions(-)
softmmu/vl.c +84 -25
@@ -113,6 +113,7 @@#include "sysemu/replay.h" #include "qapi/qapi-events-run-state.h" #include "qapi/qapi-visit-block-core.h" +#include "qapi/qapi-visit-qom.h" #include "qapi/qapi-visit-ui.h" #include "qapi/qapi-commands-block-core.h" #include "qapi/qapi-commands-migration.h"
@@ -132,6 +133,14 @@ typedef struct BlockdevOptionsQueueEntry { typedef QSIMPLEQ_HEAD(, BlockdevOptionsQueueEntry) BlockdevOptionsQueue; +typedef struct ObjectOptionsQueueEntry { +ObjectOptions *options; +Location loc; +QTAILQ_ENTRY (ObjectOptionsQueueEntry) next; +}ObjectOptionsQueueEntry ; + +typedef QTAILQ_HEAD(, ObjectOptionsQueueEntry) ObjectOptionsQueue; +static const char *cpu_option;static const char *mem_path;static const char *incoming;
@@ -143,6 +152,7 @@ static int snapshot;static bool preconfig_requested;static QemuPluginList plugin_list =QTAILQ_HEAD_INITIALIZER (plugin_list);static BlockdevOptionsQueue bdo_queue =QSIMPLEQ_HEAD_INITIALIZER (bdo_queue); +static ObjectOptionsQueue obj_queue =QTAILQ_HEAD_INITIALIZER (obj_queue);static bool nographic = false;static int mem_prealloc;/* force preallocation of physical target memory */ static ram_addr_t ram_size;
@@ -1691,12 +1701,9 @@ static int machine_set_property(void *opaque,* cannot be created here, as it depends on the chardev * already existing. */ -static bool object_create_early (const char *type,QemuOpts *opts) +static bool object_create_early (ObjectOptions *options) { -if (user_creatable_print_help (type, opts)) { -exit (0 ); - } - +const char *type =ObjectType_str (options->qom_type);/* * Objects should not be made "delayed" without a reason. If you * add one, state the reason in a comment!
@@ -1744,6 +1751,56 @@ static bool object_create_early(const char *type, QemuOpts *opts)return true; } +static void object_queue_create (bool early) +{ +ObjectOptionsQueueEntry *entry, *next; + + QTAILQ_FOREACH_SAFE(entry, &obj_queue, next, next) { +if (early !=object_create_early (entry->options)) { +continue ; + } +QTAILQ_REMOVE (&obj_queue, entry, next); +loc_push_restore (&entry->loc); +user_creatable_add_qapi (entry->options, &error_fatal); +loc_pop (&entry->loc); +qapi_free_ObjectOptions (entry->options); +g_free (entry); + } +} + +/* +* -readconfig still parses things into QemuOpts. Convert any such +* configurations to an ObjectOptionsQueueEntry. +* +* This is more restricted than the normal -object parser because QemuOpts +* parsed things, so no support for non-scalar properties. Help is also not +* supported (but this shouldn't be requested in a config file anyway). +*/ +static int object_readconfig_to_qapi (void *opaque,QemuOpts *opts,Error **errp) +{ +ERRP_GUARD (); +ObjectOptionsQueueEntry *entry; +ObjectOptions *options; +QDict *args =qemu_opts_to_qdict (opts,NULL ); +Visitor *v; + + v =qobject_input_visitor_new_keyval (QOBJECT (args)); +visit_type_ObjectOptions (v,NULL , &options, errp); +visit_free (v); +qobject_unref (args); + +if (*errp) { +return -1 ; + } + + entry =g_new0 (ObjectOptionsQueueEntry,1 ); + entry->options = options; +loc_save (&entry->loc); +QTAILQ_INSERT_TAIL (&obj_queue, entry, next); + +return 0 ; +} +static void qemu_apply_machine_options (void ) {MachineClass *machine_class =MACHINE_GET_CLASS (current_machine);
@@ -1816,8 +1873,8 @@ static void qemu_create_early_backends(void) }qemu_opts_foreach (qemu_find_opts ("object" ), - user_creatable_add_opts_foreach, - object_create_early, &error_fatal); + object_readconfig_to_qapi,NULL , &error_fatal); +object_queue_create (true);/* spice needs the timers to be initialized by this point */ /* spice must initialize before audio as it changes the default auiodev */
@@ -1841,16 +1898,6 @@ static void qemu_create_early_backends(void)audio_init_audiodevs (); } - -/* -* The remainder of object creation happens after the -* creation of chardev, fsdev, net clients and device data types. -*/ -static bool object_create_late (const char *type,QemuOpts *opts) -{ -return !object_create_early (type, opts); -} -static void qemu_create_late_backends (void ) {if (qtest_chrdev) {
@@ -1859,9 +1906,11 @@ static void qemu_create_late_backends(void)net_init_clients (&error_fatal); -qemu_opts_foreach (qemu_find_opts ("object" ), - user_creatable_add_opts_foreach, - object_create_late, &error_fatal); +/* +* The remainder of object creation happens after the +* creation of chardev, fsdev, net clients and device data types. +*/ +object_queue_create (false);if (tpm_init () <0 ) {exit (1 );
@@ -3407,12 +3456,22 @@ void qemu_init(int argc, char **argv, char **envp)#endif break ;case QEMU_OPTION_object: - opts =qemu_opts_parse_noisily (qemu_find_opts ("object" ), - optarg, true); -if (!opts) { -exit (1 ); + { +ObjectOptionsQueueEntry *entry; +ObjectOptions *options; + + options =user_creatable_parse_str (optarg, &error_fatal); +if (!options) { +/* Help was printed */ +exit (EXIT_SUCCESS ); + } + + entry =g_new0 (ObjectOptionsQueueEntry,1 ); + entry->options = options; +loc_save (&entry->loc); +QTAILQ_INSERT_TAIL (&obj_queue, entry, next); +break ; } -break ;case QEMU_OPTION_overcommit: opts =qemu_opts_parse_noisily (qemu_find_opts ("overcommit" ), optarg, false);
Signature · 1 line
2.29.2
Re: [PATCH v2 30/31] vl: QAPIfy -object
Quoted 18 lines · Kevin Wolf
This switches the system emulator from a QemuOpts-based parser for -object to
user_creatable_parse_str()which uses a keyval parser and enforces the QAPI schema.Apart from being a cleanup, this makes non-scalar properties accessible.
This adopts a similar model as -blockdev uses: When parsing the option, create the ObjectOptions and queue them. At the later point where we used to create objects for the collected QemuOpts, the ObjectOptions queue is processed instead.
A complication compared to -blockdev is that object definitions are supported in -readconfig and -writeconfig.
After this patch, -readconfig still works, though it still goes through the QemuOpts parser, which means that improvements like non-scalar properties are still not available in config files.
Quoted 6 lines
-writeconfig stops working for -object. Tough luck. It has never supported all options (not even the common ones), so supporting one less isn't the end of the world. As object definitions from -readconfig still go through QemuOpts, they are still included in -writeconfig output, which at least prevents destroying your existing configuration when you just wanted to add another option.
And Paolo has submitted a patch deprecating it.
Quoted 6 lines
Signed-off-by Kevin Wolf <[email protected]>--- softmmu/vl.c | 109 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 84 insertions(+), 25 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
PATCH v2 31/31 qom: Drop QemuOpts based interfaces
In reply to Kevin Wolfuser_creatable_add_opts() has only a single user left, which is a test case. Rewrite the test to use user_creatable_add_type() instead (which is the remaining function that doesn't require a QAPI schema) and drop the QemuOpts related functions.
--- include/qom/object_interfaces.h | 59 ------------------------ qom/object_interfaces.c | 81 --------------------------------- tests/check-qom-proplist.c | 42 ++++++++--------- 3 files changed, 20 insertions(+), 162 deletions(-)
include/qom/object_interfaces.h +0 -59
@@ -99,51 +99,6 @@ Object *user_creatable_add_type(const char *type, const char *id,*/ void user_creatable_add_qapi (ObjectOptions *options,Error **errp); -/** -* user_creatable_add_opts: -* @opts: the object definition -* @errp: if an error occurs, a pointer to an area to store the error -* -* Create an instance of the user creatable object whose type -* is defined in @opts by the 'qom-type' option, placing it -* in the object composition tree with name provided by the -* 'id' field. The remaining options in @opts are used to -* initialize the object properties. -* -* Returns: the newly created object or NULL on error -*/ -Object *user_creatable_add_opts (QemuOpts *opts,Error **errp); - - -/** -* user_creatable_add_opts_predicate: -* @type: the QOM type to be added -* -* A callback function to determine whether an object -* of type @type should be created. Instances of this -* callback should be passed to user_creatable_add_opts_foreach -*/ -typedef bool (*user_creatable_add_opts_predicate )(const char *type); - -/** -* user_creatable_add_opts_foreach: -* @opaque: a user_creatable_add_opts_predicate callback or NULL -* @opts: options to create -* @errp: unused -* -* An iterator callback to be used in conjunction with -* the qemu_opts_foreach() method for creating a list of -* objects from a set of QemuOpts -* -* The @opaque parameter can be passed a user_creatable_add_opts_predicate -* callback to filter which types of object are created during iteration. -* When it fails, report the error. -* -* Returns: 0 on success, -1 when an error was reported. -*/ -int user_creatable_add_opts_foreach (void *opaque, -QemuOpts *opts,Error **errp); -/** * user_creatable_parse_str: * @optarg: the object definition string as passed on the command line
@@ -190,20 +145,6 @@ bool user_creatable_add_from_str(const char *optarg, Error **errp);*/ void user_creatable_process_cmdline (const char *optarg); -/** -* user_creatable_print_help: -* @type: the QOM type to be added -* @opts: options to create -* -* Prints help if requested in @type or @opts. Note that if @type is neither -* "help"/"?" nor a valid user creatable type, no help will be printed -* regardless of @opts. -* -* Returns: true if a help option was found and help was printed, false -* otherwise. -*/ -bool user_creatable_print_help (const char *type,QemuOpts *opts); -/** * user_creatable_del: * @id: the unique ID for the object
qom/object_interfaces.c +0 -81
114 lines not on this page · raw message
tests/check-qom-proplist.c +20 -22
66 lines not on this page · raw message
Signature · 1 line
2.29.2
Re: [PATCH v2 31/31] qom: Drop QemuOpts based interfaces
Quoted 11 lines · Kevin Wolf
user_creatable_add_opts()has only a single user left, which is a test case. Rewrite the test to useuser_creatable_add_type()instead (which is the remaining function that doesn't require a QAPI schema) and drop the QemuOpts related functions.Signed-off-by Kevin Wolf <[email protected]>--- include/qom/object_interfaces.h | 59 ------------------------ qom/object_interfaces.c | 81 --------------------------------- tests/check-qom-proplist.c | 42 ++++++++--------- 3 files changed, 20 insertions(+), 162 deletions(-)
Yay!
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Quoted 10 lines · Kevin Wolf
This series adds a QAPI type for the properties of all user creatable QOM types and finally makes the --object command line option (in all binaries) and the object-add monitor commands (in QMP and HMP) use the new ObjectOptions union.
This change improves things in more than just one way:
1. Documentation for QOM object types has always been lacking. Adding the schema, we get documentation for every property.
Quoted 8 lines
2. It prevents bugs by performing parts of the input validation (e.g. checking presence of mandatory properties) already in QAPI instead of relying on separate manual implementations in each class.
3. It provides QAPI introspection for user creatable objects.
4. Non-scalar properties are now supported everywhere because the command line parsers (including HMP) use the keyval parser now.
I've updated and posted another version of the libvirt patches which add testing that our generated props conform to the schema and also deals with the dropped 'props' wrapper:
https://listman.redhat.com/archives/libvir-list/2021-February/msg01212.html
Libvirt's test pass after it without any change, so on behalf of libvirt