diff mbox series

[RFC,9/9] qapi: Allow some commands to be executed in machine 'initialized' phase

Message ID 20210513082549.114275-10-mirela.grujic@greensocs.com (mailing list archive)
State New, archived
Headers show
Series Initial support for machine creation via QMP | expand

Commit Message

Mirela Grujic May 13, 2021, 8:25 a.m. UTC
The following commands are allowed to execute during the machine
'initialized' phase (enabled with 'allow-init-config' option):
1) query-machine-phase
2) next-machine-phase
3) advance-machine-phase
3) device_add

Note: for device_add command in qdev.json adding the 'allow-init-config'
option has no effect because the command appears to bypass QAPI (see
TODO at qapi/qdev.json:61). The option is added there solely to document
the intent.
For the same reason, the flags have to be explicitly set in
monitor_init_qmp_commands() when the device_add command is registered.

Signed-off-by: Mirela Grujic <mirela.grujic@greensocs.com>
---
 qapi/machine.json | 7 ++++---
 qapi/qdev.json    | 3 ++-
 monitor/misc.c    | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/qapi/machine.json b/qapi/machine.json
index 31872aae72..c77ea03acb 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -1327,7 +1327,7 @@ 
 #
 ##
 { 'command': 'query-machine-phase', 'returns': 'MachineInitPhaseStatus',
-             'allow-preconfig': true }
+             'allow-preconfig': true, 'allow-init-config': true }
 
 ##
 # @next-machine-phase:
@@ -1351,7 +1351,8 @@ 
 # <- { "return": {} }
 #
 ##
-{ 'command': 'next-machine-phase', 'allow-preconfig': true }
+{ 'command': 'next-machine-phase', 'allow-preconfig': true,
+             'allow-init-config': true }
 
 ##
 # @advance-machine-phase:
@@ -1377,4 +1378,4 @@ 
 #
 ##
 { 'command': 'advance-machine-phase', 'data' : {'phase': 'MachineInitPhase'},
-             'allow-preconfig': true }
+             'allow-preconfig': true, 'allow-init-config': true }
diff --git a/qapi/qdev.json b/qapi/qdev.json
index b83178220b..2706ef3efa 100644
--- a/qapi/qdev.json
+++ b/qapi/qdev.json
@@ -67,7 +67,8 @@ 
 ##
 { 'command': 'device_add',
   'data': {'driver': 'str', '*bus': 'str', '*id': 'str'},
-  'gen': false } # so we can get the additional arguments
+  'gen': false, # so we can get the additional arguments
+  'allow-init-config': true }
 
 ##
 # @device_del:
diff --git a/monitor/misc.c b/monitor/misc.c
index 55f3744053..88a0edff0a 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -232,7 +232,7 @@  static void monitor_init_qmp_commands(void)
     qmp_init_marshal(&qmp_commands);
 
     qmp_register_command(&qmp_commands, "device_add", qmp_device_add,
-                         QCO_NO_OPTIONS);
+                         QCO_ALLOW_INIT_CONFIG);
 
     QTAILQ_INIT(&qmp_cap_negotiation_commands);
     qmp_register_command(&qmp_cap_negotiation_commands, "qmp_capabilities",