Skip to content

Commit 4ae046b

Browse files
committed
Merge remote-tracking branch 'remotes/aperard/tags/pull-xen-20200227' into staging
Xen queue 2020-02-27 * fix for xen-block * fix in exec.c for migration of xen guest * one cleanup patch # gpg: Signature made Thu 27 Feb 2020 11:57:12 GMT # gpg: using RSA key F80C006308E22CFD8A92E7980CF5572FD7FB55AF # gpg: issuer "[email protected]" # gpg: Good signature from "Anthony PERARD <[email protected]>" [marginal] # gpg: aka "Anthony PERARD <[email protected]>" [marginal] # gpg: WARNING: This key is not certified with sufficiently trusted signatures! # gpg: It is not certain that the signature belongs to the owner. # Primary key fingerprint: 5379 2F71 024C 600F 778A 7161 D8D5 7199 DF83 42C8 # Subkey fingerprint: F80C 0063 08E2 2CFD 8A92 E798 0CF5 572F D7FB 55AF * remotes/aperard/tags/pull-xen-20200227: Memory: Only call ramblock_ptr when needed in qemu_ram_writeback xen-bus/block: explicitly assign event channels to an AioContext hw/xen/xen_pt_load_rom: Remove unused includes Signed-off-by: Peter Maydell <[email protected]>
2 parents 430f63e + 5d4c954 commit 4ae046b

File tree

5 files changed

+47
-13
lines changed

5 files changed

+47
-13
lines changed

