@@ -77,7 +77,8 @@
{ 'command': 'device_add',
'data': {'driver': 'str', '*bus': 'str', '*id': 'str'},
'gen': false, # so we can get the additional arguments
- 'features': ['json-cli', 'json-cli-hotplug'] }
+ 'features': ['json-cli', 'json-cli-hotplug'],
+ 'allow-preconfig': true }
##
# @device_del:
@@ -233,7 +233,7 @@ static void monitor_init_qmp_commands(void)
qmp_init_marshal(&qmp_commands);
qmp_register_command(&qmp_commands, "device_add",
- qmp_device_add, 0, 0);
+ qmp_device_add, QCO_ALLOW_PRECONFIG, 0);
QTAILQ_INIT(&qmp_cap_negotiation_commands);
qmp_register_command(&qmp_cap_negotiation_commands, "qmp_capabilities",
@@ -853,6 +853,10 @@ void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp)
QemuOpts *opts;
DeviceState *dev;
+ if (!phase_until(PHASE_MACHINE_INITIALIZED, errp)) {
+ return;
+ }
+
opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict, errp);
if (!opts) {
return;
@@ -668,6 +668,7 @@ ERST
.help = "add device, like -device on the command line",
.cmd = hmp_device_add,
.command_completion = device_add_completion,
+ .flags = "p",
},
SRST