Message ID | 20190617181620.30047-1-elena.ufimtseva@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Initial support of multi-process qemu | expand |
On 6/17/19 1:16 PM, elena.ufimtseva@oracle.com wrote: > From: Jagannathan Raman <jag.raman@oracle.com> > > Add query-remote QMP command and extend "info" HMP command, to list > the remote objects used by QEMU. > > Signed-off-by: Jagannathan Raman <jag.raman@oracle.com> > Signed-off-by: John G Johnson <john.g.johnson@oracle.com> > Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com> > --- > +++ b/qapi/block-core.json > @@ -673,6 +673,23 @@ > '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus', > '*dirty-bitmaps': ['BlockDirtyInfo'] } } > > +## > +# @RemoteProc: Unless there's a compelling reason to abbreviate, naming this 'RemoteProcess' is just fine. > +# > +# Remote process information. > +# > +# @id: Device ID > +# > +# @pid: Linux Process ID Is this information only available for Linux, or is it a generic pid appropriate to any operating system? I'm wondering if you can just s/Linux//. > +# > +# @proc: Process name Again, no need to abbreviate, if @process or @name would be easier to document. > +# > +# Since: 3.0.93 No such release. The next release will be 4.1. > +## > +{ 'struct': 'RemoteProc', > + 'data': {'id': 'str', 'pid': 'int32', 'proc': 'str' }, > + 'if': 'defined(CONFIG_MPQEMU)' } > + > ## > # @BlockMeasureInfo: > # > @@ -795,6 +812,18 @@ > ## > { 'command': 'query-block', 'returns': ['BlockInfo'] } > > +## > +# @query-remote: > +# > +# Get a list of all the remote processes spawned by QEMU. > +# > +# Returns: a list of @RemoteProc describing each remote process. > +# > +# Since: 3.0.93 4.1 > +# > +## > +{ 'command': 'query-remote', 'returns': ['RemoteProc'], > + 'if': 'defined(CONFIG_MPQEMU)' } > > ## > # @BlockDeviceTimedStats: >
On Mon, Jun 17, 2019 at 7:28 PM <elena.ufimtseva@oracle.com> wrote: > > From: Jagannathan Raman <jag.raman@oracle.com> > > Add query-remote QMP command and extend "info" HMP command, to list > the remote objects used by QEMU. > > Signed-off-by: Jagannathan Raman <jag.raman@oracle.com> > Signed-off-by: John G Johnson <john.g.johnson@oracle.com> > Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com> > --- > hmp-commands-info.hx | 16 +++++++ > hmp.h | 1 + > hw/proxy/Makefile.objs | 1 + > hw/proxy/monitor.c | 88 +++++++++++++++++++++++++++++++++++ > include/hw/proxy/qemu-proxy.h | 1 + > qapi/block-core.json | 29 ++++++++++++ > 6 files changed, 136 insertions(+) > create mode 100644 hw/proxy/monitor.c > > diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx > index c59444c461..b145e755eb 100644 > --- a/hmp-commands-info.hx > +++ b/hmp-commands-info.hx > @@ -932,6 +932,22 @@ STEXI > Show SEV information. > ETEXI > > +#if defined(CONFIG_MPQEMU) > + { > + .name = "remote", > + .args_type = "", > + .params = "", > + .help = "list remote objects", > + .cmd = hmp_info_remote, > + }, > + > +STEXI > +@item remote > +@findex remote > +list remote objects. > +ETEXI > +#endif > + > STEXI > @end table > ETEXI > diff --git a/hmp.h b/hmp.h > index 43617f2646..6919f99218 100644 > --- a/hmp.h > +++ b/hmp.h > @@ -150,5 +150,6 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict); > 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_info_remote(Monitor *mon, const QDict *qdict); > > #endif > diff --git a/hw/proxy/Makefile.objs b/hw/proxy/Makefile.objs > index f562f5a0e9..e6420602b8 100644 > --- a/hw/proxy/Makefile.objs > +++ b/hw/proxy/Makefile.objs > @@ -1,2 +1,3 @@ > common-obj-$(CONFIG_MPQEMU) += qemu-proxy.o > common-obj-$(CONFIG_MPQEMU) += proxy-lsi53c895a.o > +common-obj-$(CONFIG_MPQEMU) += monitor.o > diff --git a/hw/proxy/monitor.c b/hw/proxy/monitor.c > new file mode 100644 > index 0000000000..694f34a446 > --- /dev/null > +++ b/hw/proxy/monitor.c > @@ -0,0 +1,88 @@ > +/* > + * QEMU monitor command handler for multi-process QEMU > + * > + * Copyright 2019, Oracle and/or its affiliates. > + * > + * Permission is hereby granted, free of charge, to any person obtaining a copy > + * of this software and associated documentation files (the "Software"), to deal > + * in the Software without restriction, including without limitation the rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN > + * THE SOFTWARE. > + */ > + > +#include <sys/types.h> > + > +#include "qemu/osdep.h" > +#include "qapi/qapi-types-block-core.h" > +#include "qapi/qapi-commands-block-core.h" > +#include "monitor/monitor.h" > +#include "qemu/option.h" > +#include "hmp.h" > +#include "hw/boards.h" > +#include "hw/proxy/qemu-proxy.h" > + > +/* > + * TODO: Is there a callback where the allocated memory for QMP could be free'd QAPI objects are freed by the monitor. The QAPI code generator produces a function for freeing each QAPI object and the monitor will call it after sending the response to the monitor client. > + */ > +RemoteProcList *qmp_query_remote(Error **errp) > +{ > + MachineState *ms = MACHINE(current_machine); > + RemoteProcList *proclist, *proc; > + GHashTableIter itr; > + PCIProxyDev *pdev; > + PCIProxyDevClass *k; This shouldn't be limited to PCI. From what I can tell this is an implementation detail, so it's fine for now. Just make sure not to put PCI-specific things in the QMP interface so that we can use this for other devices in the future (USB, etc).
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index c59444c461..b145e755eb 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -932,6 +932,22 @@ STEXI Show SEV information. ETEXI +#if defined(CONFIG_MPQEMU) + { + .name = "remote", + .args_type = "", + .params = "", + .help = "list remote objects", + .cmd = hmp_info_remote, + }, + +STEXI +@item remote +@findex remote +list remote objects. +ETEXI +#endif + STEXI @end table ETEXI diff --git a/hmp.h b/hmp.h index 43617f2646..6919f99218 100644 --- a/hmp.h +++ b/hmp.h @@ -150,5 +150,6 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict); 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_info_remote(Monitor *mon, const QDict *qdict); #endif diff --git a/hw/proxy/Makefile.objs b/hw/proxy/Makefile.objs index f562f5a0e9..e6420602b8 100644 --- a/hw/proxy/Makefile.objs +++ b/hw/proxy/Makefile.objs @@ -1,2 +1,3 @@ common-obj-$(CONFIG_MPQEMU) += qemu-proxy.o common-obj-$(CONFIG_MPQEMU) += proxy-lsi53c895a.o +common-obj-$(CONFIG_MPQEMU) += monitor.o diff --git a/hw/proxy/monitor.c b/hw/proxy/monitor.c new file mode 100644 index 0000000000..694f34a446 --- /dev/null +++ b/hw/proxy/monitor.c @@ -0,0 +1,88 @@ +/* + * QEMU monitor command handler for multi-process QEMU + * + * Copyright 2019, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include <sys/types.h> + +#include "qemu/osdep.h" +#include "qapi/qapi-types-block-core.h" +#include "qapi/qapi-commands-block-core.h" +#include "monitor/monitor.h" +#include "qemu/option.h" +#include "hmp.h" +#include "hw/boards.h" +#include "hw/proxy/qemu-proxy.h" + +/* + * TODO: Is there a callback where the allocated memory for QMP could be free'd + */ +RemoteProcList *qmp_query_remote(Error **errp) +{ + MachineState *ms = MACHINE(current_machine); + RemoteProcList *proclist, *proc; + GHashTableIter itr; + PCIProxyDev *pdev; + PCIProxyDevClass *k; + DeviceState *d; + char *id; + + proclist = NULL; + + g_hash_table_iter_init(&itr, ms->remote_devs); + + while (g_hash_table_iter_next(&itr, (gpointer *)&id, (gpointer *)&pdev)) { + k = PCI_PROXY_DEV_GET_CLASS(pdev); + d = DEVICE(pdev); + + proc = g_malloc0(sizeof(RemoteProcList)); + proc->next = proclist; + proclist = proc; + proc->value = g_malloc0(sizeof(RemoteProc)); + proc->value->pid = pdev->remote_pid; + proc->value->id = g_strdup(d->id); + proc->value->proc = g_strdup(k->command); + } + + return proclist; +} + +void hmp_info_remote(Monitor *mon, const QDict *qdict) +{ + MachineState *ms = MACHINE(current_machine); + GHashTableIter itr; + PCIProxyDev *pdev; + PCIProxyDevClass *k; + char *id; + + g_hash_table_iter_init(&itr, ms->remote_devs); + + monitor_printf(mon, "%8.8s\t%16.16s\t%16.16s\t%16.16s\n\n", "PID", "RID", + "QEMU ID", "PROCESS NAME"); + + while (g_hash_table_iter_next(&itr, (gpointer *)&id, (gpointer *)&pdev)) { + k = PCI_PROXY_DEV_GET_CLASS(pdev); + + monitor_printf(mon, "%8.8d\t%16.16s\t%16.16s\t%16.16s\n", + pdev->remote_pid, pdev->rid, id, k->command); + } +} diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index c27817f780..b73077940c 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -27,6 +27,7 @@ #include "io/proxy-link.h" #include "hw/proxy/memory-sync.h" +#include "hw/pci/pci.h" #include "qemu/event_notifier.h" #define TYPE_PCI_PROXY_DEV "pci-proxy-dev" diff --git a/qapi/block-core.json b/qapi/block-core.json index 7ccbfff9d0..6a0bfe26a2 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -673,6 +673,23 @@ '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus', '*dirty-bitmaps': ['BlockDirtyInfo'] } } +## +# @RemoteProc: +# +# Remote process information. +# +# @id: Device ID +# +# @pid: Linux Process ID +# +# @proc: Process name +# +# Since: 3.0.93 +## +{ 'struct': 'RemoteProc', + 'data': {'id': 'str', 'pid': 'int32', 'proc': 'str' }, + 'if': 'defined(CONFIG_MPQEMU)' } + ## # @BlockMeasureInfo: # @@ -795,6 +812,18 @@ ## { 'command': 'query-block', 'returns': ['BlockInfo'] } +## +# @query-remote: +# +# Get a list of all the remote processes spawned by QEMU. +# +# Returns: a list of @RemoteProc describing each remote process. +# +# Since: 3.0.93 +# +## +{ 'command': 'query-remote', 'returns': ['RemoteProc'], + 'if': 'defined(CONFIG_MPQEMU)' } ## # @BlockDeviceTimedStats: