All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add
@ 2021-02-24 13:52 Kevin Wolf
  2021-02-24 13:52 ` [PATCH v2 01/31] tests: Drop 'props' from object-add calls Kevin Wolf
                   ` (31 more replies)
  0 siblings, 32 replies; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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(-)

-- 
2.29.2



^ permalink raw reply	[flat|nested] 82+ messages in thread

* [PATCH v2 01/31] tests: Drop 'props' from object-add calls
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-25 22:40   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 02/31] qapi/qom: Drop deprecated 'props' from object-add Kevin Wolf
                   ` (30 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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 <kwolf@redhat.com>
---
 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(-)

diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c
index 1c7186e53c..c98b78d033 100644
--- a/tests/qtest/qmp-cmd-test.c
+++ b/tests/qtest/qmp-cmd-test.c
@@ -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);
diff --git a/tests/qtest/test-netfilter.c b/tests/qtest/test-netfilter.c
index 22927ee6ab..785b6f3226 100644
--- a/tests/qtest/test-netfilter.c
+++ b/tests/qtest/test-netfilter.c
@@ -21,11 +21,10 @@ static void add_one_netfilter(void)
                    " 'arguments': {"
                    "   'qom-type': 'filter-buffer',"
                    "   'id': 'qtest-f0',"
-                   "   'props': {"
-                   "     'netdev': 'qtest-bn0',"
-                   "     'queue': 'rx',"
-                   "     'interval': 1000"
-                   "}}}");
+                   "   'netdev': 'qtest-bn0',"
+                   "   'queue': 'rx',"
+                   "   'interval': 1000"
+                   "}}");
 
     g_assert(response);
     g_assert(!qdict_haskey(response, "error"));
@@ -49,11 +48,10 @@ static void remove_netdev_with_one_netfilter(void)
                    " 'arguments': {"
                    "   'qom-type': 'filter-buffer',"
                    "   'id': 'qtest-f0',"
-                   "   'props': {"
-                   "     'netdev': 'qtest-bn0',"
-                   "     'queue': 'rx',"
-                   "     'interval': 1000"
-                   "}}}");
+                   "   'netdev': 'qtest-bn0',"
+                   "   'queue': 'rx',"
+                   "   'interval': 1000"
+                   "}}");
 
     g_assert(response);
     g_assert(!qdict_haskey(response, "error"));
@@ -87,11 +85,10 @@ static void add_multi_netfilter(void)
                    " 'arguments': {"
                    "   'qom-type': 'filter-buffer',"
                    "   'id': 'qtest-f0',"
-                   "   'props': {"
-                   "     'netdev': 'qtest-bn0',"
-                   "     'queue': 'rx',"
-                   "     'interval': 1000"
-                   "}}}");
+                   "   'netdev': 'qtest-bn0',"
+                   "   'queue': 'rx',"
+                   "   'interval': 1000"
+                   "}}");
 
     g_assert(response);
     g_assert(!qdict_haskey(response, "error"));
@@ -101,11 +98,10 @@ static void add_multi_netfilter(void)
                    " 'arguments': {"
                    "   'qom-type': 'filter-buffer',"
                    "   'id': 'qtest-f1',"
-                   "   'props': {"
-                   "     'netdev': 'qtest-bn0',"
-                   "     'queue': 'rx',"
-                   "     'interval': 1000"
-                   "}}}");
+                   "   'netdev': 'qtest-bn0',"
+                   "   'queue': 'rx',"
+                   "   'interval': 1000"
+                   "}}");
 
     g_assert(response);
     g_assert(!qdict_haskey(response, "error"));
@@ -137,11 +133,10 @@ static void remove_netdev_with_multi_netfilter(void)
                    " 'arguments': {"
                    "   'qom-type': 'filter-buffer',"
                    "   'id': 'qtest-f0',"
-                   "   'props': {"
-                   "     'netdev': 'qtest-bn0',"
-                   "     'queue': 'rx',"
-                   "     'interval': 1000"
-                   "}}}");
+                   "   'netdev': 'qtest-bn0',"
+                   "   'queue': 'rx',"
+                   "   'interval': 1000"
+                   "}}");
 
     g_assert(response);
     g_assert(!qdict_haskey(response, "error"));
@@ -151,11 +146,10 @@ static void remove_netdev_with_multi_netfilter(void)
                    " 'arguments': {"
                    "   'qom-type': 'filter-buffer',"
                    "   'id': 'qtest-f1',"
-                   "   'props': {"
-                   "     'netdev': 'qtest-bn0',"
-                   "     'queue': 'rx',"
-                   "     'interval': 1000"
-                   "}}}");
+                   "   'netdev': 'qtest-bn0',"
+                   "   'queue': 'rx',"
+                   "   'interval': 1000"
+                   "}}");
 
     g_assert(response);
     g_assert(!qdict_haskey(response, "error"));
diff --git a/tests/qemu-iotests/087 b/tests/qemu-iotests/087
index edd43f1a28..d8e0e384cd 100755
--- a/tests/qemu-iotests/087
+++ b/tests/qemu-iotests/087
@@ -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",
diff --git a/tests/qemu-iotests/184 b/tests/qemu-iotests/184
index 513d167098..e4cbcd8634 100755
--- a/tests/qemu-iotests/184
+++ b/tests/qemu-iotests/184
@@ -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
     }
   }
 }
diff --git a/tests/qemu-iotests/218 b/tests/qemu-iotests/218
index ae7c4fb187..325d8244fb 100755
--- a/tests/qemu-iotests/218
+++ b/tests/qemu-iotests/218
@@ -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',
diff --git a/tests/qemu-iotests/235 b/tests/qemu-iotests/235
index 20d16dbf38..282b956b49 100755
--- a/tests/qemu-iotests/235
+++ b/tests/qemu-iotests/235
@@ -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',
diff --git a/tests/qemu-iotests/245 b/tests/qemu-iotests/245
index cfdeb902be..30b1d7b22d 100755
--- a/tests/qemu-iotests/245
+++ b/tests/qemu-iotests/245
@@ -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', {})
 
diff --git a/tests/qemu-iotests/258 b/tests/qemu-iotests/258
index 9a2d33ae5e..a6618208a8 100755
--- a/tests/qemu-iotests/258
+++ b/tests/qemu-iotests/258
@@ -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',
diff --git a/tests/qemu-iotests/258.out b/tests/qemu-iotests/258.out
index ce6e9ba3e5..c3a003d3e3 100644
--- a/tests/qemu-iotests/258.out
+++ b/tests/qemu-iotests/258.out
@@ -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": {}}
diff --git a/tests/qemu-iotests/295 b/tests/qemu-iotests/295
index 01a6c0b31f..270ad3999f 100755
--- a/tests/qemu-iotests/295
+++ b/tests/qemu-iotests/295
@@ -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):
diff --git a/tests/qemu-iotests/296 b/tests/qemu-iotests/296
index 0bc3c6c7d7..7c65e987a1 100755
--- a/tests/qemu-iotests/296
+++ b/tests/qemu-iotests/296
@@ -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() }
 
 ################################################################################
 
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 02/31] qapi/qom: Drop deprecated 'props' from object-add
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
  2021-02-24 13:52 ` [PATCH v2 01/31] tests: Drop 'props' from object-add calls Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-25 22:42   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 03/31] qapi/qom: Add ObjectOptions for iothread Kevin Wolf
                   ` (29 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

The option has been deprecated in QEMU 5.0, remove it.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 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(-)

diff --git a/qapi/qom.json b/qapi/qom.json
index 0b0b92944b..96c91c1faf 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -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
 
 ##
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 2fcac7861e..00b694e053 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -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)
 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
 
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst
index c8481cafbd..95f3fb2912 100644
--- a/docs/system/removed-features.rst
+++ b/docs/system/removed-features.rst
@@ -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
 -------------------------------------
 
diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
index b40ac39f30..19fd5e117f 100644
--- a/qom/qom-qmp-cmds.c
+++ b/qom/qom-qmp-cmds.c
@@ -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);
 }
 
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 03/31] qapi/qom: Add ObjectOptions for iothread
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
  2021-02-24 13:52 ` [PATCH v2 01/31] tests: Drop 'props' from object-add calls Kevin Wolf
  2021-02-24 13:52 ` [PATCH v2 02/31] qapi/qom: Drop deprecated 'props' from object-add Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-25 22:55   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 04/31] qapi/qom: Add ObjectOptions for authz-* Kevin Wolf
                   ` (28 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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 <kwolf@redhat.com>
---
 qapi/qom.json | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/qapi/qom.json b/qapi/qom.json
index 96c91c1faf..bf2ecb34be 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -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:
 #
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 04/31] qapi/qom: Add ObjectOptions for authz-*
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (2 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 03/31] qapi/qom: Add ObjectOptions for iothread Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 14:02   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 05/31] qapi/qom: Add ObjectOptions for cryptodev-* Kevin Wolf
                   ` (27 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

This adds a QAPI schema for the properties of the authz-* objects.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qapi/authz.json                      | 62 ++++++++++++++++++++++++++++
 qapi/qom.json                        | 10 +++++
 storage-daemon/qapi/qapi-schema.json |  1 +
 3 files changed, 73 insertions(+)

diff --git a/qapi/authz.json b/qapi/authz.json
index 42afe752d1..99d49aa563 100644
--- a/qapi/authz.json
+++ b/qapi/authz.json
@@ -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' } }
diff --git a/qapi/qom.json b/qapi/qom.json
index bf2ecb34be..30ed179bc1 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -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'
   } }
 
diff --git a/storage-daemon/qapi/qapi-schema.json b/storage-daemon/qapi/qapi-schema.json
index 28117c3aac..67749d1101 100644
--- a/storage-daemon/qapi/qapi-schema.json
+++ b/storage-daemon/qapi/qapi-schema.json
@@ -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' }
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 05/31] qapi/qom: Add ObjectOptions for cryptodev-*
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (3 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 04/31] qapi/qom: Add ObjectOptions for authz-* Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 14:36   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 06/31] qapi/qom: Add ObjectOptions for dbus-vmstate Kevin Wolf
                   ` (26 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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 <kwolf@redhat.com>
---
 qapi/qom.json | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/qapi/qom.json b/qapi/qom.json
index 30ed179bc1..1dbc95fb53 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -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'
   } }
 
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 06/31] qapi/qom: Add ObjectOptions for dbus-vmstate
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (4 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 05/31] qapi/qom: Add ObjectOptions for cryptodev-* Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 15:58   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 07/31] qapi/qom: Add ObjectOptions for memory-backend-* Kevin Wolf
                   ` (25 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qapi/qom.json | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/qapi/qom.json b/qapi/qom.json
index 1dbc95fb53..a6a5049707 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -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'
   } }
 
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 07/31] qapi/qom: Add ObjectOptions for memory-backend-*
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (5 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 06/31] qapi/qom: Add ObjectOptions for dbus-vmstate Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 16:23   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 08/31] qapi/qom: Add ObjectOptions for rng-*, deprecate 'opened' Kevin Wolf
                   ` (24 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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 <kwolf@redhat.com>
---
 qapi/common.json  |  20 ++++++++
 qapi/machine.json |  22 +--------
 qapi/qom.json     | 118 +++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 138 insertions(+), 22 deletions(-)

diff --git a/qapi/common.json b/qapi/common.json
index 716712d4b3..2dad4fadc3 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -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' ] }
diff --git a/qapi/machine.json b/qapi/machine.json
index 330189efe3..4322aee782 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -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:
 #
diff --git a/qapi/qom.json b/qapi/qom.json
index a6a5049707..1a869006a1 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -5,6 +5,7 @@
 # See the COPYING file in the top-level directory.
 
 { 'include': 'authz.json' }
+{ 'include': 'common.json' }
 
 ##
 # = QEMU Object Model (QOM)
@@ -272,6 +273,113 @@
             '*poll-grow': 'int',
             '*poll-shrink': 'int' } }
 
