mirror of https://github.com/proxmox/mirror_qemu
monitor: convert do_device_add() to QObject
parent
c7e4e8ceb3
commit
8bc27249f0
42
hw/qdev.c
42
hw/qdev.c
|
@ -586,7 +586,9 @@ static BusState *qbus_find(const char *path)
|
||||||
dev = qbus_find_dev(bus, elem);
|
dev = qbus_find_dev(bus, elem);
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
qerror_report(QERR_DEVICE_NOT_FOUND, elem);
|
qerror_report(QERR_DEVICE_NOT_FOUND, elem);
|
||||||
qbus_list_dev(bus);
|
if (!monitor_cur_is_qmp()) {
|
||||||
|
qbus_list_dev(bus);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,7 +607,9 @@ static BusState *qbus_find(const char *path)
|
||||||
return QLIST_FIRST(&dev->child_bus);
|
return QLIST_FIRST(&dev->child_bus);
|
||||||
default:
|
default:
|
||||||
qerror_report(QERR_DEVICE_MULTIPLE_BUSSES, elem);
|
qerror_report(QERR_DEVICE_MULTIPLE_BUSSES, elem);
|
||||||
qbus_list_bus(dev);
|
if (!monitor_cur_is_qmp()) {
|
||||||
|
qbus_list_bus(dev);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -619,7 +623,9 @@ static BusState *qbus_find(const char *path)
|
||||||
bus = qbus_find_bus(dev, elem);
|
bus = qbus_find_bus(dev, elem);
|
||||||
if (!bus) {
|
if (!bus) {
|
||||||
qerror_report(QERR_BUS_NOT_FOUND, elem);
|
qerror_report(QERR_BUS_NOT_FOUND, elem);
|
||||||
qbus_list_bus(dev);
|
if (!monitor_cur_is_qmp()) {
|
||||||
|
qbus_list_bus(dev);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -762,16 +768,36 @@ void do_info_qdm(Monitor *mon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_device_add(Monitor *mon, const QDict *qdict)
|
/**
|
||||||
|
* do_device_add(): Add a device
|
||||||
|
*
|
||||||
|
* Argument qdict contains
|
||||||
|
* - "driver": the name of the new device's driver
|
||||||
|
* - "bus": the device's parent bus (device tree path)
|
||||||
|
* - "id": the device's ID (must be unique)
|
||||||
|
* - device properties
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* { "driver": "usb-net", "id": "eth1", "netdev": "netdev1" }
|
||||||
|
*/
|
||||||
|
int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
||||||
{
|
{
|
||||||
QemuOpts *opts;
|
QemuOpts *opts;
|
||||||
|
|
||||||
opts = qemu_opts_from_qdict(&qemu_device_opts, qdict);
|
opts = qemu_opts_from_qdict(&qemu_device_opts, qdict);
|
||||||
if (opts) {
|
if (!opts) {
|
||||||
if (qdev_device_help(opts) || qdev_device_add(opts) == NULL) {
|
return -1;
|
||||||
qemu_opts_del(opts);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (!monitor_cur_is_qmp() && qdev_device_help(opts)) {
|
||||||
|
qemu_opts_del(opts);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!qdev_device_add(opts)) {
|
||||||
|
qemu_opts_del(opts);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_device_del(Monitor *mon, const QDict *qdict)
|
void do_device_del(Monitor *mon, const QDict *qdict)
|
||||||
|
|
|
@ -175,7 +175,7 @@ void qbus_free(BusState *bus);
|
||||||
|
|
||||||
void do_info_qtree(Monitor *mon);
|
void do_info_qtree(Monitor *mon);
|
||||||
void do_info_qdm(Monitor *mon);
|
void do_info_qdm(Monitor *mon);
|
||||||
void do_device_add(Monitor *mon, const QDict *qdict);
|
int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
|
||||||
void do_device_del(Monitor *mon, const QDict *qdict);
|
void do_device_del(Monitor *mon, const QDict *qdict);
|
||||||
|
|
||||||
/*** qdev-properties.c ***/
|
/*** qdev-properties.c ***/
|
||||||
|
|
|
@ -573,7 +573,8 @@ ETEXI
|
||||||
.args_type = "device:O",
|
.args_type = "device:O",
|
||||||
.params = "driver[,prop=value][,...]",
|
.params = "driver[,prop=value][,...]",
|
||||||
.help = "add device, like -device on the command line",
|
.help = "add device, like -device on the command line",
|
||||||
.mhandler.cmd = do_device_add,
|
.user_print = monitor_user_noop,
|
||||||
|
.mhandler.cmd_new = do_device_add,
|
||||||
},
|
},
|
||||||
|
|
||||||
STEXI
|
STEXI
|
||||||
|
|
Loading…
Reference in New Issue