Send the shared memory window last
This ensures that all of the interrupts are initialized before
Android begins to boot. ivshmem_common_realize calls ivshmem_recv_setup,
which exits only when it gets the shared memory window.
BUG: 111000656
Test: Boot completes, as does the e2e test
Test: Debian 1:2.12~rc3+dfsg-1
Test: Debian 1:2.11+dfsg-1
Test: vsoc-0.7pre4 image (1:2.8+dfsg-6+deb9u4)
Change-Id: I55d75e0b542aa96dcf7abc4a38226bc6305ac7fa
(cherry picked from commit 85df3121a694d9f5f9c03010f85ce1803fdaa606)
diff --git a/host/libs/ivserver/qemu_client.cc b/host/libs/ivserver/qemu_client.cc
index c893f0f..d584ccc 100644
--- a/host/libs/ivserver/qemu_client.cc
+++ b/host/libs/ivserver/qemu_client.cc
@@ -63,15 +63,7 @@
return false;
}
- // 3. The number -1, accompanied by the file descriptor for the shared
- // memory.
- if (!SendSocketInfo(kSharedMem, shmem.SharedMemFD())) {
- LOG(ERROR) << "Failed to send Shared Memory socket: "
- << client_socket_->StrError();
- return false;
- }
-
- // 4. Connect notifications for existing other clients, if any. This is
+ // 3. Connect notifications for existing other clients, if any. This is
// a peer ID (number between 0 and 65535 other than the client's ID),
// repeated N times. Each repetition is accompanied by one file
// descriptor. These are for interrupting the peer with that ID using
@@ -86,7 +78,7 @@
}
}
- // 5. Interrupt setup. This is the client's own ID, repeated N times.
+ // 4. Interrupt setup. This is the client's own ID, repeated N times.
// Each repetition is accompanied by one file descriptor. These are
// for receiving interrupts from peers using vector 0,..,N-1, in
// order. If the client is configured for fewer vectors, it closes
@@ -100,6 +92,15 @@
}
}
+ // 5. The number -1, accompanied by the file descriptor for the shared
+ // memory.
+ if (!SendSocketInfo(kSharedMem, shmem.SharedMemFD())) {
+ LOG(ERROR) << "Failed to send Shared Memory socket: "
+ << client_socket_->StrError();
+ return false;
+ }
+
+
LOG(INFO) << "QEmu handshake completed.";
return true;
}