+##
+# @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)
+#
+# @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)
+#
+# @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
+#                                        machine types or older to allow
+#                                        migration with newer QEMU versions.
+#                                        (default: false generally, but true
+#                                        for machine types <= 4.0)
+#
+# Since: 2.1
+##
+{ 'struct': 'MemoryBackendProperties',
+  'data': { '*dump': 'bool',
+            '*host-nodes': ['uint16'],
+            '*merge': 'bool',
+            '*policy': 'HostMemPolicy',
+            '*prealloc': 'bool',
+            '*prealloc-threads': 'uint32',
+            '*share': 'bool',
+            '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
+#         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)
+#
+# @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',
+  'base': 'MemoryBackendProperties',
+  'data': { '*align': 'size',
+            '*discard-data': 'bool',
+            'mem-path': 'str',
+            '*pmem': 'bool',
+            '*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)
+#
+# @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' } }
+
 ##
 # @ObjectType:
 #
@@ -287,7 +395,10 @@
     'cryptodev-backend-builtin',
     'cryptodev-vhost-user',
     'dbus-vmstate',
-    'iothread'
+    'iothread',
+    'memory-backend-file',
+    'memory-backend-memfd',
+    'memory-backend-ram'
   ] }
 
 ##
@@ -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',
+      'memory-backend-ram':         'MemoryBackendProperties'
   } }
 
 ##
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 08/31] qapi/qom: Add ObjectOptions for rng-*, deprecate 'opened'
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (6 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 07/31] qapi/qom: Add ObjectOptions for memory-backend-* Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 16:54   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 09/31] qapi/qom: Add ObjectOptions for throttle-group Kevin Wolf
                   ` (23 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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 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.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qapi/qom.json              | 56 ++++++++++++++++++++++++++++++++++++--
 docs/system/deprecated.rst |  9 ++++++
 2 files changed, 63 insertions(+), 2 deletions(-)

diff --git a/qapi/qom.json b/qapi/qom.json
index 1a869006a1..73f28f9608 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -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'
   } }
 
 ##
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 00b694e053..79991c2893 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -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
 ------------------------------------
 
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 09/31] qapi/qom: Add ObjectOptions for throttle-group
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (7 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 08/31] qapi/qom: Add ObjectOptions for rng-*, deprecate 'opened' Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 17:26   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 10/31] qapi/qom: Add ObjectOptions for secret*, deprecate 'loaded' Kevin Wolf
                   ` (22 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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 <kwolf@redhat.com>
---
 qapi/block-core.json | 27 +++++++++++++++++++++++++++
 qapi/qom.json        |  7 +++++--
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/qapi/block-core.json b/qapi/block-core.json
index 9f555d5c1d..a67fa0cc59 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -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:
 #
diff --git a/qapi/qom.json b/qapi/qom.json
index 73f28f9608..449dca8ec5 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -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'
   } }
 
 ##
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 10/31] qapi/qom: Add ObjectOptions for secret*, deprecate 'loaded'
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (8 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 09/31] qapi/qom: Add ObjectOptions for throttle-group Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 19:17   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 11/31] qapi/qom: Add ObjectOptions for tls-*, " Kevin Wolf
                   ` (21 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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 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.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qapi/crypto.json           | 61 ++++++++++++++++++++++++++++++++++++++
 qapi/qom.json              |  5 ++++
 docs/system/deprecated.rst | 11 +++++++
 3 files changed, 77 insertions(+)

diff --git a/qapi/crypto.json b/qapi/crypto.json
index 2aebe6fa20..0fef3de66d 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -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' } }
diff --git a/qapi/qom.json b/qapi/qom.json
index 449dca8ec5..2668ad8369 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -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'
   } }
 
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 79991c2893..78b175cb59 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -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
 ------------------------------------
 
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 11/31] qapi/qom: Add ObjectOptions for tls-*, deprecate 'loaded'
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (9 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 10/31] qapi/qom: Add ObjectOptions for secret*, deprecate 'loaded' Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 19:33   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 12/31] qapi/qom: Add ObjectOptions for can-* Kevin Wolf
                   ` (20 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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 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.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qapi/crypto.json | 98 ++++++++++++++++++++++++++++++++++++++++++++++++
 qapi/qom.json    | 12 +++++-
 2 files changed, 108 insertions(+), 2 deletions(-)

diff --git a/qapi/crypto.json b/qapi/crypto.json
index 0fef3de66d..7116ae9a46 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -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' } }
diff --git a/qapi/qom.json b/qapi/qom.json
index 2668ad8369..f22b7aa99b 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -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'
   } }
 
 ##
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 12/31] qapi/qom: Add ObjectOptions for can-*
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (10 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 11/31] qapi/qom: Add ObjectOptions for tls-*, " Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 19:42   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 13/31] qapi/qom: Add ObjectOptions for colo-compare Kevin Wolf
                   ` (19 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qapi/qom.json | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/qapi/qom.json b/qapi/qom.json
index f22b7aa99b..4b1cd4b8dc 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -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',
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 13/31] qapi/qom: Add ObjectOptions for colo-compare
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (11 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 12/31] qapi/qom: Add ObjectOptions for can-* Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 19:46   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 14/31] qapi/qom: Add ObjectOptions for filter-* Kevin Wolf
                   ` (18 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

This adds a QAPI schema for the properties of the colo-compare object.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qapi/qom.json | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/qapi/qom.json b/qapi/qom.json
index 4b1cd4b8dc..8e4414f843 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -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',
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 14/31] qapi/qom: Add ObjectOptions for filter-*
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (12 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 13/31] qapi/qom: Add ObjectOptions for colo-compare Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 20:03   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 15/31] qapi/qom: Add ObjectOptions for pr-manager-helper Kevin Wolf
                   ` (17 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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 <kwolf@redhat.com>
---
 qapi/common.json |  20 +++++++
 qapi/net.json    |  20 -------
 qapi/qom.json    | 143 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 163 insertions(+), 20 deletions(-)

diff --git a/qapi/common.json b/qapi/common.json
index 2dad4fadc3..b87e7f9039 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -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' ] }
diff --git a/qapi/net.json b/qapi/net.json
index c31748c87f..af3f5b0fda 100644
--- a/qapi/net.json
+++ b/qapi/net.json
@@ -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:
 #
diff --git a/qapi/qom.json b/qapi/qom.json
index 8e4414f843..e3357f5123 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -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' ] }
+
+##
+# @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")
+#
+# @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")
+#
+# @insert: where to insert the filter relative to the filter given in @position.
+#          Ignored if @position is "head" or "tail". (default: behind)
+#
+# Since: 2.5
+##
+{ 'struct': 'NetfilterProperties',
+  'data': { 'netdev': 'str',
+            '*queue': 'NetFilterDirection',
+            '*status': 'str',
+            '*position': 'str',
+            '*insert': 'NetfilterInsert' } }
+
+##
+# @FilterBufferProperties:
+#
+# 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' } }
+
+##
+# @FilterDumpProperties:
+#
+# Properties for filter-dump objects.
+#
+# @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' } }
+
+##
+# @FilterMirrorProperties:
+#
+# Properties for filter-mirror objects.
+#
+# @outdev: the name of a character device backend to which all incoming packets
+#          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' } }
+
+##
+# @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
+#
+# @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' } }
+
+##
+# @FilterRewriterProperties:
+#
+# 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' } }
+
 ##
 # @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',
       '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',
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 15/31] qapi/qom: Add ObjectOptions for pr-manager-helper
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (13 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 14/31] qapi/qom: Add ObjectOptions for filter-* Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 20:04   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 16/31] qapi/qom: Add ObjectOptions for confidential-guest-support Kevin Wolf
                   ` (16 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

This adds a QAPI schema for the properties of the pr-manager-helper
object.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qapi/qom.json | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/qapi/qom.json b/qapi/qom.json
index e3357f5123..e7184122e9 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -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',
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 16/31] qapi/qom: Add ObjectOptions for confidential-guest-support
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (14 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 15/31] qapi/qom: Add ObjectOptions for pr-manager-helper Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-24 15:21   ` Dr. David Alan Gilbert
  2021-02-26 20:27   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 17/31] qapi/qom: Add ObjectOptions for input-* Kevin Wolf
                   ` (15 subsequent siblings)
  31 siblings, 2 replies; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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 <kwolf@redhat.com>
---
 qapi/qom.json | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/qapi/qom.json b/qapi/qom.json
index e7184122e9..d5f68b5c89 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -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',
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 17/31] qapi/qom: Add ObjectOptions for input-*
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (15 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 16/31] qapi/qom: Add ObjectOptions for confidential-guest-support Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 20:55   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 18/31] qapi/qom: Add ObjectOptions for x-remote-object Kevin Wolf
                   ` (14 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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 <kwolf@redhat.com>
---
 qapi/common.json | 12 ++++++++++
 qapi/qom.json    | 58 ++++++++++++++++++++++++++++++++++++++++++++++++
 qapi/ui.json     | 13 +----------
 3 files changed, 71 insertions(+), 12 deletions(-)

diff --git a/qapi/common.json b/qapi/common.json
index b87e7f9039..7c976296f0 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -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' ] }
diff --git a/qapi/qom.json b/qapi/qom.json
index d5f68b5c89..f8ff322df0 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -444,6 +444,60 @@
   'base': 'NetfilterProperties',
   'data': { '*vnet_hdr_support': 'bool' } }
 
+##
+# @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")
+#
+# @x-origin: x coordinate of the leftmost pixel on the guest screen
+#            (default: "0")
+#
+# @y-origin: y coordinate of he topmost pixel on the guest screen (default: "0")
+#
+# @width: the width of secondary screen in pixels (default: "1920")
+#
+# @height: the height of secondary screen in pixels (default: "1080")
+#
+# Since: 4.2
+##
+{ 'struct': 'InputBarrierProperties',
+  'data': { 'name': 'str',
+            '*server': 'str',
+            '*port': 'str',
+            '*x-origin': 'str',
+            '*y-origin': 'str',
+            '*width': 'str',
+            '*height': 'str' } }
+
+##
+# @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)
+#
+# @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' } }
+
 ##
 # @IothreadProperties:
 #
@@ -689,6 +743,8 @@
     'filter-redirector',
     'filter-replay',
     'filter-rewriter',
+    'input-barrier',
+    'input-linux',
     'iothread',
     'memory-backend-file',
     'memory-backend-memfd',
@@ -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',
diff --git a/qapi/ui.json b/qapi/ui.json
index d08d72b439..cc1882108b 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -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:
 #
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 18/31] qapi/qom: Add ObjectOptions for x-remote-object
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (16 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 17/31] qapi/qom: Add ObjectOptions for input-* Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 21:01   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 19/31] qapi/qom: QAPIfy object-add Kevin Wolf
                   ` (13 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

This adds a QAPI schema for the properties of the x-remote-object
object.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qapi/qom.json | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/qapi/qom.json b/qapi/qom.json
index f8ff322df0..6793342e81 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -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'
   } }
 
 ##
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 19/31] qapi/qom: QAPIfy object-add
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (17 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 18/31] qapi/qom: Add ObjectOptions for x-remote-object Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 11:30   ` Paolo Bonzini
  2021-02-26 21:18   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 20/31] qom: Make "object" QemuOptsList optional Kevin Wolf
                   ` (12 subsequent siblings)
  31 siblings, 2 replies; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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 <kwolf@redhat.com>
