[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v7 38/51] i386/xen: add monitor commands to test event inject
From: |
David Woodhouse |
Subject: |
Re: [PATCH v7 38/51] i386/xen: add monitor commands to test event injection |
Date: |
Tue, 17 Jan 2023 11:31:23 +0000 |
User-agent: |
Evolution 3.44.4-0ubuntu1 |
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
- Re: [PATCH v7 26/51] hw/xen: Add xen_evtchn device for event channel emulation, (continued)
- Re: [PATCH v7 26/51] hw/xen: Add xen_evtchn device for event channel emulation, Paul Durrant, 2023/01/17
- Re: [PATCH v7 26/51] hw/xen: Add xen_evtchn device for event channel emulation, David Woodhouse, 2023/01/17
- Re: [PATCH v7 26/51] hw/xen: Add xen_evtchn device for event channel emulation, Paul Durrant, 2023/01/17
- Re: [PATCH v7 26/51] hw/xen: Add xen_evtchn device for event channel emulation, David Woodhouse, 2023/01/17
- Re: [PATCH v7 26/51] hw/xen: Add xen_evtchn device for event channel emulation, Paul Durrant, 2023/01/17
- Re: [PATCH v7 26/51] hw/xen: Add xen_evtchn device for event channel emulation, David Woodhouse, 2023/01/17
- [PATCH v7.1 26/51] hw/xen: Add xen_evtchn device for event channel emulation, David Woodhouse, 2023/01/17
[PATCH v7 38/51] i386/xen: add monitor commands to test event injection, David Woodhouse, 2023/01/16
[PATCH v7 06/51] i386/hvm: Set Xen vCPU ID in KVM, David Woodhouse, 2023/01/16
[PATCH v7 29/51] hw/xen: Implement EVTCHNOP_close, David Woodhouse, 2023/01/16
[PATCH v7 36/51] hw/xen: Implement EVTCHNOP_bind_vcpu, David Woodhouse, 2023/01/16
[PATCH v7 19/51] i386/xen: implement HYPERVISOR_vcpu_op, David Woodhouse, 2023/01/16
[PATCH v7 28/51] hw/xen: Implement EVTCHNOP_status, David Woodhouse, 2023/01/16
[PATCH v7 42/51] hw/xen: Add xen_gnttab device for grant table emulation, David Woodhouse, 2023/01/16
[PATCH v7 20/51] i386/xen: handle VCPUOP_register_vcpu_info, David Woodhouse, 2023/01/16
[PATCH v7 43/51] hw/xen: Support mapping grant frames, David Woodhouse, 2023/01/16
[PATCH v7 45/51] hw/xen: Implement GNTTABOP_query_size, David Woodhouse, 2023/01/16