multi-process: QMP/HMP commands to add a device to the remote process
RFC PATCH 21/37 multi-process: QMP/HMP commands to add a device to the remote process
From: Jagannathan Raman <[email protected]>
Adds rdevice_add QMP & HMP commands to hotplug device to a remote device.
--- hmp-commands.hx | 14 ++++++++ hmp.h | 1 + hw/proxy/monitor.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++ include/io/proxy-link.h | 2 ++ include/monitor/qdev.h | 4 +++ monitor.c | 5 +++ qapi/misc.json | 22 ++++++++++++ remote/remote-main.c | 48 ++++++++++++++++++++++++++ 8 files changed, 188 insertions(+)
hmp-commands.hx +14 -0
@@ -727,6 +727,20 @@ ETEXI #if defined(CONFIG_MPQEMU) { + .name = "rdevice_add", + .args_type = "rdev_id:s,driver:s,id:s,drive:s,bus:s", + .params = "rdev_id driver id drive bus", + .help = "add device to remote proc, like -rdevice on the command line", + .cmd = hmp_rdevice_add, + }, + +STEXI +@item rdevice_add @var{config} +@findex rdevice_add +Add device to remote proc. +ETEXI + + { .name = "remote_proc_list", .args_type = "", .params = "",
hmp.h +1 -0
@@ -150,5 +150,6 @@ void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict);void hmp_info_memory_size_summary (Monitor *mon,const QDict *qdict);void hmp_info_sev (Monitor *mon,const QDict *qdict);void hmp_remote_proc_list (Monitor *mon,const QDict *qdict); +void hmp_rdevice_add (Monitor *mon,const QDict *qdict);#endif
hw/proxy/monitor.c +92 -0
107 lines not on this page · raw message
include/io/proxy-link.h +2 -0
@@ -60,6 +60,7 @@ typedef struct ProxyLinkState ProxyLinkState;* BAR_READ Reads from PCI BAR region * SET_IRQFD Sets the IRQFD to be used to raise interrupts directly * from remote device +* DEVICE_ADD QMP/HMP command to hotplug device * */ typedef enum {
@@ -70,6 +71,7 @@ typedef enum {BAR_WRITE ,BAR_READ ,SET_IRQFD , +DEVICE_ADD ,MAX , } proc_cmd_t;
include/monitor/qdev.h +4 -0
@@ -10,6 +10,10 @@ void hmp_info_qdm(Monitor *mon, const QDict *qdict);void hmp_info_qom_tree (Monitor *mon,const QDict *dict);void qmp_device_add (QDict *qdict,QObject **ret_data,Error **errp); +#ifdef CONFIG_MPQEMU +void qmp_rdevice_add (QDict *qdict,QObject **ret_data,Error **errp); +#endif +int qdev_device_help (QemuOpts *opts);DeviceState *qdev_device_add (QemuOpts *opts,Error **errp);void qdev_set_id (DeviceState *dev,const char *id);
monitor.c +5 -0
@@ -1155,6 +1155,11 @@ static void monitor_init_qmp_commands(void)qmp_register_command (&qmp_commands,"netdev_add" , qmp_netdev_add,QCO_NO_OPTIONS ); +#ifdef CONFIG_MPQEMU +qmp_register_command (&qmp_commands,"rdevice_add" , qmp_rdevice_add, +QCO_NO_OPTIONS ); +#endif +QTAILQ_INIT (&qmp_cap_negotiation_commands);qmp_register_command (&qmp_cap_negotiation_commands,"qmp_capabilities" , qmp_marshal_qmp_capabilities,QCO_ALLOW_PRECONFIG );
qapi/misc.json +22 -0
@@ -1663,6 +1663,28 @@ 'gen': false } # so we can get the additional arguments ## +# @rdevice_add: +# +# @rdev_id: ID of the remote device root +# +# @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 +# +# Additional arguments depend on the type. +# +# Add a device. +# +# Since: 3.0 +## +{ 'command': 'rdevice_add', + 'data': {'rdev_id': 'str', 'driver': 'str', '*bus': 'str', '*id': 'str'}, + 'if': 'defined(CONFIG_MPQEMU)', + 'gen': false } # so we can get the additional arguments + +## # @device_del: # # Remove a device from a guest
remote/remote-main.c +48 -0
72 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Quoted 130 lines · * [email protected] ([email protected]) wrote:
From: Jagannathan Raman <[email protected]>
Adds
rdevice_addQMP & HMP commands to hotplug device to a remote device.Signed-off-by Jagannathan Raman <[email protected]>Signed-off-by John G Johnson <[email protected]>Signed-off-by Elena Ufimtseva <[email protected]>--- hmp-commands.hx | 14 ++++++++ hmp.h | 1 + hw/proxy/monitor.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++ include/io/proxy-link.h | 2 ++ include/monitor/qdev.h | 4 +++ monitor.c | 5 +++ qapi/misc.json | 22 ++++++++++++ remote/remote-main.c | 48 ++++++++++++++++++++++++++ 8 files changed, 188 insertions(+)hmp-commands.hx +14
-0@@ -727,6 +727,20 @@ ETEXI #if defined(CONFIG_MPQEMU) { + .name = "rdevice_add", + .args_type = "rdev_id:s,driver:s,id:s,drive:s,bus:s", + .params = "rdev_id driver id drive bus", + .help = "add device to remote proc, like -rdevice on the command line", + .cmd = hmp_rdevice_add, + }, + +STEXI +@item rdevice_add @var{config} +@findex rdevice_add +Add device to remote proc. +ETEXI + + { .name = "remote_proc_list", .args_type = "", .params = "",hmp.h +1
-0@@ -150,5 +150,6 @@ void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict);void hmp_info_memory_size_summary (Monitor *mon,const QDict *qdict);void hmp_info_sev (Monitor *mon,const QDict *qdict);void hmp_remote_proc_list (Monitor *mon,const QDict *qdict); +void hmp_rdevice_add (Monitor *mon,const QDict *qdict);#endif hw/proxy/monitor.c +54
-0@@ -23,6 +23,7 @@*/ #include <sys/types.h> +#include <string.h> #include "qemu/osdep.h" #include "qapi/qapi-types-block-core.h" @@ -33,6 +34,13 @@#include "hw/boards.h" #include "hw/i386/pc.h" #include "hw/proxy/qemu-proxy.h" +#include "qapi/qapi-commands-misc.h" +#include "monitor/qdev.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qjson.h" +#include "qapi/qmp/qstring.h" +#include "qapi/error.h" +#include "io/proxy-link.h" /* * TODO: Is there a callback where the allocated memory for QMP could be free'd @@ -87,3 +95,87 @@ void hmp_remote_proc_list(Monitor *mon, const QDict *qdict) pdev->remote_pid, pdev->rid, id, k->command); } } + +static PCIProxyDev *get_proxy_device (QDict *qdict,Error **errp) +{ +PCMachineState *pcms =PC_MACHINE (current_machine); +PCIProxyDev *pdev =NULL ; +const char *rdev_id; + +if (!qdict_haskey (qdict,"rdev_id" )) { +error_setg (errp,"Please specify a value for rdev_id" ); +return NULL ; + } + + rdev_id =qdict_get_str (qdict,"rdev_id" ); + + pdev = (PCIProxyDev *)g_hash_table_lookup (pcms->remote_devs, rdev_id); +if (!pdev) { +error_setg (errp, +"No remote device by ID %s. Use query-remote command to get remote devices" , + rdev_id); + } + +return pdev; +} + +static void rdevice_add_del (QDict *qdict,proc_cmd_t cmd,Error **errp) +{ +PCMachineState *pcms =PC_MACHINE (current_machine); +ProcMsg msg = {0 }; +PCIProxyDev *pdev =NULL ; +const char *id; +QString *json; +int wait; + + pdev =get_proxy_device (qdict, errp); +if (*errp) { +return ; + } + +qdict_del (qdict,"rdev_id" ); + + id =qdict_get_str (qdict,"id" ); + + json =qobject_to_json (QOBJECT (qdict)); + + wait =GET_REMOTE_WAIT ; +
hw/proxy/monitor.c void hmp_remote_proc_list(Monitor *mon, const QDict *qdict) · line 153
Quoted 10 lines
hw/proxy/monitor.c +10
-0+ msg.cmd = cmd; + msg.bytestream =1 ; + msg.size =strlen (qstring_get_str (json)); + msg.data2 = (uint8_t *)qstring_get_str (json); + msg.num_fds =1 ; + msg.fds[0 ] = wait; + +proxy_proc_send (pdev->proxy_link, &msg); + (void )wait_for_remote (wait); +PUT_REMOTE_WAIT (wait);
Can this not fail? For example what happens if the external process dies just about here?
hw/proxy/monitor.c void hmp_remote_proc_list(Monitor *mon, const QDict *qdict) · line 155
Quoted 1 line
hw/proxy/monitor.c +1
-0+qstring_destroy_obj (QOBJECT (json));
All of this:
build some JSON
send it to the remote
wait for the response
all looks like something more generic than a device add/del - separate function?
Quoted 50 lines
hw/proxy/monitor.c +25
-0+/* TODO: Only on success */ +if (cmd ==DEVICE_ADD ) { + (void )g_hash_table_insert (pcms->remote_devs, (gpointer )g_strdup (id), + (gpointer )pdev); + } +} + +void qmp_rdevice_add (QDict *qdict,QObject **ret_data,Error **errp) +{ +rdevice_add_del (qdict,DEVICE_ADD , errp); +} + +void hmp_rdevice_add (Monitor *mon,const QDict *qdict) +{ +Error *err =NULL ; + +/* TODO: Is it OK to modify the QDict argument from HMP? */ +rdevice_add_del ((QDict *)qdict,DEVICE_ADD , &err); + +if (err) { +monitor_printf (mon,"rdevice_add error: %s\n" , +error_get_pretty (err)); +error_free (err); + } +}include/io/proxy-link.h +2
-0@@ -60,6 +60,7 @@ typedef struct ProxyLinkState ProxyLinkState;* BAR_READ Reads from PCI BAR region * SET_IRQFD Sets the IRQFD to be used to raise interrupts directly * from remote device +* DEVICE_ADD QMP/HMP command to hotplug device * */ typedef enum {@@ -70,6 +71,7 @@ typedef enum {BAR_WRITE ,BAR_READ ,SET_IRQFD , +DEVICE_ADD ,MAX , } proc_cmd_t;include/monitor/qdev.h +0
-0
include/monitor/qdev.h void hmp_info_qdm(Monitor *mon, const QDict *qdict); · line 16
Quoted 7 lines
include/monitor/qdev.h +4
-0@@ -10,6 +10,10 @@ void hmp_info_qdm(Monitor *mon, const QDict *qdict);void hmp_info_qom_tree (Monitor *mon,const QDict *dict);void qmp_device_add (QDict *qdict,QObject **ret_data,Error **errp); +#ifdef CONFIG_MPQEMU +void qmp_rdevice_add (QDict *qdict,QObject **ret_data,Error **errp); +#endif +
I don't think you need to bother ifdef'ing the headers
Quoted 114 lines
include/monitor/qdev.h +0
-0int qdev_device_help (QemuOpts *opts);DeviceState *qdev_device_add (QemuOpts *opts,Error **errp);void qdev_set_id (DeviceState *dev,const char *id);monitor.c +5
-0@@ -1155,6 +1155,11 @@ static void monitor_init_qmp_commands(void)qmp_register_command (&qmp_commands,"netdev_add" , qmp_netdev_add,QCO_NO_OPTIONS ); +#ifdef CONFIG_MPQEMU +qmp_register_command (&qmp_commands,"rdevice_add" , qmp_rdevice_add, +QCO_NO_OPTIONS ); +#endif +QTAILQ_INIT (&qmp_cap_negotiation_commands);qmp_register_command (&qmp_cap_negotiation_commands,"qmp_capabilities" , qmp_marshal_qmp_capabilities,QCO_ALLOW_PRECONFIG );qapi/misc.json +22
-0@@ -1663,6 +1663,28 @@ 'gen': false } # so we can get the additional arguments ## +# @rdevice_add: +# +# @rdev_id: ID of the remote device root +# +# @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 +# +# Additional arguments depend on the type. +# +# Add a device. +# +# Since: 3.0 +## +{ 'command': 'rdevice_add', + 'data': {'rdev_id': 'str', 'driver': 'str', '*bus': 'str', '*id': 'str'}, + 'if': 'defined(CONFIG_MPQEMU)', + 'gen': false } # so we can get the additional arguments + +## # @device_del: # # Remove a device from a guestremote/remote-main.c +43
-0@@ -48,6 +48,11 @@#include "exec/memattrs.h" #include "exec/address-spaces.h" #include "remote/iohub.h" +#include "qapi/qmp/qjson.h" +#include "qapi/qmp/qobject.h" +#include "qemu/option.h" +#include "qemu/config-file.h" +#include "monitor/qdev.h" static ProxyLinkState *proxy_link;PCIDevice *remote_pci_dev;@@ -138,6 +143,44 @@ fail:PUT_REMOTE_WAIT (wait); } +static void process_device_add_msg (ProcMsg *msg) +{ +Error *local_err =NULL ; +const char *json = (const char *)msg->data2; +int wait = msg->fds[0 ]; +QObject *qobj =NULL ; +QDict *qdict =NULL ; +QemuOpts *opts =NULL ; + + qobj =qobject_from_json (json, &local_err); +if (local_err) { + goto fail; + } + + qdict =qobject_to (QDict, qobj); +assert (qdict); + + opts =qemu_opts_from_qdict (qemu_find_opts ("device" ), qdict, &local_err); +if (local_err) { + goto fail; + } + + (void )qdev_device_add (opts, &local_err); +if (local_err) { + goto fail; + } + +fail: +if (local_err) { +error_report_err (local_err); +/* TODO: communicate the exact error message to proxy */ + } + +notify_proxy (wait,1 ); + +PUT_REMOTE_WAIT (wait); +} +static void process_msg (GIOCondition cond) {ProcMsg *msg =NULL ;
remote/remote-main.c static void process_msg(GIOCondition cond) · line 237
Quoted 6 lines
remote/remote-main.c +3
-0@@ -189,6 +232,9 @@ static void process_msg(GIOCondition cond)case SET_IRQFD :process_set_irqfd_msg (remote_pci_dev, msg);break ; +case DEVICE_ADD : +process_device_add_msg (msg); +break ;
wrong patch?
remote/remote-main.c int main(int argc, char *argv[]) · line 275
Quoted 9 lines
remote/remote-main.c +2
-0default :error_setg (&err,"Unknown command" ); goto finalize_loop;@@ -225,6 +271,8 @@ int main(int argc, char *argv[])bdrv_init_with_whitelist (); +qemu_add_opts (&qemu_device_opts); +
wrong patch?
Quoted 6 lines
remote/remote-main.c +0
-0if (qemu_init_main_loop (&err)) {error_report_err (err);return -EBUSY ;Signature · 1 line
1.8.3.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 133 lines · Dr. David Alan Gilbert
Quoted 132 lines · * [email protected] ([email protected]) wrote:
From: Jagannathan Raman <[email protected]>
Adds
rdevice_addQMP & HMP commands to hotplug device to a remote device.Signed-off-by Jagannathan Raman <[email protected]>Signed-off-by John G Johnson <[email protected]>Signed-off-by Elena Ufimtseva <[email protected]>--- hmp-commands.hx | 14 ++++++++ hmp.h | 1 + hw/proxy/monitor.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++ include/io/proxy-link.h | 2 ++ include/monitor/qdev.h | 4 +++ monitor.c | 5 +++ qapi/misc.json | 22 ++++++++++++ remote/remote-main.c | 48 ++++++++++++++++++++++++++ 8 files changed, 188 insertions(+)hmp-commands.hx +14
-0@@ -727,6 +727,20 @@ ETEXI #if defined(CONFIG_MPQEMU) { + .name = "rdevice_add", + .args_type = "rdev_id:s,driver:s,id:s,drive:s,bus:s", + .params = "rdev_id driver id drive bus", + .help = "add device to remote proc, like -rdevice on the command line", + .cmd = hmp_rdevice_add, + }, + +STEXI +@item rdevice_add @var{config} +@findex rdevice_add +Add device to remote proc. +ETEXI + + { .name = "remote_proc_list", .args_type = "", .params = "",hmp.h +1
-0@@ -150,5 +150,6 @@ void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict);void hmp_info_memory_size_summary (Monitor *mon,const QDict *qdict);void hmp_info_sev (Monitor *mon,const QDict *qdict);void hmp_remote_proc_list (Monitor *mon,const QDict *qdict); +void hmp_rdevice_add (Monitor *mon,const QDict *qdict);#endif hw/proxy/monitor.c +56
-0@@ -23,6 +23,7 @@*/ #include <sys/types.h> +#include <string.h> #include "qemu/osdep.h" #include "qapi/qapi-types-block-core.h" @@ -33,6 +34,13 @@#include "hw/boards.h" #include "hw/i386/pc.h" #include "hw/proxy/qemu-proxy.h" +#include "qapi/qapi-commands-misc.h" +#include "monitor/qdev.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qjson.h" +#include "qapi/qmp/qstring.h" +#include "qapi/error.h" +#include "io/proxy-link.h" /* * TODO: Is there a callback where the allocated memory for QMP could be free'd @@ -87,3 +95,87 @@ void hmp_remote_proc_list(Monitor *mon, const QDict *qdict) pdev->remote_pid, pdev->rid, id, k->command); } } + +static PCIProxyDev *get_proxy_device (QDict *qdict,Error **errp) +{ +PCMachineState *pcms =PC_MACHINE (current_machine); +PCIProxyDev *pdev =NULL ; +const char *rdev_id; + +if (!qdict_haskey (qdict,"rdev_id" )) { +error_setg (errp,"Please specify a value for rdev_id" ); +return NULL ; + } + + rdev_id =qdict_get_str (qdict,"rdev_id" ); + + pdev = (PCIProxyDev *)g_hash_table_lookup (pcms->remote_devs, rdev_id); +if (!pdev) { +error_setg (errp, +"No remote device by ID %s. Use query-remote command to get remote devices" , + rdev_id); + } + +return pdev; +} + +static void rdevice_add_del (QDict *qdict,proc_cmd_t cmd,Error **errp) +{ +PCMachineState *pcms =PC_MACHINE (current_machine); +ProcMsg msg = {0 }; +PCIProxyDev *pdev =NULL ; +const char *id; +QString *json; +int wait; + + pdev =get_proxy_device (qdict, errp); +if (*errp) { +return ; + } + +qdict_del (qdict,"rdev_id" ); + + id =qdict_get_str (qdict,"id" ); + + json =qobject_to_json (QOBJECT (qdict)); + + wait =GET_REMOTE_WAIT ; + + msg.cmd = cmd; + msg.bytestream =1 ;
Quoted 9 lines
hw/proxy/monitor.c void hmp_remote_proc_list(Monitor *mon, const QDict *qdict) · line 153
Quoted 8 lines
hw/proxy/monitor.c +8
-0+ msg.size =strlen (qstring_get_str (json)); + msg.data2 = (uint8_t *)qstring_get_str (json); + msg.num_fds =1 ; + msg.fds[0 ] = wait; + +proxy_proc_send (pdev->proxy_link, &msg); + (void )wait_for_remote (wait); +PUT_REMOTE_WAIT (wait);
Hi David
Thanks for your comments.
Quoted 2 lines
Can this not fail? For example what happens if the external process dies just about here?
We did not take care yet of these scenarios. Probably polling on the file descriptor with a timeout will help with this.
This will be addressed in the next patchset.
Quoted 10 lines
hw/proxy/monitor.c void hmp_remote_proc_list(Monitor *mon, const QDict *qdict) · line 155
Quoted 2 lines
hw/proxy/monitor.c +1
-0+qstring_destroy_obj (QOBJECT (json));All of this:
build some JSON
send it to the remote
wait for the responseall looks like something more generic than a device add/del - separate function?
Agree, that does look like it can be generalized.
Quoted 54 lines
Quoted 54 lines
hw/proxy/monitor.c +25
-0+/* TODO: Only on success */ +if (cmd ==DEVICE_ADD ) { + (void )g_hash_table_insert (pcms->remote_devs, (gpointer )g_strdup (id), + (gpointer )pdev); + } +} + +void qmp_rdevice_add (QDict *qdict,QObject **ret_data,Error **errp) +{ +rdevice_add_del (qdict,DEVICE_ADD , errp); +} + +void hmp_rdevice_add (Monitor *mon,const QDict *qdict) +{ +Error *err =NULL ; + +/* TODO: Is it OK to modify the QDict argument from HMP? */ +rdevice_add_del ((QDict *)qdict,DEVICE_ADD , &err); + +if (err) { +monitor_printf (mon,"rdevice_add error: %s\n" , +error_get_pretty (err)); +error_free (err); + } +}include/io/proxy-link.h +2
-0@@ -60,6 +60,7 @@ typedef struct ProxyLinkState ProxyLinkState;* BAR_READ Reads from PCI BAR region * SET_IRQFD Sets the IRQFD to be used to raise interrupts directly * from remote device +* DEVICE_ADD QMP/HMP command to hotplug device * */ typedef enum {@@ -70,6 +71,7 @@ typedef enum {BAR_WRITE ,BAR_READ ,SET_IRQFD , +DEVICE_ADD ,MAX , } proc_cmd_t;include/monitor/qdev.h +0
-0@@ -10,6 +10,10 @@ void hmp_info_qdm(Monitor *mon, const QDict *qdict);void hmp_info_qom_tree (Monitor *mon,const QDict *dict);void qmp_device_add (QDict *qdict,QObject **ret_data,Error **errp);
Quoted 6 lines
include/monitor/qdev.h void hmp_info_qdm(Monitor *mon, const QDict *qdict); · line 16
Quoted 4 lines
include/monitor/qdev.h +4
-0+#ifdef CONFIG_MPQEMU +void qmp_rdevice_add (QDict *qdict,QObject **ret_data,Error **errp); +#endif +I don't think you need to bother ifdef'ing the headers
Ah, that's right, not needed.
Quoted 143 lines
Quoted 115 lines
include/monitor/qdev.h +0
-0int qdev_device_help (QemuOpts *opts);DeviceState *qdev_device_add (QemuOpts *opts,Error **errp);void qdev_set_id (DeviceState *dev,const char *id);monitor.c +5
-0@@ -1155,6 +1155,11 @@ static void monitor_init_qmp_commands(void)qmp_register_command (&qmp_commands,"netdev_add" , qmp_netdev_add,QCO_NO_OPTIONS ); +#ifdef CONFIG_MPQEMU +qmp_register_command (&qmp_commands,"rdevice_add" , qmp_rdevice_add, +QCO_NO_OPTIONS ); +#endif +QTAILQ_INIT (&qmp_cap_negotiation_commands);qmp_register_command (&qmp_cap_negotiation_commands,"qmp_capabilities" , qmp_marshal_qmp_capabilities,QCO_ALLOW_PRECONFIG );qapi/misc.json +22
-0@@ -1663,6 +1663,28 @@ 'gen': false } # so we can get the additional arguments ## +# @rdevice_add: +# +# @rdev_id: ID of the remote device root +# +# @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 +# +# Additional arguments depend on the type. +# +# Add a device. +# +# Since: 3.0 +## +{ 'command': 'rdevice_add', + 'data': {'rdev_id': 'str', 'driver': 'str', '*bus': 'str', '*id': 'str'}, + 'if': 'defined(CONFIG_MPQEMU)', + 'gen': false } # so we can get the additional arguments + +## # @device_del: # # Remove a device from a guestremote/remote-main.c +43
-0@@ -48,6 +48,11 @@#include "exec/memattrs.h" #include "exec/address-spaces.h" #include "remote/iohub.h" +#include "qapi/qmp/qjson.h" +#include "qapi/qmp/qobject.h" +#include "qemu/option.h" +#include "qemu/config-file.h" +#include "monitor/qdev.h" static ProxyLinkState *proxy_link;PCIDevice *remote_pci_dev;@@ -138,6 +143,44 @@ fail:PUT_REMOTE_WAIT (wait); } +static void process_device_add_msg (ProcMsg *msg) +{ +Error *local_err =NULL ; +const char *json = (const char *)msg->data2; +int wait = msg->fds[0 ]; +QObject *qobj =NULL ; +QDict *qdict =NULL ; +QemuOpts *opts =NULL ; + + qobj =qobject_from_json (json, &local_err); +if (local_err) { + goto fail; + } + + qdict =qobject_to (QDict, qobj); +assert (qdict); + + opts =qemu_opts_from_qdict (qemu_find_opts ("device" ), qdict, &local_err); +if (local_err) { + goto fail; + } + + (void )qdev_device_add (opts, &local_err); +if (local_err) { + goto fail; + } + +fail: +if (local_err) { +error_report_err (local_err); +/* TODO: communicate the exact error message to proxy */ + } + +notify_proxy (wait,1 ); + +PUT_REMOTE_WAIT (wait); +} +static void process_msg (GIOCondition cond) {ProcMsg *msg =NULL ;remote/remote-main.c static void process_msg(GIOCondition cond) · line 237
Quoted 6 lines
remote/remote-main.c +3
-0@@ -189,6 +232,9 @@ static void process_msg(GIOCondition cond)case SET_IRQFD :process_set_irqfd_msg (remote_pci_dev, msg);break ; +case DEVICE_ADD : +process_device_add_msg (msg); +break ;wrong patch?
remote/remote-main.c int main(int argc, char *argv[]) · line 275
Quoted 9 lines
remote/remote-main.c +2
-0default :error_setg (&err,"Unknown command" ); goto finalize_loop;@@ -225,6 +271,8 @@ int main(int argc, char *argv[])bdrv_init_with_whitelist (); +qemu_add_opts (&qemu_device_opts); +wrong patch?
Quoted 6 lines
remote/remote-main.c +0
-0if (qemu_init_main_loop (&err)) {error_report_err (err);return -EBUSY ;Signature · 1 line
1.8.3.1--
Dr. David Alan Gilbert / [email protected] / Manchester, UK