---
 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(-)

diff --git a/qapi/qom.json b/qapi/qom.json
index 6793342e81..e5b219df58 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -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:
diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index 07d5cc8832..9b9938b8c0 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -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
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index a3b69e2709..ac82d54063 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -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);
diff --git a/monitor/misc.c b/monitor/misc.c
index a7650ed747..42efd9e2ab 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -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",
diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
index 19fd5e117f..e577a96adf 100644
--- a/qom/qom-qmp-cmds.c
+++ b/qom/qom-qmp-cmds.c
@@ -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)
diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c
index 9021a46b3a..d8d172cc60 100644
--- a/storage-daemon/qemu-storage-daemon.c
+++ b/storage-daemon/qemu-storage-daemon.c
@@ -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",
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 20/31] qom: Make "object" QemuOptsList optional
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (18 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 19/31] qapi/qom: QAPIfy object-add Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 21:20   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 21/31] qemu-storage-daemon: Implement --object with qmp_object_add() Kevin Wolf
                   ` (11 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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 <kwolf@redhat.com>
---
 qom/object_interfaces.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 1e9ad6f08a..b9a99c8bf4 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -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;
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 21/31] qemu-storage-daemon: Implement --object with qmp_object_add()
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (19 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 20/31] qom: Make "object" QemuOptsList optional Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 21:22   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 22/31] qom: Remove user_creatable_add_dict() Kevin Wolf
                   ` (10 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

This QAPIfies --object and ensures that QMP and the command line option
behave the same.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 storage-daemon/qemu-storage-daemon.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c
index d8d172cc60..0dfb9c1448 100644
--- a/storage-daemon/qemu-storage-daemon.c
+++ b/storage-daemon/qemu-storage-daemon.c
@@ -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();
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 22/31] qom: Remove user_creatable_add_dict()
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (20 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 21/31] qemu-storage-daemon: Implement --object with qmp_object_add() Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 21:23   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 23/31] qom: Factor out user_creatable_process_cmdline() Kevin Wolf
                   ` (9 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

This function is now unused and can be removed.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 include/qom/object_interfaces.h | 18 ------------------
 qom/object_interfaces.c         | 32 --------------------------------
 2 files changed, 50 deletions(-)

diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index 9b9938b8c0..5299603f50 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -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
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index b9a99c8bf4..7d8a4b77b8 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -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;
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 23/31] qom: Factor out user_creatable_process_cmdline()
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (21 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 22/31] qom: Remove user_creatable_add_dict() Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 21:26   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 24/31] qemu-io: Use user_creatable_process_cmdline() for --object Kevin Wolf
                   ` (8 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

The 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.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 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(-)

diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index 5299603f50..1e6c51b541 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -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
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 7d8a4b77b8..efb48249d5 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -2,10 +2,13 @@
 
 #include "qemu/cutils.h"
 #include "qapi/error.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/qmp/qjson.h"
 #include "qapi/qobject-input-visitor.h"
+#include "qapi/qobject-output-visitor.h"
 #include "qom/object_interfaces.h"
 #include "qemu/help_option.h"
 #include "qemu/module.h"
@@ -104,6 +107,29 @@ out:
     return obj;
 }
 
+void user_creatable_add_qapi(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);
+}
+
 Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)
 {
     Visitor *v;
@@ -247,7 +273,7 @@ bool user_creatable_print_help(const char *type, QemuOpts *opts)
     return false;
 }
 
-void user_creatable_print_help_from_qdict(QDict *args)
+static void user_creatable_print_help_from_qdict(QDict *args)
 {
     const char *type = qdict_get_try_str(args, "qom-type");
 
@@ -256,6 +282,28 @@ void user_creatable_print_help_from_qdict(QDict *args)
     }
 }
 
+void user_creatable_process_cmdline(const char *optarg)
+{
+    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);
+
+    user_creatable_add_qapi(options, &error_fatal);
+    qapi_free_ObjectOptions(options);
+}
+
 bool user_creatable_del(const char *id, Error **errp)
 {
     QemuOptsList *opts_list;
diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
index e577a96adf..2d6f41ecc7 100644
--- a/qom/qom-qmp-cmds.c
+++ b/qom/qom-qmp-cmds.c
@@ -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)
diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c
index 0dfb9c1448..32b59878a7 100644
--- a/storage-daemon/qemu-storage-daemon.c
+++ b/storage-daemon/qemu-storage-daemon.c
@@ -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();
         }
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 24/31] qemu-io: Use user_creatable_process_cmdline() for --object
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (22 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 23/31] qom: Factor out user_creatable_process_cmdline() Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 21:27   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 25/31] qemu-img: " Kevin Wolf
                   ` (7 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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 <kwolf@redhat.com>
---
 qemu-io.c | 33 +++------------------------------
 1 file changed, 3 insertions(+), 30 deletions(-)

diff --git a/qemu-io.c b/qemu-io.c
index ac88d8bd40..bf902302e9 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -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);
     }
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 25/31] qemu-img: Use user_creatable_process_cmdline() for --object
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (23 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 24/31] qemu-io: Use user_creatable_process_cmdline() for --object Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 21:56   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 26/31] qemu-nbd: " Kevin Wolf
                   ` (6 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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 <kwolf@redhat.com>
---
 qemu-img.c | 239 ++++++++---------------------------------------------
 1 file changed, 33 insertions(+), 206 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index e2952fe955..ebf8661e2a 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -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);
 
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 26/31] qemu-nbd: Use user_creatable_process_cmdline() for --object
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (24 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 25/31] qemu-img: " Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 22:18   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 27/31] qom: Add user_creatable_add_from_str() Kevin Wolf
                   ` (5 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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 <kwolf@redhat.com>
---
 qemu-nbd.c | 34 +++-------------------------------
 1 file changed, 3 insertions(+), 31 deletions(-)

diff --git a/qemu-nbd.c b/qemu-nbd.c
index b1b9430a8f..93ef4e288f 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -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);
     }
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 27/31] qom: Add user_creatable_add_from_str()
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (25 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 26/31] qemu-nbd: " Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 22:21   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 28/31] hmp: QAPIfy object_add Kevin Wolf
                   ` (4 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

This is a version of user_creatable_process_cmdline() with an Error
parameter that never calls exit() and is therefore usable in HMP.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 include/qom/object_interfaces.h | 16 ++++++++++++++++
 qom/object_interfaces.c         | 29 ++++++++++++++++++++++++-----
 2 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index 1e6c51b541..07511e6cff 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -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
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index efb48249d5..54f0dadfea 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -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)
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 28/31] hmp: QAPIfy object_add
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (26 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 27/31] qom: Add user_creatable_add_from_str() Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-24 15:31   ` Dr. David Alan Gilbert
  2021-02-26 22:23   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 29/31] qom: Add user_creatable_parse_str() Kevin Wolf
                   ` (3 subsequent siblings)
  31 siblings, 2 replies; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

This 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().

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 monitor/hmp-cmds.c      | 17 ++---------------
 qom/object_interfaces.c | 11 ++++++-----
 hmp-commands.hx         |  2 +-
 3 files changed, 9 insertions(+), 21 deletions(-)

diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 3c88a4faef..652cf9ff21 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -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)
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 54f0dadfea..c4982dd7a0 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -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);
diff --git a/hmp-commands.hx b/hmp-commands.hx
index d4001f9c5d..6f5d9ce2fb 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -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,
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 29/31] qom: Add user_creatable_parse_str()
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (27 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 28/31] hmp: QAPIfy object_add Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 22:24   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 30/31] vl: QAPIfy -object Kevin Wolf
                   ` (2 subsequent siblings)
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 include/qom/object_interfaces.h | 15 +++++++++++++++
 qom/object_interfaces.c         | 20 ++++++++++++++------
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index 07511e6cff..fb32330901 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -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
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index c4982dd7a0..1c29f45b41 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -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;
 }
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 30/31] vl: QAPIfy -object
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (28 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 29/31] qom: Add user_creatable_parse_str() Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 22:40   ` Eric Blake
  2021-02-24 13:52 ` [PATCH v2 31/31] qom: Drop QemuOpts based interfaces Kevin Wolf
  2021-02-24 16:01 ` [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Peter Krempa
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

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.

-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.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 softmmu/vl.c | 109 +++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 84 insertions(+), 25 deletions(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index b219ce1f35..205c254542 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -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);
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 31/31] qom: Drop QemuOpts based interfaces
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (29 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 30/31] vl: QAPIfy -object Kevin Wolf
@ 2021-02-24 13:52 ` Kevin Wolf
  2021-02-26 22:42   ` Eric Blake
  2021-02-24 16:01 ` [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Peter Krempa
  31 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

user_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.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 include/qom/object_interfaces.h | 59 ------------------------
 qom/object_interfaces.c         | 81 ---------------------------------
 tests/check-qom-proplist.c      | 42 ++++++++---------
 3 files changed, 20 insertions(+), 162 deletions(-)

diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index fb32330901..ac6c33ceac 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -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
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 1c29f45b41..25cc54fcd7 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -10,12 +10,9 @@
 #include "qapi/qobject-input-visitor.h"
 #include "qapi/qobject-output-visitor.h"
 #include "qom/object_interfaces.h"
-#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"
 
 bool user_creatable_complete(UserCreatable *uc, Error **errp)
 {
@@ -131,60 +128,6 @@ void user_creatable_add_qapi(ObjectOptions *options, Error **errp)
     visit_free(v);
 }
 
-Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)
-{
-    Visitor *v;
-    QDict *pdict;
-    Object *obj;
-    const char *id = qemu_opts_id(opts);
-    char *type = qemu_opt_get_del(opts, "qom-type");
-
-    if (!type) {
-        error_setg(errp, QERR_MISSING_PARAMETER, "qom-type");
-        return NULL;
-    }
-    if (!id) {
-        error_setg(errp, QERR_MISSING_PARAMETER, "id");
-        qemu_opt_set(opts, "qom-type", type, &error_abort);
-        g_free(type);
-        return NULL;
-    }
-
-    qemu_opts_set_id(opts, NULL);
-    pdict = qemu_opts_to_qdict(opts, NULL);
-
-    v = opts_visitor_new(opts);
-    obj = user_creatable_add_type(type, id, pdict, v, errp);
-    visit_free(v);
-
-    qemu_opts_set_id(opts, (char *) id);
-    qemu_opt_set(opts, "qom-type", type, &error_abort);
-    g_free(type);
-    qobject_unref(pdict);
-    return obj;
-}
-
-
-int user_creatable_add_opts_foreach(void *opaque, QemuOpts *opts, Error **errp)
-{
-    bool (*type_opt_predicate)(const char *, QemuOpts *) = opaque;
-    Object *obj = NULL;
-    const char *type;
-
-    type = qemu_opt_get(opts, "qom-type");
-    if (type && type_opt_predicate &&
-        !type_opt_predicate(type, opts)) {
-        return 0;
-    }
-
-    obj = user_creatable_add_opts(opts, errp);
-    if (!obj) {
-        return -1;
-    }
-    object_unref(obj);
-    return 0;
-}
-
 char *object_property_help(const char *name, const char *type,
                            QObject *defval, const char *description)
 {
@@ -260,20 +203,6 @@ static bool user_creatable_print_type_properites(const char *type)
     return true;
 }
 
-bool user_creatable_print_help(const char *type, QemuOpts *opts)
-{
-    if (is_help_option(type)) {
-        user_creatable_print_types();
-        return true;
-    }
-
-    if (qemu_opt_has_help_opt(opts)) {
-        return user_creatable_print_type_properites(type);
-    }
-
-    return false;
-}
-
 static void user_creatable_print_help_from_qdict(QDict *args)
 {
     const char *type = qdict_get_try_str(args, "qom-type");
@@ -334,7 +263,6 @@ void user_creatable_process_cmdline(const char *optarg)
 
 bool user_creatable_del(const char *id, Error **errp)
 {
-    QemuOptsList *opts_list;
     Object *container;
     Object *obj;
 
@@ -350,15 +278,6 @@ bool user_creatable_del(const char *id, Error **errp)
         return false;
     }
 
-    /*
-     * if object was defined on the command-line, remove its corresponding
-     * option group entry
-     */
-    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;
 }
diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c
index 1b76581980..3bf208ba8b 100644
--- a/tests/check-qom-proplist.c
+++ b/tests/check-qom-proplist.c
@@ -21,6 +21,8 @@
 #include "qemu/osdep.h"
 
 #include "qapi/error.h"
+#include "qapi/qmp/qdict.h"
+#include "qapi/qobject-input-visitor.h"
 #include "qom/object.h"
 #include "qemu/module.h"
 #include "qemu/option.h"
@@ -400,20 +402,30 @@ static void test_dummy_createlist(void)
 
 static void test_dummy_createcmdl(void)
 {
-    QemuOpts *opts;
     DummyObject *dobj;
-    Error *err = NULL;
+    QDict *args;
+    Visitor *v;
+    g_autofree const char *qom_type = NULL;
+    g_autofree const char *id = NULL;
     const char *params = TYPE_DUMMY \
                          ",id=dev0," \
                          "bv=yes,sv=Hiss hiss hiss,av=platypus";
 
-    qemu_add_opts(&qemu_object_opts);
-    opts = qemu_opts_parse(&qemu_object_opts, params, true, &err);
-    g_assert(err == NULL);
-    g_assert(opts);
+    args = keyval_parse(params, "qom-type", NULL, &error_abort);
+
+    qom_type = g_strdup(qdict_get_str(args, "qom-type"));
+    qdict_del(args, "qom-type");
+    g_assert(!strcmp(qom_type, TYPE_DUMMY));
+
+    id = g_strdup(qdict_get_str(args, "id"));
+    qdict_del(args, "id");
+    g_assert(!strcmp(id, "dev0"));
+
+    v = qobject_input_visitor_new_keyval(QOBJECT(args));
+    dobj = DUMMY_OBJECT(user_creatable_add_type(TYPE_DUMMY, id, args, v,
+                                                &error_abort));
+    visit_free(v);
 
-    dobj = DUMMY_OBJECT(user_creatable_add_opts(opts, &err));
-    g_assert(err == NULL);
     g_assert(dobj);
     g_assert_cmpstr(dobj->sv, ==, "Hiss hiss hiss");
     g_assert(dobj->bv == true);
@@ -422,20 +434,6 @@ static void test_dummy_createcmdl(void)
     user_creatable_del("dev0", &error_abort);
 
     object_unref(OBJECT(dobj));
-
-    /*
-     * cmdline-parsing via qemu_opts_parse() results in a QemuOpts entry
-     * corresponding to the Object's ID to be added to the QemuOptsList
-     * for objects. To avoid having this entry conflict with future
-     * Objects using the same ID (which can happen in cases where
-     * qemu_opts_parse() is used to parse the object params, such as
-     * with hmp_object_add() at the time of this comment), we need to
-     * check for this in user_creatable_del() and remove the QemuOpts if
-     * it is present.
-     *
-     * The below check ensures this works as expected.
-     */
-    g_assert_null(qemu_opts_find(&qemu_object_opts, "dev0"));
 }
 
 static void test_dummy_badenum(void)
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 16/31] qapi/qom: Add ObjectOptions for confidential-guest-support
  2021-02-24 13:52 ` [PATCH v2 16/31] qapi/qom: Add ObjectOptions for confidential-guest-support Kevin Wolf
@ 2021-02-24 15:21   ` Dr. David Alan Gilbert
  2021-02-24 16:25     ` Kevin Wolf
  2021-02-26 20:27   ` Eric Blake
  1 sibling, 1 reply; 82+ messages in thread
From: Dr. David Alan Gilbert @ 2021-02-24 15:21 UTC (permalink / raw)
  To: Kevin Wolf
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, armbru, jasowang, qemu-devel, mreitz, kraxel,
	pbonzini

* Kevin Wolf (kwolf@redhat.com) 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 <kwolf@redhat.com>
> ---
>  qapi/qom.json | 37 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
> 
> diff --git a/qapi/qom.json b/qapi/qom.json
> index e7184122e9..d5f68b5c89 100644
> --- a/qapi/qom.json
> +++ b/qapi/qom.json
> @@ -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',

If pef-guest is conditional on PSERIES< shouldn't this be dependent on
s390?

Dave

>      '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',
> -- 
> 2.29.2
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 28/31] hmp: QAPIfy object_add
  2021-02-24 13:52 ` [PATCH v2 28/31] hmp: QAPIfy object_add Kevin Wolf
@ 2021-02-24 15:31   ` Dr. David Alan Gilbert
  2021-02-26 22:23   ` Eric Blake
  1 sibling, 0 replies; 82+ messages in thread
From: Dr. David Alan Gilbert @ 2021-02-24 15:31 UTC (permalink / raw)
  To: Kevin Wolf
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, armbru, jasowang, qemu-devel, mreitz, kraxel,
	pbonzini

* Kevin Wolf (kwolf@redhat.com) wrote:
> This 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().
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  monitor/hmp-cmds.c      | 17 ++---------------
>  qom/object_interfaces.c | 11 ++++++-----
>  hmp-commands.hx         |  2 +-
>  3 files changed, 9 insertions(+), 21 deletions(-)
> 
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index 3c88a4faef..652cf9ff21 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -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)
> diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
> index 54f0dadfea..c4982dd7a0 100644
> --- a/qom/object_interfaces.c
> +++ b/qom/object_interfaces.c
> @@ -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);
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index d4001f9c5d..6f5d9ce2fb 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -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,
> -- 
> 2.29.2
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add
  2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
                   ` (30 preceding siblings ...)
  2021-02-24 13:52 ` [PATCH v2 31/31] qom: Drop QemuOpts based interfaces Kevin Wolf
@ 2021-02-24 16:01 ` Peter Krempa
  31 siblings, 0 replies; 82+ messages in thread
From: Peter Krempa @ 2021-02-24 16:01 UTC (permalink / raw)
  To: Kevin Wolf
  Cc: lvivier, thuth, ehabkost, qemu-block, libvir-list, jasowang,
	qemu-devel, mreitz, kraxel, pbonzini, dgilbert

On Wed, Feb 24, 2021 at 14:52:24 +0100, Kevin Wolf wrote:
> 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.

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

ACKed-by: Peter Krempa <pkrempa@redhat.com>



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 16/31] qapi/qom: Add ObjectOptions for confidential-guest-support
  2021-02-24 15:21   ` Dr. David Alan Gilbert
@ 2021-02-24 16:25     ` Kevin Wolf
  0 siblings, 0 replies; 82+ messages in thread
From: Kevin Wolf @ 2021-02-24 16:25 UTC (permalink / raw)
  To: Dr. David Alan Gilbert
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, armbru, jasowang, qemu-devel, mreitz, kraxel,
	pbonzini

Am 24.02.2021 um 16:21 hat Dr. David Alan Gilbert geschrieben:
> * Kevin Wolf (kwolf@redhat.com) 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 <kwolf@redhat.com>
> > ---
> >  qapi/qom.json | 37 +++++++++++++++++++++++++++++++++++++
> >  1 file changed, 37 insertions(+)
> > 
> > diff --git a/qapi/qom.json b/qapi/qom.json
> > index e7184122e9..d5f68b5c89 100644
> > --- a/qapi/qom.json
> > +++ b/qapi/qom.json
> > @@ -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',
> 
> 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



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 01/31] tests: Drop 'props' from object-add calls
  2021-02-24 13:52 ` [PATCH v2 01/31] tests: Drop 'props' from object-add calls Kevin Wolf
@ 2021-02-25 22:40   ` Eric Blake
  0 siblings, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-25 22:40 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> 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 <kwolf@redhat.com>
> ---

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 02/31] qapi/qom: Drop deprecated 'props' from object-add
  2021-02-24 13:52 ` [PATCH v2 02/31] qapi/qom: Drop deprecated 'props' from object-add Kevin Wolf
@ 2021-02-25 22:42   ` Eric Blake
  0 siblings, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-25 22:42 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> The option has been deprecated in QEMU 5.0, remove it.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  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(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 03/31] qapi/qom: Add ObjectOptions for iothread
  2021-02-24 13:52 ` [PATCH v2 03/31] qapi/qom: Add ObjectOptions for iothread Kevin Wolf
@ 2021-02-25 22:55   ` Eric Blake
  2021-03-02 17:27     ` Kevin Wolf
  0 siblings, 1 reply; 82+ messages in thread
From: Eric Blake @ 2021-02-25 22:55 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> 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 <kwolf@redhat.com>
> ---
>  qapi/qom.json | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 53 insertions(+)
> 
> diff --git a/qapi/qom.json b/qapi/qom.json
> index 96c91c1faf..bf2ecb34be 100644
> --- a/qapi/qom.json
> +++ b/qapi/qom.json
> @@ -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)

Matches PollParamInfo declarations in iothread.c.

> +#
> +# 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).

> +##
> +{ '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.

> +
> +##
> +# @ObjectType:
> +#
> +# Since: 6.0
> +##
> +{ 'enum': 'ObjectType',
> +  'data': [
> +    'iothread'
> +  ] }

Will be fun to watch this grow over the series.

> +
> +##
> +# @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:
>  #
> 


Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 19/31] qapi/qom: QAPIfy object-add
  2021-02-24 13:52 ` [PATCH v2 19/31] qapi/qom: QAPIfy object-add Kevin Wolf
@ 2021-02-26 11:30   ` Paolo Bonzini
  2021-03-01 11:54     ` Kevin Wolf
  2021-02-26 21:18   ` Eric Blake
  1 sibling, 1 reply; 82+ messages in thread
From: Paolo Bonzini @ 2021-02-26 11:30 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, dgilbert

On 24/02/21 14:52, Kevin Wolf wrote:
> +    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



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 04/31] qapi/qom: Add ObjectOptions for authz-*
  2021-02-24 13:52 ` [PATCH v2 04/31] qapi/qom: Add ObjectOptions for authz-* Kevin Wolf
@ 2021-02-26 14:02   ` Eric Blake
  0 siblings, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-26 14:02 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> This adds a QAPI schema for the properties of the authz-* objects.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  qapi/authz.json                      | 62 ++++++++++++++++++++++++++++
>  qapi/qom.json                        | 10 +++++
>  storage-daemon/qapi/qapi-schema.json |  1 +
>  3 files changed, 73 insertions(+)
> 
> diff --git a/qapi/authz.json b/qapi/authz.json
> index 42afe752d1..99d49aa563 100644
> --- a/qapi/authz.json
> +++ b/qapi/authz.json
> @@ -59,3 +59,65 @@
>  ##
>  { 'struct': 'QAuthZListRuleListHack',
>    'data': { 'unused': ['QAuthZListRule'] } }

This hack is no longer necessary...

> +
> +##
> +# @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'] } }

...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().

> +
> +##
> +# @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' } }

Matches authz/listfile.c:qauthz_list_file_class_init().

> +
> +##
> +# @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().

> +
> +##
> +# @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' } }

Matches authz/simple.c:qauthz_simple_class_init().

> diff --git a/qapi/qom.json b/qapi/qom.json
> index bf2ecb34be..30ed179bc1 100644
> --- a/qapi/qom.json
> +++ b/qapi/qom.json
> @@ -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'
>    } }
>  
> diff --git a/storage-daemon/qapi/qapi-schema.json b/storage-daemon/qapi/qapi-schema.json
> index 28117c3aac..67749d1101 100644
> --- a/storage-daemon/qapi/qapi-schema.json
> +++ b/storage-daemon/qapi/qapi-schema.json
> @@ -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,
Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 05/31] qapi/qom: Add ObjectOptions for cryptodev-*
  2021-02-24 13:52 ` [PATCH v2 05/31] qapi/qom: Add ObjectOptions for cryptodev-* Kevin Wolf
@ 2021-02-26 14:36   ` Eric Blake
  0 siblings, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-26 14:36 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> 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 <kwolf@redhat.com>
> ---
>  qapi/qom.json | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/qapi/qom.json b/qapi/qom.json
> index 30ed179bc1..1dbc95fb53 100644
> --- a/qapi/qom.json
> +++ b/qapi/qom.json
> @@ -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' } }

Matches backend/cryptodev.c:cryptodev_backend_class_init() and
backend/cryptodev-builtin.c:cryptodev_builtin_class_init().

> +
> +##
> +# @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/ ?

> +#           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().

> +
>  ##
>  # @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'
>    } }
>  
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 06/31] qapi/qom: Add ObjectOptions for dbus-vmstate
  2021-02-24 13:52 ` [PATCH v2 06/31] qapi/qom: Add ObjectOptions for dbus-vmstate Kevin Wolf
@ 2021-02-26 15:58   ` Eric Blake
  2021-03-02 17:36     ` Kevin Wolf
  0 siblings, 1 reply; 82+ messages in thread
From: Eric Blake @ 2021-02-26 15:58 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> 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?

> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  qapi/qom.json | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/qapi/qom.json b/qapi/qom.json
> index 1dbc95fb53..a6a5049707 100644
> --- a/qapi/qom.json
> +++ b/qapi/qom.json
> @@ -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' } }

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,

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 07/31] qapi/qom: Add ObjectOptions for memory-backend-*
  2021-02-24 13:52 ` [PATCH v2 07/31] qapi/qom: Add ObjectOptions for memory-backend-* Kevin Wolf
@ 2021-02-26 16:23   ` Eric Blake
  2021-03-02 18:11     ` Kevin Wolf
  0 siblings, 1 reply; 82+ messages in thread
From: Eric Blake @ 2021-02-26 16:23 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> 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 <kwolf@redhat.com>
> ---
>  qapi/common.json  |  20 ++++++++
>  qapi/machine.json |  22 +--------
>  qapi/qom.json     | 118 +++++++++++++++++++++++++++++++++++++++++++++-
>  3 files changed, 138 insertions(+), 22 deletions(-)
> 

> +++ b/qapi/qom.json

> +##
> +# @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");

> +#
> +# @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.

> +#
> +# @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
> +#                                        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?

> +#
> +# Since: 2.1
> +##
> +{ 'struct': 'MemoryBackendProperties',
> +  'data': { '*dump': 'bool',
> +            '*host-nodes': ['uint16'],
> +            '*merge': 'bool',
> +            '*policy': 'HostMemPolicy',
> +            '*prealloc': 'bool',
> +            '*prealloc-threads': 'uint32',
> +            '*share': 'bool',
> +            '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...

> +#         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.

> +#
> +# @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',
> +  '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)' },

> +            '*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)
> +#
> +# @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,...

> +
>  ##
>  # @ObjectType:
>  #
> @@ -287,7 +395,10 @@
>      'cryptodev-backend-builtin',
>      'cryptodev-vhost-user',
>      'dbus-vmstate',
> -    'iothread'
> +    'iothread',
> +    'memory-backend-file',
> +    'memory-backend-memfd',
> +    'memory-backend-ram'
>    ] }
>  
>  ##
> @@ -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.

> +      'memory-backend-ram':         'MemoryBackendProperties'
>    } }
>  
>  ##
> 

Because of my questions on conditional compilation, I'm not comfortable
with R-b yet.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 08/31] qapi/qom: Add ObjectOptions for rng-*, deprecate 'opened'
  2021-02-24 13:52 ` [PATCH v2 08/31] qapi/qom: Add ObjectOptions for rng-*, deprecate 'opened' Kevin Wolf
@ 2021-02-26 16:54   ` Eric Blake
  0 siblings, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-26 16:54 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> 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 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.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  qapi/qom.json              | 56 ++++++++++++++++++++++++++++++++++++--
>  docs/system/deprecated.rst |  9 ++++++
>  2 files changed, 63 insertions(+), 2 deletions(-)
> 
> diff --git a/qapi/qom.json b/qapi/qom.json
> index 1a869006a1..73f28f9608 100644
> --- a/qapi/qom.json
> +++ b/qapi/qom.json
> @@ -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'] } } }

Matches backends/rng.c:rng_backend_class_init(), and I concur with the
deprecation.

> +
> +##
> +# @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' } }

Matches backends/rng-egd.c:rng_egd_class_init().

> +
> +##
> +# @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' } }

Matches backends/rng-random.c:rng_random_class_init().

> +
>  ##
>  # @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'
>    } }
>  
>  ##
> diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
> index 00b694e053..79991c2893 100644
> --- a/docs/system/deprecated.rst
> +++ b/docs/system/deprecated.rst
> @@ -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.

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 09/31] qapi/qom: Add ObjectOptions for throttle-group
  2021-02-24 13:52 ` [PATCH v2 09/31] qapi/qom: Add ObjectOptions for throttle-group Kevin Wolf
@ 2021-02-26 17:26   ` Eric Blake
  2021-03-02 18:18     ` Kevin Wolf
  0 siblings, 1 reply; 82+ messages in thread
From: Eric Blake @ 2021-02-26 17:26 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> 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 <kwolf@redhat.com>
> ---
>  qapi/block-core.json | 27 +++++++++++++++++++++++++++
>  qapi/qom.json        |  7 +++++--
>  2 files changed, 32 insertions(+), 2 deletions(-)
> 
> diff --git a/qapi/block-core.json b/qapi/block-core.json
> index 9f555d5c1d..a67fa0cc59 100644
> --- a/qapi/block-core.json
> +++ b/qapi/block-core.json
> @@ -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.

> +#
> +# 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.

> +#
> +# 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:
>  #
> diff --git a/qapi/qom.json b/qapi/qom.json
> index 73f28f9608..449dca8ec5 100644
> --- a/qapi/qom.json
> +++ b/qapi/qom.json
> @@ -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'
>    } }
>  
>  ##
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 10/31] qapi/qom: Add ObjectOptions for secret*, deprecate 'loaded'
  2021-02-24 13:52 ` [PATCH v2 10/31] qapi/qom: Add ObjectOptions for secret*, deprecate 'loaded' Kevin Wolf
@ 2021-02-26 19:17   ` Eric Blake
  2021-03-02 18:23     ` Kevin Wolf
  0 siblings, 1 reply; 82+ messages in thread
From: Eric Blake @ 2021-02-26 19:17 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> 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 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.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  qapi/crypto.json           | 61 ++++++++++++++++++++++++++++++++++++++
>  qapi/qom.json              |  5 ++++
>  docs/system/deprecated.rst | 11 +++++++
>  3 files changed, 77 insertions(+)
> 
> diff --git a/qapi/crypto.json b/qapi/crypto.json
> index 2aebe6fa20..0fef3de66d 100644
> --- a/qapi/crypto.json
> +++ b/qapi/crypto.json
> @@ -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' } }

Matches crypto/secret_common.c:qcrypto_secret_class_init(), and I concur
with the deprecation.

> +
> +##
> +# @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' } }

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)

> +
> +##
> +# @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().

> diff --git a/qapi/qom.json b/qapi/qom.json
> index 449dca8ec5..2668ad8369 100644
> --- a/qapi/qom.json
> +++ b/qapi/qom.json
> @@ -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',

What is stopping us from naming this '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'
>    } }
>  
> diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
> index 79991c2893..78b175cb59 100644
> --- a/docs/system/deprecated.rst
> +++ b/docs/system/deprecated.rst
> @@ -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.

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,

Reviewed-by: Eric Blake <eblake@redhat.com>


-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 11/31] qapi/qom: Add ObjectOptions for tls-*, deprecate 'loaded'
  2021-02-24 13:52 ` [PATCH v2 11/31] qapi/qom: Add ObjectOptions for tls-*, " Kevin Wolf
@ 2021-02-26 19:33   ` Eric Blake
  2021-03-02 18:27     ` Kevin Wolf
  0 siblings, 1 reply; 82+ messages in thread
From: Eric Blake @ 2021-02-26 19:33 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> 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 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.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  qapi/crypto.json | 98 ++++++++++++++++++++++++++++++++++++++++++++++++
>  qapi/qom.json    | 12 +++++-
>  2 files changed, 108 insertions(+), 2 deletions(-)
> 
> diff --git a/qapi/crypto.json b/qapi/crypto.json
> index 0fef3de66d..7116ae9a46 100644
> --- a/qapi/crypto.json
> +++ b/qapi/crypto.json
> @@ -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' } }

Matches crypto/tlscreds.c:qcrypto_tls_creds_class_init().

> +
> +##
> +# @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'] } } }

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().

> +
> +##
> +# @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' } }

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...)

> +
> +##
> +# @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' } }

This matches crypto/tlscredsx509.c:qcrypto_tls_creds_x509_class_init().

> diff --git a/qapi/qom.json b/qapi/qom.json
> index 2668ad8369..f22b7aa99b 100644
> --- a/qapi/qom.json
> +++ b/qapi/qom.json
> @@ -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().

>    ] }
>  
>  ##
> @@ -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'

Reviewed-by: Eric Blake <eblake@redhat.com>


-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 12/31] qapi/qom: Add ObjectOptions for can-*
  2021-02-24 13:52 ` [PATCH v2 12/31] qapi/qom: Add ObjectOptions for can-* Kevin Wolf
@ 2021-02-26 19:42   ` Eric Blake
  2021-03-02 18:32     ` Kevin Wolf
  0 siblings, 1 reply; 82+ messages in thread
From: Eric Blake @ 2021-02-26 19:42 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> 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.

> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  qapi/qom.json | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/qapi/qom.json b/qapi/qom.json
> index f22b7aa99b..4b1cd4b8dc 100644
> --- a/qapi/qom.json
> +++ b/qapi/qom.json
> @@ -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' } }
> +

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").

>  ##
>  # @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',
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 13/31] qapi/qom: Add ObjectOptions for colo-compare
  2021-02-24 13:52 ` [PATCH v2 13/31] qapi/qom: Add ObjectOptions for colo-compare Kevin Wolf
@ 2021-02-26 19:46   ` Eric Blake
  0 siblings, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-26 19:46 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> This adds a QAPI schema for the properties of the colo-compare object.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  qapi/qom.json | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 49 insertions(+)
> 
> diff --git a/qapi/qom.json b/qapi/qom.json
> index 4b1cd4b8dc..8e4414f843 100644
> --- a/qapi/qom.json
> +++ b/qapi/qom.json
> @@ -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)
> +#

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.

> +# @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' } }

Matches net/colo-compare.c:colo_compare_init().

> +
>  ##
>  # @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',

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 14/31] qapi/qom: Add ObjectOptions for filter-*
  2021-02-24 13:52 ` [PATCH v2 14/31] qapi/qom: Add ObjectOptions for filter-* Kevin Wolf
@ 2021-02-26 20:03   ` Eric Blake
  0 siblings, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-26 20:03 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> 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 <kwolf@redhat.com>
> ---
>  qapi/common.json |  20 +++++++
>  qapi/net.json    |  20 -------
>  qapi/qom.json    | 143 +++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 163 insertions(+), 20 deletions(-)
> 

> +++ b/qapi/qom.json
> @@ -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' ] }
> +
> +##
> +# @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.

> +#
> +# @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.

> +# @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...

> +#
> +# Since: 2.5
> +##
> +{ 'struct': 'NetfilterProperties',
> +  'data': { 'netdev': 'str',
> +            '*queue': 'NetFilterDirection',
> +            '*status': 'str',
> +            '*position': 'str',
> +            '*insert': 'NetfilterInsert' } }
> +
> +##
> +# @FilterBufferProperties:
> +#
> +# 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().

> +
> +##
> +# @FilterDumpProperties:
> +#
> +# Properties for filter-dump objects.
> +#
> +# @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().

> +
> +##
> +# @FilterMirrorProperties:
> +#
> +# Properties for filter-mirror objects.
> +#
> +# @outdev: the name of a character device backend to which all incoming packets
> +#          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?

> +
> +##
> +# @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
> +#
> +# @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().

> +
> +##
> +# @FilterRewriterProperties:
> +#
> +# 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().

>  ##
>  # @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',
>        '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',
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 15/31] qapi/qom: Add ObjectOptions for pr-manager-helper
  2021-02-24 13:52 ` [PATCH v2 15/31] qapi/qom: Add ObjectOptions for pr-manager-helper Kevin Wolf
@ 2021-02-26 20:04   ` Eric Blake
  0 siblings, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-26 20:04 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> This adds a QAPI schema for the properties of the pr-manager-helper
> object.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  qapi/qom.json | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/qapi/qom.json b/qapi/qom.json
> index e3357f5123..e7184122e9 100644
> --- a/qapi/qom.json
> +++ b/qapi/qom.json
> @@ -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' } }
> +

Matches scsi/pr-manager-helper.c:pr_manager_helper_class_init().

>  ##
>  # @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',
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 16/31] qapi/qom: Add ObjectOptions for confidential-guest-support
  2021-02-24 13:52 ` [PATCH v2 16/31] qapi/qom: Add ObjectOptions for confidential-guest-support Kevin Wolf
  2021-02-24 15:21   ` Dr. David Alan Gilbert
@ 2021-02-26 20:27   ` Eric Blake
  1 sibling, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-26 20:27 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf 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 <kwolf@redhat.com>
> ---
>  qapi/qom.json | 37 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
> 
> diff --git a/qapi/qom.json b/qapi/qom.json
> index e7184122e9..d5f68b5c89 100644
> --- a/qapi/qom.json
> +++ b/qapi/qom.json
> @@ -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)

Matches target/i386/sev.c:sev_guest_class_init()...

> +#
> +# @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().

> +#
> +# 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',
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 17/31] qapi/qom: Add ObjectOptions for input-*
  2021-02-24 13:52 ` [PATCH v2 17/31] qapi/qom: Add ObjectOptions for input-* Kevin Wolf
@ 2021-02-26 20:55   ` Eric Blake
  2021-03-02 18:42     ` Kevin Wolf
  0 siblings, 1 reply; 82+ messages in thread
From: Eric Blake @ 2021-02-26 20:55 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> 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 <kwolf@redhat.com>
> ---
>  qapi/common.json | 12 ++++++++++
>  qapi/qom.json    | 58 ++++++++++++++++++++++++++++++++++++++++++++++++
>  qapi/ui.json     | 13 +----------
>  3 files changed, 71 insertions(+), 12 deletions(-)
> 

> +##
> +# @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...

> +#
> +# @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?

> +#
> +# @y-origin: y coordinate of he topmost pixel on the guest screen (default: "0")

"the", long line

> +#
> +# @width: the width of secondary screen in pixels (default: "1920")
> +#
> +# @height: the height of secondary screen in pixels (default: "1080")
> +#
> +# 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().

> +
> +##
> +# @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'.

> +#
> +# @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.

> +
>  ##
>  # @IothreadProperties:
>  #
> @@ -689,6 +743,8 @@
>      'filter-redirector',
>      'filter-replay',
>      'filter-rewriter',
> +    'input-barrier',
> +    'input-linux',
>      'iothread',
>      'memory-backend-file',
>      'memory-backend-memfd',
> @@ -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',

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 18/31] qapi/qom: Add ObjectOptions for x-remote-object
  2021-02-24 13:52 ` [PATCH v2 18/31] qapi/qom: Add ObjectOptions for x-remote-object Kevin Wolf
@ 2021-02-26 21:01   ` Eric Blake
  0 siblings, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-26 21:01 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> This adds a QAPI schema for the properties of the x-remote-object
> object.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  qapi/qom.json | 20 ++++++++++++++++++--
>  1 file changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/qapi/qom.json b/qapi/qom.json
> index f8ff322df0..6793342e81 100644
> --- a/qapi/qom.json
> +++ b/qapi/qom.json
> @@ -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' } }
> +

Matches hw/remote/remote-obj.c:remote_object_class_init().

>  ##
>  # @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'
>    } }
>  
>  ##
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 19/31] qapi/qom: QAPIfy object-add
  2021-02-24 13:52 ` [PATCH v2 19/31] qapi/qom: QAPIfy object-add Kevin Wolf
  2021-02-26 11:30   ` Paolo Bonzini
@ 2021-02-26 21:18   ` Eric Blake
  2021-03-02 18:54     ` Kevin Wolf
  1 sibling, 1 reply; 82+ messages in thread
From: Eric Blake @ 2021-02-26 21:18 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> 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 <kwolf@redhat.com>
> ---
>  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.json
> @@ -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 }

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.

> +++ 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)
>  {
> -    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...

> +
> +    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!

> +
> +    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 <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 20/31] qom: Make "object" QemuOptsList optional
  2021-02-24 13:52 ` [PATCH v2 20/31] qom: Make "object" QemuOptsList optional Kevin Wolf
@ 2021-02-26 21:20   ` Eric Blake
  0 siblings, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-26 21:20 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> 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 <kwolf@redhat.com>
> ---
>  qom/object_interfaces.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 21/31] qemu-storage-daemon: Implement --object with qmp_object_add()
  2021-02-24 13:52 ` [PATCH v2 21/31] qemu-storage-daemon: Implement --object with qmp_object_add() Kevin Wolf
@ 2021-02-26 21:22   ` Eric Blake
  0 siblings, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-26 21:22 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> This QAPIfies --object and ensures that QMP and the command line option
> behave the same.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  storage-daemon/qemu-storage-daemon.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 22/31] qom: Remove user_creatable_add_dict()
  2021-02-24 13:52 ` [PATCH v2 22/31] qom: Remove user_creatable_add_dict() Kevin Wolf
@ 2021-02-26 21:23   ` Eric Blake
  0 siblings, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-26 21:23 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> This function is now unused and can be removed.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  include/qom/object_interfaces.h | 18 ------------------
>  qom/object_interfaces.c         | 32 --------------------------------
>  2 files changed, 50 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 23/31] qom: Factor out user_creatable_process_cmdline()
  2021-02-24 13:52 ` [PATCH v2 23/31] qom: Factor out user_creatable_process_cmdline() Kevin Wolf
@ 2021-02-26 21:26   ` Eric Blake
  0 siblings, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-26 21:26 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> The 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.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 24/31] qemu-io: Use user_creatable_process_cmdline() for --object
  2021-02-24 13:52 ` [PATCH v2 24/31] qemu-io: Use user_creatable_process_cmdline() for --object Kevin Wolf
@ 2021-02-26 21:27   ` Eric Blake
  0 siblings, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-26 21:27 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> 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 <kwolf@redhat.com>
> ---
>  qemu-io.c | 33 +++------------------------------
>  1 file changed, 3 insertions(+), 30 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 25/31] qemu-img: Use user_creatable_process_cmdline() for --object
  2021-02-24 13:52 ` [PATCH v2 25/31] qemu-img: " Kevin Wolf
@ 2021-02-26 21:56   ` Eric Blake
  2021-02-26 22:17     ` Eric Blake
  0 siblings, 1 reply; 82+ messages in thread
From: Eric Blake @ 2021-02-26 21:56 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> 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 <kwolf@redhat.com>
> ---
>  qemu-img.c | 239 ++++++++---------------------------------------------
>  1 file changed, 33 insertions(+), 206 deletions(-)
> 

> @@ -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)...

> -            }
> -        }   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.

>          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;

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).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 25/31] qemu-img: Use user_creatable_process_cmdline() for --object
  2021-02-26 21:56   ` Eric Blake
