From: Stefano Stabellini <sstabellini@kernel.org>
To: peter.maydell@linaro.org, stefanha@gmail.com
Cc: sstabellini@kernel.org, stefanha@redhat.com,
anthony.perard@citrix.com, xen-devel@lists.xenproject.org,
qemu-devel@nongnu.org, Paul Durrant <paul.durrant@citrix.com>
Subject: [Qemu-devel] [PULL v2 05/15] xen-hvm: create separate function for ioreq server initialization
Date: Tue, 22 May 2018 11:46:32 -0700 [thread overview]
Message-ID: <1527014802-11289-5-git-send-email-sstabellini@kernel.org> (raw)
In-Reply-To: <alpine.DEB.2.10.1805221136110.24793@sstabellini-ThinkPad-X260>
From: Paul Durrant <paul.durrant@citrix.com>
The code is sufficiently substantial that it improves code readability
to put it in a new function called by xen_hvm_init() rather than having
it inline.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Anthony Perard <anthony.perard@citrix.com>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
---
hw/i386/xen/xen-hvm.c | 76 +++++++++++++++++++++++++++++++--------------------
1 file changed, 46 insertions(+), 30 deletions(-)
diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c
index caa563b..6ffa3c2 100644
--- a/hw/i386/xen/xen-hvm.c
+++ b/hw/i386/xen/xen-hvm.c
@@ -95,7 +95,8 @@ typedef struct XenIOState {
CPUState **cpu_by_vcpu_id;
/* the evtchn port for polling the notification, */
evtchn_port_t *ioreq_local_port;
- /* evtchn local port for buffered io */
+ /* evtchn remote and local ports for buffered io */
+ evtchn_port_t bufioreq_remote_port;
evtchn_port_t bufioreq_local_port;
/* the evtchn fd for polling */
xenevtchn_handle *xce_handle;
@@ -1236,12 +1237,52 @@ static void xen_wakeup_notifier(Notifier *notifier, void *data)
xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 0);
}
-void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
+static int xen_map_ioreq_server(XenIOState *state)
{
- int i, rc;
xen_pfn_t ioreq_pfn;
xen_pfn_t bufioreq_pfn;
evtchn_port_t bufioreq_evtchn;
+ int rc;
+
+ rc = xen_get_ioreq_server_info(xen_domid, state->ioservid,
+ &ioreq_pfn, &bufioreq_pfn,
+ &bufioreq_evtchn);
+ if (rc < 0) {
+ error_report("failed to get ioreq server info: error %d handle=%p",
+ errno, xen_xc);
+ return rc;
+ }
+
+ DPRINTF("shared page at pfn %lx\n", ioreq_pfn);
+ DPRINTF("buffered io page at pfn %lx\n", bufioreq_pfn);
+ DPRINTF("buffered io evtchn is %x\n", bufioreq_evtchn);
+
+ state->shared_page = xenforeignmemory_map(xen_fmem, xen_domid,
+ PROT_READ | PROT_WRITE,
+ 1, &ioreq_pfn, NULL);
+ if (state->shared_page == NULL) {
+ error_report("map shared IO page returned error %d handle=%p",
+ errno, xen_xc);
+ return -1;
+ }
+
+ state->buffered_io_page = xenforeignmemory_map(xen_fmem, xen_domid,
+ PROT_READ | PROT_WRITE,
+ 1, &bufioreq_pfn, NULL);
+ if (state->buffered_io_page == NULL) {
+ error_report("map buffered IO page returned error %d", errno);
+ return -1;
+ }
+
+ state->bufioreq_remote_port = bufioreq_evtchn;
+
+ return 0;
+}
+
+void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
+{
+ int i, rc;
+ xen_pfn_t ioreq_pfn;
XenIOState *state;
state = g_malloc0(sizeof (XenIOState));
@@ -1269,25 +1310,8 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
state->wakeup.notify = xen_wakeup_notifier;
qemu_register_wakeup_notifier(&state->wakeup);
- rc = xen_get_ioreq_server_info(xen_domid, state->ioservid,
- &ioreq_pfn, &bufioreq_pfn,
- &bufioreq_evtchn);
+ rc = xen_map_ioreq_server(state);
if (rc < 0) {
- error_report("failed to get ioreq server info: error %d handle=%p",
- errno, xen_xc);
- goto err;
- }
-
- DPRINTF("shared page at pfn %lx\n", ioreq_pfn);
- DPRINTF("buffered io page at pfn %lx\n", bufioreq_pfn);
- DPRINTF("buffered io evtchn is %x\n", bufioreq_evtchn);
-
- state->shared_page = xenforeignmemory_map(xen_fmem, xen_domid,
- PROT_READ|PROT_WRITE,
- 1, &ioreq_pfn, NULL);
- if (state->shared_page == NULL) {
- error_report("map shared IO page returned error %d handle=%p",
- errno, xen_xc);
goto err;
}
@@ -1308,14 +1332,6 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
goto err;
}
- state->buffered_io_page = xenforeignmemory_map(xen_fmem, xen_domid,
- PROT_READ|PROT_WRITE,
- 1, &bufioreq_pfn, NULL);
- if (state->buffered_io_page == NULL) {
- error_report("map buffered IO page returned error %d", errno);
- goto err;
- }
-
/* Note: cpus is empty at this point in init */
state->cpu_by_vcpu_id = g_malloc0(max_cpus * sizeof(CPUState *));
@@ -1340,7 +1356,7 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
}
rc = xenevtchn_bind_interdomain(state->xce_handle, xen_domid,
- bufioreq_evtchn);
+ state->bufioreq_remote_port);
if (rc == -1) {
error_report("buffered evtchn bind error %d", errno);
goto err;
--
1.9.1
next prev parent reply other threads:[~2018-05-22 18:46 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-22 18:46 [Qemu-devel] [PULL v2 00/15] xen-20180522-tag Stefano Stabellini
2018-05-22 18:46 ` [Qemu-devel] [PULL v2 01/15] xen-pvdevice: Introduce a simplistic xen-pvdevice save state Stefano Stabellini
2018-05-22 18:46 ` [Qemu-devel] [PULL v2 02/15] xen/pt: use address_space_memory object for memory region hooks Stefano Stabellini
2018-05-22 18:46 ` [Qemu-devel] [PULL v2 03/15] configure: Add explanation for --enable-xen-pci-passthrough Stefano Stabellini
2018-05-22 18:46 ` [Qemu-devel] [PULL v2 04/15] xen_pt: Present the size of 64 bit BARs correctly Stefano Stabellini
2018-05-22 18:46 ` Stefano Stabellini [this message]
2018-05-22 18:46 ` [Qemu-devel] [PULL v2 06/15] checkpatch: generalize xen handle matching in the list of types Stefano Stabellini
2018-05-22 18:46 ` [Qemu-devel] [PULL v2 07/15] xen: add a meaningful declaration of grant_copy_segment into xen_common.h Stefano Stabellini
2018-05-22 18:46 ` [Qemu-devel] [PULL v2 08/15] xen_backend: add grant table helpers Stefano Stabellini
2018-05-22 18:46 ` [Qemu-devel] [PULL v2 09/15] xen_disk: remove open-coded use of libxengnttab Stefano Stabellini
2018-05-22 18:46 ` [Qemu-devel] [PULL v2 10/15] xen: remove other " Stefano Stabellini
2018-05-22 18:46 ` [Qemu-devel] [PULL v2 11/15] xen_backend: add an emulation of grant copy Stefano Stabellini
2018-05-22 18:46 ` [Qemu-devel] [PULL v2 12/15] xen_disk: remove use of grant map/unmap Stefano Stabellini
2018-05-22 18:46 ` [Qemu-devel] [PULL v2 13/15] xen_backend: make the xen_feature_grant_copy flag private Stefano Stabellini
2018-05-22 18:46 ` [Qemu-devel] [PULL v2 14/15] xen_disk: use a single entry iovec Stefano Stabellini
2018-05-22 18:46 ` [Qemu-devel] [PULL v2 15/15] xen_disk: be consistent with use of xendev and blkdev->xendev Stefano Stabellini
2018-05-24 12:23 ` [Qemu-devel] [PULL v2 00/15] xen-20180522-tag Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1527014802-11289-5-git-send-email-sstabellini@kernel.org \
--to=sstabellini@kernel.org \
--cc=anthony.perard@citrix.com \
--cc=paul.durrant@citrix.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
--cc=stefanha@redhat.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).