Incremental patch, which I think addresses everything major? Would still be nice to make the remote-domain field optional.
I *still* assume p->type is in the valid range, but at least if that's wrong now it'll just put a bad value in the enum instead of crashing ;) (In fact as I squash this I'll remove xen-stubs.c entirely; that would end up empty at the point in the series so I'll only add it later.) --- hw/i386/kvm/xen-stubs.c | 13 ----- hw/i386/kvm/xen_evtchn.c | 25 ++++----- hw/i386/kvm/xen_evtchn.h | 3 - include/monitor/hmp.h | 2 + monitor/misc.c | 4 -- qapi/misc-target.json | 116 +++++++++++++++++++++++++++++++++++++++ qapi/misc.json | 91 ------------------------------ 7 files changed, 130 insertions(+), 124 deletions(-) diff --git a/hw/i386/kvm/xen-stubs.c b/hw/i386/kvm/xen-stubs.c index 5660a2ccad..a95964bbac 100644 --- a/hw/i386/kvm/xen-stubs.c +++ b/hw/i386/kvm/xen-stubs.c @@ -10,21 +10,8 @@ */ #include "qemu/osdep.h" -#include "qapi/error.h" -#include "qapi/qapi-commands-misc.h" #include "xen_evtchn.h" -EvtchnInfoList *qmp_xen_event_list(Error **errp) -{ - error_setg(errp, "Xen event channel emulation not enabled"); - return NULL; -} - -void qmp_xen_event_inject(uint32_t port, Error **errp) -{ - error_setg(errp, "Xen event channel emulation not enabled"); -} - void xen_evtchn_snoop_msi(PCIDevice *dev, bool is_msix, unsigned int vector, uint64_t addr, uint32_t data, bool is_masked) { diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c index be67089f82..dc91da6544 100644 --- a/hw/i386/kvm/xen_evtchn.c +++ b/hw/i386/kvm/xen_evtchn.c @@ -17,7 +17,7 @@ #include "monitor/monitor.h" #include "monitor/hmp.h" #include "qapi/error.h" -#include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-commands-misc-target.h" #include "qapi/qmp/qdict.h" #include "qom/object.h" #include "exec/target_page.h" @@ -2200,15 +2200,6 @@ int xen_be_evtchn_get_guest_port(struct xenevtchn_handle *xc) return xc->guest_port; } -static const char *type_names[] = { - "closed", - "unbound", - "interdomain", - "pirq", - "virq", - "ipi" -}; - EvtchnInfoList *qmp_xen_event_list(Error **errp) { XenEvtchnState *s = xen_evtchn_singleton; @@ -2226,6 +2217,7 @@ EvtchnInfoList *qmp_xen_event_list(Error **errp) error_setg(errp, "Xen shared info page not allocated"); return NULL; } + if (xen_is_long_mode()) { pending = shinfo + offsetof(struct shared_info, evtchn_pending); mask = shinfo + offsetof(struct shared_info, evtchn_mask); @@ -2247,7 +2239,14 @@ EvtchnInfoList *qmp_xen_event_list(Error **errp) info = g_new0(EvtchnInfo, 1); info->port = i; - info->type = g_strdup(type_names[p->type]); + qemu_build_assert(EVTCHN_PORT_TYPE_CLOSED == EVTCHNSTAT_closed); + qemu_build_assert(EVTCHN_PORT_TYPE_UNBOUND == EVTCHNSTAT_unbound); + qemu_build_assert(EVTCHN_PORT_TYPE_INTERDOMAIN == EVTCHNSTAT_interdomain); + qemu_build_assert(EVTCHN_PORT_TYPE_PIRQ == EVTCHNSTAT_pirq); + qemu_build_assert(EVTCHN_PORT_TYPE_VIRQ == EVTCHNSTAT_virq); + qemu_build_assert(EVTCHN_PORT_TYPE_IPI == EVTCHNSTAT_ipi); + + info->type = p->type; if (p->type == EVTCHNSTAT_interdomain) { info->remote_domain = g_strdup((p->type_val & PORT_INFO_TYPEVAL_REMOTE_QEMU) ? "qemu" : "loopback"); @@ -2301,8 +2300,8 @@ void hmp_xen_event_list(Monitor *mon, const QDict *qdict) EvtchnInfo *info = iter->value; monitor_printf(mon, "port %4lu: vcpu: %ld %s", info->port, info->vcpu, - info->type); - if (strcmp(info->type, "ipi")) { + EvtchnPortType_str(info->type)); + if (info->type != EVTCHN_PORT_TYPE_IPI) { monitor_printf(mon, "("); if (info->remote_domain) { monitor_printf(mon, "%s:", info->remote_domain); diff --git a/hw/i386/kvm/xen_evtchn.h b/hw/i386/kvm/xen_evtchn.h index fa8651040c..bfb67ac2bc 100644 --- a/hw/i386/kvm/xen_evtchn.h +++ b/hw/i386/kvm/xen_evtchn.h @@ -51,9 +51,6 @@ int xen_be_evtchn_pending(struct xenevtchn_handle *xc); /* Apart from this which is a local addition */ int xen_be_evtchn_get_guest_port(struct xenevtchn_handle *xc); -void hmp_xen_event_inject(Monitor *mon, const QDict *qdict); -void hmp_xen_event_list(Monitor *mon, const QDict *qdict); - struct evtchn_status; struct evtchn_close; struct evtchn_unmask; diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index 27f86399f7..ba1e6e8c2e 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -101,6 +101,8 @@ void hmp_virtio_status(Monitor *mon, const QDict *qdict); void hmp_virtio_queue_status(Monitor *mon, const QDict *qdict); void hmp_vhost_queue_status(Monitor *mon, const QDict *qdict); void hmp_virtio_queue_element(Monitor *mon, const QDict *qdict); +void hmp_xen_event_inject(Monitor *mon, const QDict *qdict); +void hmp_xen_event_list(Monitor *mon, const QDict *qdict); void object_add_completion(ReadLineState *rs, int nb_args, const char *str); void object_del_completion(ReadLineState *rs, int nb_args, const char *str); void device_add_completion(ReadLineState *rs, int nb_args, const char *str); diff --git a/monitor/misc.c b/monitor/misc.c index 7d8c473ffb..bf3f1c67ca 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -82,10 +82,6 @@ /* Make devices configuration available for use in hmp-commands*.hx templates */ #include CONFIG_DEVICES -#ifdef CONFIG_XEN_EMU -#include "hw/i386/kvm/xen_evtchn.h" -#endif - /* file descriptors passed via SCM_RIGHTS */ typedef struct mon_fd_t mon_fd_t; struct mon_fd_t { diff --git a/qapi/misc-target.json b/qapi/misc-target.json index 5b6a8e9185..652e6e0b37 100644 --- a/qapi/misc-target.json +++ b/qapi/misc-target.json @@ -380,3 +380,119 @@ # ## { 'command': 'query-sgx-capabilities', 'returns': 'SGXInfo', 'if': 'TARGET_I386' } + + +## +# @EvtchnPortType: +# +# An enumeration of Xen event channel port types. +# +# @closed: The port is unused. +# +# @unbound: The port is allocated and ready to be bound. +# +# @interdomain: The port is connected as an interdomain interrupt. +# +# @pirq: The port is bound to a physical IRQ (PIRQ). +# +# @virq: The port is bound to a virtual IRQ (VIRQ). +# +# @ipi: The post is an inter-processor interrupt (IPI). +# +# Since: 8.0.0 +## +{ 'enum': 'EvtchnPortType', + 'data': ['closed', 'unbound', 'interdomain', 'pirq', 'virq', 'ipi'], + 'if': 'TARGET_I386' } + +## +# @EvtchnInfo: +# +# Information about a Xen event channel port +# +# @port: the port number +# +# @vcpu: target vCPU for this port +# +# @type: the port type +# +# @remote-domain: remote domain for interdomain ports +# +# @target: remote port ID, or virq/pirq number +# +# @pending: port is currently active pending delivery +# +# @masked: port is masked +# +# Since: 8.0.0 +## +{ 'struct': 'EvtchnInfo', + 'data': {'port': 'int', + 'vcpu': 'int', + 'type': 'EvtchnPortType', + 'remote-domain': 'str', + 'target': 'int', + 'pending': 'bool', + 'masked': 'bool'}, + 'if': 'TARGET_I386' } + + +## +# @xen-event-list: +# +# Query the Xen event channels opened by the guest. +# +# Returns: list of open event channel ports. +# +# Since: 8.0.0 +# +# Example: +# +# -> { "execute": "xen-event-list" } +# <- { "return": [ +# { +# "pending": false, +# "port": 1, +# "vcpu": 1, +# "remote-domain": "qemu", +# "masked": false, +# "type": "interdomain", +# "target": 1 +# }, +# { +# "pending": false, +# "port": 2, +# "vcpu": 0, +# "remote-domain": "", +# "masked": false, +# "type": "virq", +# "target": 0 +# } +# ] +# } +# +## +{ 'command': 'xen-event-list', + 'returns': ['EvtchnInfo'], + 'if': 'TARGET_I386' } + +## +# @xen-event-inject: +# +# Inject a Xen event channel port (interrupt) to the guest. +# +# @port: The port number +# +# Returns: - Nothing on success. +# +# Since: 8.0.0 +# +# Example: +# +# -> { "execute": "xen-event-inject", "arguments": { "port": 1 } } +# <- { "return": { } } +# +## +{ 'command': 'xen-event-inject', + 'data': { 'port': 'uint32' }, + 'if': 'TARGET_I386' } diff --git a/qapi/misc.json b/qapi/misc.json index 6284f86a5b..27ef5a2b20 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -584,94 +584,3 @@ { 'event': 'VFU_CLIENT_HANGUP', 'data': { 'vfu-id': 'str', 'vfu-qom-path': 'str', 'dev-id': 'str', 'dev-qom-path': 'str' } } - -## -# @EvtchnInfo: -# -# Information about a Xen event channel port -# -# @port: the port number -# -# @vcpu: target vCPU for this port -# -# @type: the port type -# -# @remote-domain: remote domain for interdomain ports -# -# @target: remote port ID, or virq/pirq number -# -# @pending: port is currently active pending delivery -# -# @masked: port is masked -# -# Since: x.xx -## -{ 'struct': 'EvtchnInfo', - 'data': {'port': 'int', - 'vcpu': 'int', - 'type': 'str', - 'remote-domain': 'str', - 'target': 'int', - 'pending': 'bool', - 'masked': 'bool'}} - - -## -# @xen-event-list: -# -# Query the Xen event channels opened by the guest. -# -# Returns: list of open event channel ports. -# -# Since: x.xx -# -# Example: -# -# -> { "execute": "xen-event-list" } -# <- { "return": [ -# { -# "pending": false, -# "port": 1, -# "vcpu": 1, -# "remote-domain": "qemu", -# "masked": false, -# "type": "interdomain", -# "target": 1 -# }, -# { -# "pending": false, -# "port": 2, -# "vcpu": 0, -# "remote-domain": "", -# "masked": false, -# "type": "virq", -# "target": 0 -# } -# ] -# } -# -## -{ 'command': 'xen-event-list', - 'returns': ['EvtchnInfo'] -} - -## -# @xen-event-inject: -# -# Inject a Xen event channel port to the guest. -# -# @port: The port number -# -# Returns: - Nothing on success. -# -# Since: x.xx -# -# Example: -# -# -> { "execute": "xen-event-inject", "arguments": { "port": 1 } } -# <- { "return": { } } -# -## -{ 'command': 'xen-event-inject', - 'data': { 'port': 'uint32' } -} -- 2.34.1
smime.p7s
Description: S/MIME cryptographic signature