From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X37Vo-0007xN-Ft for qemu-devel@nongnu.org; Fri, 04 Jul 2014 13:43:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X37Vi-0000T3-B8 for qemu-devel@nongnu.org; Fri, 04 Jul 2014 13:43:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52462) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X37Vi-0000Sw-2h for qemu-devel@nongnu.org; Fri, 04 Jul 2014 13:42:58 -0400 From: "Dr. David Alan Gilbert (git)" Date: Fri, 4 Jul 2014 18:41:44 +0100 Message-Id: <1404495717-4239-34-git-send-email-dgilbert@redhat.com> In-Reply-To: <1404495717-4239-1-git-send-email-dgilbert@redhat.com> References: <1404495717-4239-1-git-send-email-dgilbert@redhat.com> Subject: [Qemu-devel] [PATCH 33/46] Postcopy: Create a fault handler thread before marking the ram as userfault List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, lilei@linux.vnet.ibm.com, quintela@redhat.com From: "Dr. David Alan Gilbert" Signed-off-by: Dr. David Alan Gilbert --- include/migration/migration.h | 3 +++ postcopy-ram.c | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/migration/migration.h b/include/migration/migration.h index 397f41c..67e5528 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -86,6 +86,9 @@ struct MigrationIncomingState { POSTCOPY_RAM_INCOMING_END } postcopy_ram_state; + QemuThread fault_thread; + QemuSemaphore fault_thread_sem; + QEMUFile *return_path; QemuMutex rp_mutex; /* We send replies from multiple threads */ PostcopyPMI postcopy_pmi; diff --git a/postcopy-ram.c b/postcopy-ram.c index c605dd3..fb7b02b 100644 --- a/postcopy-ram.c +++ b/postcopy-ram.c @@ -357,8 +357,31 @@ static int postcopy_ram_sensitise_area(const char *block_name, void *host_addr, return 0; } +/* + * Handle faults detected by the USERFAULT markings + */ +static void *postcopy_ram_fault_thread(void *opaque) +{ + MigrationIncomingState *mis = (MigrationIncomingState *)opaque; + + fprintf(stderr, "postcopy_ram_fault_thread\n"); + /* TODO: In later patch */ + qemu_sem_post(&mis->fault_thread_sem); + while (1) { + /* TODO: In later patch */ + } + + return NULL; +} + int postcopy_ram_enable_notify(MigrationIncomingState *mis) { + /* Create the fault handler thread and wait for it to be ready */ + qemu_sem_init(&mis->fault_thread_sem, 0); + qemu_thread_create(&mis->fault_thread, "postcopy/fault", + postcopy_ram_fault_thread, mis, QEMU_THREAD_JOINABLE); + qemu_sem_wait(&mis->fault_thread_sem); + /* Mark so that we get notified of accesses to unwritten areas */ if (qemu_ram_foreach_block(postcopy_ram_sensitise_area, NULL)) { return -1; -- 1.9.3