exec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,14 +2116,13 @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp)
21162116
*/
21172117
void qemu_ram_writeback(RAMBlock *block, ram_addr_t start, ram_addr_t length)
21182118
{
2119-
void *addr = ramblock_ptr(block, start);
2120-
21212119
/* The requested range should fit in within the block range */
21222120
g_assert((start + length) <= block->used_length);
21232121

21242122
#ifdef CONFIG_LIBPMEM
21252123
/* The lack of support for pmem should not block the sync */
21262124
if (ramblock_is_pmem(block)) {
2125+
void *addr = ramblock_ptr(block, start);
21272126
pmem_persist(addr, length);
21282127
return;
21292128
}
@@ -2134,6 +2133,7 @@ void qemu_ram_writeback(RAMBlock *block, ram_addr_t start, ram_addr_t length)
21342133
* specified as persistent (or is not one) - use the msync.
21352134
* Less optimal but still achieves the same goal
21362135
*/
2136+
void *addr = ramblock_ptr(block, start);
21372137
if (qemu_msync(addr, length, block->fd)) {
21382138
warn_report("%s: failed to sync memory range: start: "
21392139
RAM_ADDR_FMT " length: " RAM_ADDR_FMT,

hw/block/dataplane/xen-block.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,12 +685,24 @@ void xen_block_dataplane_stop(XenBlockDataPlane *dataplane)
685685
return;
686686
}
687687

688+
xendev = dataplane->xendev;
689+
688690
aio_context_acquire(dataplane->ctx);
691+
if (dataplane->event_channel) {
692+
/* Only reason for failure is a NULL channel */
693+
xen_device_set_event_channel_context(xendev, dataplane->event_channel,
694+
qemu_get_aio_context(),
695+
&error_abort);
696+
}
689697
/* Xen doesn't have multiple users for nodes, so this can't fail */
690698
blk_set_aio_context(dataplane->blk, qemu_get_aio_context(), &error_abort);
691699
aio_context_release(dataplane->ctx);
692700

693-
xendev = dataplane->xendev;
701+
/*
702+
* Now that the context has been moved onto the main thread, cancel
703+
* further processing.
704+
*/
705+
qemu_bh_cancel(dataplane->bh);
694706

695707
if (dataplane->event_channel) {
696708
Error *local_err = NULL;
@@ -807,7 +819,7 @@ void xen_block_dataplane_start(XenBlockDataPlane *dataplane,
807819
}
808820

809821
dataplane->event_channel =
810-
xen_device_bind_event_channel(xendev, dataplane->ctx, event_channel,
822+
xen_device_bind_event_channel(xendev, event_channel,
811823
xen_block_dataplane_event, dataplane,
812824
&local_err);
813825
if (local_err) {
@@ -818,7 +830,11 @@ void xen_block_dataplane_start(XenBlockDataPlane *dataplane,
818830
aio_context_acquire(dataplane->ctx);
819831
/* If other users keep the BlockBackend in the iothread, that's ok */
820832
blk_set_aio_context(dataplane->blk, dataplane->ctx, NULL);
833+
/* Only reason for failure is a NULL channel */
834+
xen_device_set_event_channel_context(xendev, dataplane->event_channel,
835+
dataplane->ctx, &error_abort);
821836
aio_context_release(dataplane->ctx);
837+
822838
return;
823839

824840
stop:

hw/xen/xen-bus.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,8 +1089,26 @@ static void xen_device_event(void *opaque)
10891089
}
10901090
}
10911091

1092+
void xen_device_set_event_channel_context(XenDevice *xendev,
1093+
XenEventChannel *channel,
1094+
AioContext *ctx,
1095+
Error **errp)
1096+
{
1097+
if (!channel) {
1098+
error_setg(errp, "bad channel");
1099+
return;
1100+
}
1101+
1102+
if (channel->ctx)
1103+
aio_set_fd_handler(channel->ctx, xenevtchn_fd(channel->xeh), true,
1104+
NULL, NULL, NULL, NULL);
1105+
1106+
channel->ctx = ctx;
1107+
aio_set_fd_handler(channel->ctx, xenevtchn_fd(channel->xeh), true,
1108+
xen_device_event, NULL, xen_device_poll, channel);
1109+
}
1110+
10921111
XenEventChannel *xen_device_bind_event_channel(XenDevice *xendev,
1093-
AioContext *ctx,
10941112
unsigned int port,
10951113
XenEventHandler handler,
10961114
void *opaque, Error **errp)
@@ -1116,9 +1134,10 @@ XenEventChannel *xen_device_bind_event_channel(XenDevice *xendev,
11161134
channel->handler = handler;
11171135
channel->opaque = opaque;
11181136

1119-
channel->ctx = ctx;
1120-
aio_set_fd_handler(channel->ctx, xenevtchn_fd(channel->xeh), true,
1121-
xen_device_event, NULL, xen_device_poll, channel);
1137+
/* Only reason for failure is a NULL channel */
1138+
xen_device_set_event_channel_context(xendev, channel,
1139+
qemu_get_aio_context(),
1140+
&error_abort);
11221141

11231142
QLIST_INSERT_HEAD(&xendev->event_channels, channel, list);
11241143

hw/xen/xen_pt_load_rom.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@
33
*/
44
#include "qemu/osdep.h"
55
#include "qapi/error.h"
6-
#include "hw/i386/pc.h"
76
#include "qemu/error-report.h"
8-
#include "ui/console.h"
97
#include "hw/loader.h"
10-
#include "monitor/monitor.h"
11-
#include "qemu/range.h"
128
#include "hw/pci/pci.h"
139
#include "xen_pt.h"
1410

include/hw/xen/xen-bus.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,13 @@ void xen_device_copy_grant_refs(XenDevice *xendev, bool to_domain,
128128
typedef bool (*XenEventHandler)(void *opaque);
129129

130130
XenEventChannel *xen_device_bind_event_channel(XenDevice *xendev,
131-
AioContext *ctx,
132131
unsigned int port,
133132
XenEventHandler handler,
134133
void *opaque, Error **errp);
134+
void xen_device_set_event_channel_context(XenDevice *xendev,
135+
XenEventChannel *channel,
136+
AioContext *ctx,
137+
Error **errp);
135138
void xen_device_notify_event_channel(XenDevice *xendev,
136139
XenEventChannel *channel,
137140
Error **errp);

0 commit comments

Comments
 (0)