@ 2021-02-26 22:17     ` Eric Blake
  0 siblings, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-26 22:17 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, ehabkost, qemu-block, libvir-list,
	jasowang, dgilbert, mreitz, kraxel, pbonzini

On 2/26/21 3:56 PM, Eric Blake wrote:
> On 2/24/21 7:52 AM, Kevin Wolf wrote:
>> 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 <kwolf@redhat.com>
>> ---
>>  qemu-img.c | 239 ++++++++---------------------------------------------
>>  1 file changed, 33 insertions(+), 206 deletions(-)
>>
> 
>> @@ -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)...
> 
>> -            }
>> -        }   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

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

> $ 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,

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).

> 
> 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.

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,

> 
>>          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;
> 
> 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).

...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.

> 
> 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).
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 26/31] qemu-nbd: Use user_creatable_process_cmdline() for --object
  2021-02-24 13:52 ` [PATCH v2 26/31] qemu-nbd: " Kevin Wolf
@ 2021-02-26 22:18   ` Eric Blake
  0 siblings, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-26 22:18 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> 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 <kwolf@redhat.com>
> ---
>  qemu-nbd.c | 34 +++-------------------------------
>  1 file changed, 3 insertions(+), 31 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 27/31] qom: Add user_creatable_add_from_str()
  2021-02-24 13:52 ` [PATCH v2 27/31] qom: Add user_creatable_add_from_str() Kevin Wolf
@ 2021-02-26 22:21   ` Eric Blake
  2021-03-02 19:39     ` Kevin Wolf
  0 siblings, 1 reply; 82+ messages in thread
From: Eric Blake @ 2021-02-26 22:21 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> This is a version of user_creatable_process_cmdline() with an Error
> parameter that never calls exit() and is therefore usable in HMP.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  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 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.

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 28/31] hmp: QAPIfy object_add
  2021-02-24 13:52 ` [PATCH v2 28/31] hmp: QAPIfy object_add Kevin Wolf
  2021-02-24 15:31   ` Dr. David Alan Gilbert
@ 2021-02-26 22:23   ` Eric Blake
  1 sibling, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-26 22:23 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> This 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().
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  monitor/hmp-cmds.c      | 17 ++---------------
>  qom/object_interfaces.c | 11 ++++++-----
>  hmp-commands.hx         |  2 +-
>  3 files changed, 9 insertions(+), 21 deletions(-)
> 
Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 29/31] qom: Add user_creatable_parse_str()
  2021-02-24 13:52 ` [PATCH v2 29/31] qom: Add user_creatable_parse_str() Kevin Wolf
@ 2021-02-26 22:24   ` Eric Blake
  0 siblings, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-26 22:24 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> 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.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  include/qom/object_interfaces.h | 15 +++++++++++++++
>  qom/object_interfaces.c         | 20 ++++++++++++++------
>  2 files changed, 29 insertions(+), 6 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 30/31] vl: QAPIfy -object
  2021-02-24 13:52 ` [PATCH v2 30/31] vl: QAPIfy -object Kevin Wolf
@ 2021-02-26 22:40   ` Eric Blake
  0 siblings, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-26 22:40 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> 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.
> 
> -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.

> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  softmmu/vl.c | 109 +++++++++++++++++++++++++++++++++++++++------------
>  1 file changed, 84 insertions(+), 25 deletions(-)
> 
Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 31/31] qom: Drop QemuOpts based interfaces
  2021-02-24 13:52 ` [PATCH v2 31/31] qom: Drop QemuOpts based interfaces Kevin Wolf
@ 2021-02-26 22:42   ` Eric Blake
  0 siblings, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-02-26 22:42 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, mreitz, kraxel, pbonzini,
	dgilbert

On 2/24/21 7:52 AM, Kevin Wolf wrote:
> user_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.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  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!

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 19/31] qapi/qom: QAPIfy object-add
  2021-02-26 11:30   ` Paolo Bonzini
@ 2021-03-01 11:54     ` Kevin Wolf
  2021-03-01 12:03       ` Paolo Bonzini
  0 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-03-01 11:54 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, qemu-devel, kraxel, mreitz,
	dgilbert

Am 26.02.2021 um 12:30 hat Paolo Bonzini geschrieben:
> On 24/02/21 14:52, Kevin Wolf wrote:
> > +    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.

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



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 19/31] qapi/qom: QAPIfy object-add
  2021-03-01 11:54     ` Kevin Wolf
@ 2021-03-01 12:03       ` Paolo Bonzini
  0 siblings, 0 replies; 82+ messages in thread
From: Paolo Bonzini @ 2021-03-01 12:03 UTC (permalink / raw)
  To: Kevin Wolf
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, jasowang, armbru, qemu-devel, kraxel, mreitz,
	dgilbert

On 01/03/21 12:54, Kevin Wolf wrote:
>> 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.
> 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().

Yes, you are right.

> The obvious place to affect only the external interfaces would be
> user_creatable_add_type().

Makes sense, thanks.

Paolo



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 03/31] qapi/qom: Add ObjectOptions for iothread
  2021-02-25 22:55   ` Eric Blake
@ 2021-03-02 17:27     ` Kevin Wolf
  0 siblings, 0 replies; 82+ messages in thread
From: Kevin Wolf @ 2021-03-02 17:27 UTC (permalink / raw)
  To: Eric Blake
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, armbru, jasowang, qemu-devel, mreitz, kraxel,
	pbonzini, dgilbert

Am 25.02.2021 um 23:55 hat Eric Blake geschrieben:
> On 2/24/21 7:52 AM, Kevin Wolf wrote:
> > 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 <kwolf@redhat.com>
> > ---
> >  qapi/qom.json | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 53 insertions(+)
> > 
> > diff --git a/qapi/qom.json b/qapi/qom.json
> > index 96c91c1faf..bf2ecb34be 100644
> > --- a/qapi/qom.json
> > +++ b/qapi/qom.json
> > @@ -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)
> 
> Matches PollParamInfo declarations in iothread.c.
> 
> > +#
> > +# 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).

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'.

> > +##
> > +{ '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



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 06/31] qapi/qom: Add ObjectOptions for dbus-vmstate
  2021-02-26 15:58   ` Eric Blake
@ 2021-03-02 17:36     ` Kevin Wolf
  0 siblings, 0 replies; 82+ messages in thread
From: Kevin Wolf @ 2021-03-02 17:36 UTC (permalink / raw)
  To: Eric Blake
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, armbru, jasowang, qemu-devel, mreitz, kraxel,
	pbonzini, dgilbert

Am 26.02.2021 um 16:58 hat Eric Blake geschrieben:
> On 2/24/21 7:52 AM, Kevin Wolf wrote:
> > 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



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 07/31] qapi/qom: Add ObjectOptions for memory-backend-*
  2021-02-26 16:23   ` Eric Blake
@ 2021-03-02 18:11     ` Kevin Wolf
  0 siblings, 0 replies; 82+ messages in thread
From: Kevin Wolf @ 2021-03-02 18:11 UTC (permalink / raw)
  To: Eric Blake
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, armbru, jasowang, qemu-devel, mreitz, kraxel,
	pbonzini, dgilbert

Am 26.02.2021 um 17:23 hat Eric Blake geschrieben:
> On 2/24/21 7:52 AM, Kevin Wolf wrote:
> > 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 <kwolf@redhat.com>
> > ---
> >  qapi/common.json  |  20 ++++++++
> >  qapi/machine.json |  22 +--------
> >  qapi/qom.json     | 118 +++++++++++++++++++++++++++++++++++++++++++++-
> >  3 files changed, 138 insertions(+), 22 deletions(-)
> > 
> 
> > +++ b/qapi/qom.json
> 
> > +##
> > +# @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");

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.

> > +#
> > +# @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.
> 
> > +#
> > +# @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
> > +#                                        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... :-))

> > +#
> > +# Since: 2.1
> > +##
> > +{ 'struct': 'MemoryBackendProperties',
> > +  'data': { '*dump': 'bool',
> > +            '*host-nodes': ['uint16'],
> > +            '*merge': 'bool',
> > +            '*policy': 'HostMemPolicy',
> > +            '*prealloc': 'bool',
> > +            '*prealloc-threads': 'uint32',
> > +            '*share': 'bool',
> > +            '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...

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.

> > +#         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.
> 
> > +#
> > +# @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',
> > +  '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.

> > +            '*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)
> > +#
> > +# @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,...
> 
> > +
> >  ##
> >  # @ObjectType:
> >  #
> > @@ -287,7 +395,10 @@
> >      'cryptodev-backend-builtin',
> >      'cryptodev-vhost-user',
> >      'dbus-vmstate',
> > -    'iothread'
> > +    'iothread',
> > +    'memory-backend-file',
> > +    'memory-backend-memfd',
> > +    'memory-backend-ram'
> >    ] }
> >  
> >  ##
> > @@ -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.

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



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 09/31] qapi/qom: Add ObjectOptions for throttle-group
  2021-02-26 17:26   ` Eric Blake
@ 2021-03-02 18:18     ` Kevin Wolf
  0 siblings, 0 replies; 82+ messages in thread
From: Kevin Wolf @ 2021-03-02 18:18 UTC (permalink / raw)
  To: Eric Blake
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, armbru, jasowang, qemu-devel, mreitz, kraxel,
	pbonzini, dgilbert

Am 26.02.2021 um 18:26 hat Eric Blake geschrieben:
> On 2/24/21 7:52 AM, Kevin Wolf wrote:
> > 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 <kwolf@redhat.com>
> > ---
> >  qapi/block-core.json | 27 +++++++++++++++++++++++++++
> >  qapi/qom.json        |  7 +++++--
> >  2 files changed, 32 insertions(+), 2 deletions(-)
> > 
> > diff --git a/qapi/block-core.json b/qapi/block-core.json
> > index 9f555d5c1d..a67fa0cc59 100644
> > --- a/qapi/block-core.json
> > +++ b/qapi/block-core.json
> > @@ -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.
> 
> > +#
> > +# 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.

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



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 10/31] qapi/qom: Add ObjectOptions for secret*, deprecate 'loaded'
  2021-02-26 19:17   ` Eric Blake
@ 2021-03-02 18:23     ` Kevin Wolf
  0 siblings, 0 replies; 82+ messages in thread
From: Kevin Wolf @ 2021-03-02 18:23 UTC (permalink / raw)
  To: Eric Blake
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, armbru, jasowang, qemu-devel, mreitz, kraxel,
	pbonzini, dgilbert

Am 26.02.2021 um 20:17 hat Eric Blake geschrieben:
> On 2/24/21 7:52 AM, Kevin Wolf wrote:
> > diff --git a/qapi/qom.json b/qapi/qom.json
> > index 449dca8ec5..2668ad8369 100644
> > --- a/qapi/qom.json
> > +++ b/qapi/qom.json
> > @@ -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',
> 
> 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



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 11/31] qapi/qom: Add ObjectOptions for tls-*, deprecate 'loaded'
  2021-02-26 19:33   ` Eric Blake
@ 2021-03-02 18:27     ` Kevin Wolf
  0 siblings, 0 replies; 82+ messages in thread
