Skip to content

Commit d588299

Browse files
jemmy858585Juan Quintela
authored and
Juan Quintela
committed
migration: poll the cm event while wait RDMA work request completion
If the peer qemu is crashed, the qemu_rdma_wait_comp_channel function maybe loop forever. so we should also poll the cm event fd, and when receive RDMA_CM_EVENT_DISCONNECTED and RDMA_CM_EVENT_DEVICE_REMOVAL, we consider some error happened. Signed-off-by: Lidong Chen <[email protected]> Signed-off-by: Gal Shachaf <[email protected]> Signed-off-by: Aviad Yehezkel <[email protected]> Reviewed-by: Dr. David Alan Gilbert <[email protected]> Reviewed-by: Juan Quintela <[email protected]> Signed-off-by: Juan Quintela <[email protected]>
1 parent 5d5f4d8 commit d588299

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

migration/rdma.c

+30-3
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,9 @@ static uint64_t qemu_rdma_poll(RDMAContext *rdma, uint64_t *wr_id_out,
14891489
*/
14901490
static int qemu_rdma_wait_comp_channel(RDMAContext *rdma)
14911491
{
1492+
struct rdma_cm_event *cm_event;
1493+
int ret = -1;
1494+
14921495
/*
14931496
* Coroutine doesn't start until migration_fd_process_incoming()
14941497
* so don't yield unless we know we're running inside of a coroutine.
@@ -1505,13 +1508,37 @@ static int qemu_rdma_wait_comp_channel(RDMAContext *rdma)
15051508
* without hanging forever.
15061509
*/
15071510
while (!rdma->error_state && !rdma->received_error) {
1508-
GPollFD pfds[1];
1511+
GPollFD pfds[2];
15091512
pfds[0].fd = rdma->comp_channel->fd;
15101513
pfds[0].events = G_IO_IN | G_IO_HUP | G_IO_ERR;
1514+
pfds[0].revents = 0;
1515+
1516+
pfds[1].fd = rdma->channel->fd;
1517+
pfds[1].events = G_IO_IN | G_IO_HUP | G_IO_ERR;
1518+
pfds[1].revents = 0;
1519+
15111520
/* 0.1s timeout, should be fine for a 'cancel' */
1512-
switch (qemu_poll_ns(pfds, 1, 100 * 1000 * 1000)) {
1521+
switch (qemu_poll_ns(pfds, 2, 100 * 1000 * 1000)) {
1522+
case 2:
15131523
case 1: /* fd active */
1514-
return 0;
1524+
if (pfds[0].revents) {
1525+
return 0;
1526+
}
1527+
1528+
if (pfds[1].revents) {
1529+
ret = rdma_get_cm_event(rdma->channel, &cm_event);
1530+
if (!ret) {
1531+
rdma_ack_cm_event(cm_event);
1532+
}
1533+
1534+
error_report("receive cm event while wait comp channel,"
1535+
"cm event is %d", cm_event->event);
1536+
if (cm_event->event == RDMA_CM_EVENT_DISCONNECTED ||
1537+
cm_event->event == RDMA_CM_EVENT_DEVICE_REMOVAL) {
1538+
return -EPIPE;
1539+
}
1540+
}
1541+
break;
15151542

15161543
case 0: /* Timeout, go around again */
15171544
break;

0 commit comments

Comments
 (0)