From: Kevin Wolf @ 2021-03-02 18:27 UTC (permalink / raw)
  To: Eric Blake
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, armbru, jasowang, qemu-devel, mreitz, kraxel,
	pbonzini, dgilbert

Am 26.02.2021 um 20:33 hat Eric Blake geschrieben:
> On 2/24/21 7:52 AM, Kevin Wolf wrote:
> > 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 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.
> > 
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> >  qapi/crypto.json | 98 ++++++++++++++++++++++++++++++++++++++++++++++++
> >  qapi/qom.json    | 12 +++++-
> >  2 files changed, 108 insertions(+), 2 deletions(-)
> > 
> > diff --git a/qapi/crypto.json b/qapi/crypto.json
> > index 0fef3de66d..7116ae9a46 100644
> > --- a/qapi/crypto.json
> > +++ b/qapi/crypto.json
> > @@ -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' } }
> 
> Matches crypto/tlscreds.c:qcrypto_tls_creds_class_init().
> 
> > +
> > +##
> > +# @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'] } } }
> 
> 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().

We can't turn a no-op into an error without a deprecation period.

> > +
> > +##
> > +# @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' } }
> 
> 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...)

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



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 12/31] qapi/qom: Add ObjectOptions for can-*
  2021-02-26 19:42   ` Eric Blake
@ 2021-03-02 18:32     ` Kevin Wolf
  2021-03-02 20:03       ` Eric Blake
  0 siblings, 1 reply; 82+ messages in thread
From: Kevin Wolf @ 2021-03-02 18:32 UTC (permalink / raw)
  To: Eric Blake
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, armbru, jasowang, qemu-devel, mreitz, kraxel,
	pbonzini, dgilbert

Am 26.02.2021 um 20:42 hat Eric Blake geschrieben:
> On 2/24/21 7:52 AM, Kevin Wolf wrote:
> > 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.

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



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 17/31] qapi/qom: Add ObjectOptions for input-*
  2021-02-26 20:55   ` Eric Blake
@ 2021-03-02 18:42     ` Kevin Wolf
  0 siblings, 0 replies; 82+ messages in thread
From: Kevin Wolf @ 2021-03-02 18:42 UTC (permalink / raw)
  To: Eric Blake
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, armbru, jasowang, qemu-devel, mreitz, kraxel,
	pbonzini, dgilbert

Am 26.02.2021 um 21:55 hat Eric Blake geschrieben:
> On 2/24/21 7:52 AM, Kevin Wolf wrote:
> > 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 <kwolf@redhat.com>
> > ---
> >  qapi/common.json | 12 ++++++++++
> >  qapi/qom.json    | 58 ++++++++++++++++++++++++++++++++++++++++++++++++
> >  qapi/ui.json     | 13 +----------
> >  3 files changed, 71 insertions(+), 12 deletions(-)
> > 
> 
> > +##
> > +# @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...
> 
> > +#
> > +# @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.

> 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



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 19/31] qapi/qom: QAPIfy object-add
  2021-02-26 21:18   ` Eric Blake
@ 2021-03-02 18:54     ` Kevin Wolf
  0 siblings, 0 replies; 82+ messages in thread
From: Kevin Wolf @ 2021-03-02 18:54 UTC (permalink / raw)
  To: Eric Blake
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, armbru, jasowang, qemu-devel, mreitz, kraxel,
	pbonzini, dgilbert

Am 26.02.2021 um 22:18 hat Eric Blake geschrieben:
> On 2/24/21 7:52 AM, Kevin Wolf wrote:
> > 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 <kwolf@redhat.com>
> > ---
> >  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.json
> > @@ -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 }
> 
> 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.
> 
> > +++ 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)
> >  {
> > -    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.

> > +
> > +    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

> > +
> > +    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 <eblake@redhat.com>
> 
> -- 
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.           +1-919-301-3226
> Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 27/31] qom: Add user_creatable_add_from_str()
  2021-02-26 22:21   ` Eric Blake
@ 2021-03-02 19:39     ` Kevin Wolf
  0 siblings, 0 replies; 82+ messages in thread
From: Kevin Wolf @ 2021-03-02 19:39 UTC (permalink / raw)
  To: Eric Blake
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, armbru, jasowang, qemu-devel, mreitz, kraxel,
	pbonzini, dgilbert

Am 26.02.2021 um 23:21 hat Eric Blake geschrieben:
> On 2/24/21 7:52 AM, Kevin Wolf wrote:
> > This is a version of user_creatable_process_cmdline() with an Error
> > parameter that never calls exit() and is therefore usable in HMP.
> > 
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> >  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 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.

Thanks for the suggestion, with this reordering the fix became quite
simple.

Kevin



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 12/31] qapi/qom: Add ObjectOptions for can-*
  2021-03-02 18:32     ` Kevin Wolf
@ 2021-03-02 20:03       ` Eric Blake
  0 siblings, 0 replies; 82+ messages in thread
From: Eric Blake @ 2021-03-02 20:03 UTC (permalink / raw)
  To: Kevin Wolf
  Cc: lvivier, thuth, pkrempa, berrange, ehabkost, qemu-block,
	libvir-list, armbru, jasowang, qemu-devel, mreitz, kraxel,
	pbonzini, dgilbert

On 3/2/21 12:32 PM, Kevin Wolf wrote:
> Am 26.02.2021 um 20:42 hat Eric Blake geschrieben:
>> On 2/24/21 7:52 AM, Kevin Wolf wrote:
>>> 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.
> 
> 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.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 82+ messages in thread

end of thread, other threads:[~2021-03-02 20:05 UTC | newest]

Thread overview: 82+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-24 13:52 [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Kevin Wolf
2021-02-24 13:52 ` [PATCH v2 01/31] tests: Drop 'props' from object-add calls Kevin Wolf
2021-02-25 22:40   ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 02/31] qapi/qom: Drop deprecated 'props' from object-add Kevin Wolf
2021-02-25 22:42   ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 03/31] qapi/qom: Add ObjectOptions for iothread Kevin Wolf
2021-02-25 22:55   ` Eric Blake
2021-03-02 17:27     ` Kevin Wolf
2021-02-24 13:52 ` [PATCH v2 04/31] qapi/qom: Add ObjectOptions for authz-* Kevin Wolf
2021-02-26 14:02   ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 05/31] qapi/qom: Add ObjectOptions for cryptodev-* Kevin Wolf
2021-02-26 14:36   ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 06/31] qapi/qom: Add ObjectOptions for dbus-vmstate Kevin Wolf
2021-02-26 15:58   ` Eric Blake
2021-03-02 17:36     ` Kevin Wolf
2021-02-24 13:52 ` [PATCH v2 07/31] qapi/qom: Add ObjectOptions for memory-backend-* Kevin Wolf
2021-02-26 16:23   ` Eric Blake
2021-03-02 18:11     ` Kevin Wolf
2021-02-24 13:52 ` [PATCH v2 08/31] qapi/qom: Add ObjectOptions for rng-*, deprecate 'opened' Kevin Wolf
2021-02-26 16:54   ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 09/31] qapi/qom: Add ObjectOptions for throttle-group Kevin Wolf
2021-02-26 17:26   ` Eric Blake
2021-03-02 18:18     ` Kevin Wolf
2021-02-24 13:52 ` [PATCH v2 10/31] qapi/qom: Add ObjectOptions for secret*, deprecate 'loaded' Kevin Wolf
2021-02-26 19:17   ` Eric Blake
2021-03-02 18:23     ` Kevin Wolf
2021-02-24 13:52 ` [PATCH v2 11/31] qapi/qom: Add ObjectOptions for tls-*, " Kevin Wolf
2021-02-26 19:33   ` Eric Blake
2021-03-02 18:27     ` Kevin Wolf
2021-02-24 13:52 ` [PATCH v2 12/31] qapi/qom: Add ObjectOptions for can-* Kevin Wolf
2021-02-26 19:42   ` Eric Blake
2021-03-02 18:32     ` Kevin Wolf
2021-03-02 20:03       ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 13/31] qapi/qom: Add ObjectOptions for colo-compare Kevin Wolf
2021-02-26 19:46   ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 14/31] qapi/qom: Add ObjectOptions for filter-* Kevin Wolf
2021-02-26 20:03   ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 15/31] qapi/qom: Add ObjectOptions for pr-manager-helper Kevin Wolf
2021-02-26 20:04   ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 16/31] qapi/qom: Add ObjectOptions for confidential-guest-support Kevin Wolf
2021-02-24 15:21   ` Dr. David Alan Gilbert
2021-02-24 16:25     ` Kevin Wolf
2021-02-26 20:27   ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 17/31] qapi/qom: Add ObjectOptions for input-* Kevin Wolf
2021-02-26 20:55   ` Eric Blake
2021-03-02 18:42     ` Kevin Wolf
2021-02-24 13:52 ` [PATCH v2 18/31] qapi/qom: Add ObjectOptions for x-remote-object Kevin Wolf
2021-02-26 21:01   ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 19/31] qapi/qom: QAPIfy object-add Kevin Wolf
2021-02-26 11:30   ` Paolo Bonzini
2021-03-01 11:54     ` Kevin Wolf
2021-03-01 12:03       ` Paolo Bonzini
2021-02-26 21:18   ` Eric Blake
2021-03-02 18:54     ` Kevin Wolf
2021-02-24 13:52 ` [PATCH v2 20/31] qom: Make "object" QemuOptsList optional Kevin Wolf
2021-02-26 21:20   ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 21/31] qemu-storage-daemon: Implement --object with qmp_object_add() Kevin Wolf
2021-02-26 21:22   ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 22/31] qom: Remove user_creatable_add_dict() Kevin Wolf
2021-02-26 21:23   ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 23/31] qom: Factor out user_creatable_process_cmdline() Kevin Wolf
2021-02-26 21:26   ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 24/31] qemu-io: Use user_creatable_process_cmdline() for --object Kevin Wolf
2021-02-26 21:27   ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 25/31] qemu-img: " Kevin Wolf
2021-02-26 21:56   ` Eric Blake
2021-02-26 22:17     ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 26/31] qemu-nbd: " Kevin Wolf
2021-02-26 22:18   ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 27/31] qom: Add user_creatable_add_from_str() Kevin Wolf
2021-02-26 22:21   ` Eric Blake
2021-03-02 19:39     ` Kevin Wolf
2021-02-24 13:52 ` [PATCH v2 28/31] hmp: QAPIfy object_add Kevin Wolf
2021-02-24 15:31   ` Dr. David Alan Gilbert
2021-02-26 22:23   ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 29/31] qom: Add user_creatable_parse_str() Kevin Wolf
2021-02-26 22:24   ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 30/31] vl: QAPIfy -object Kevin Wolf
2021-02-26 22:40   ` Eric Blake
2021-02-24 13:52 ` [PATCH v2 31/31] qom: Drop QemuOpts based interfaces Kevin Wolf
2021-02-26 22:42   ` Eric Blake
2021-02-24 16:01 ` [PATCH v2 00/31] qapi/qom: QAPIfy --object and object-add Peter Krempa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.