From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEcYt-0005ns-05 for qemu-devel@nongnu.org; Mon, 13 Jul 2015 08:10:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZEcYp-0000Ce-PV for qemu-devel@nongnu.org; Mon, 13 Jul 2015 08:10:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58933) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEcYp-0000CM-Ji for qemu-devel@nongnu.org; Mon, 13 Jul 2015 08:10:15 -0400 From: Juan Quintela In-Reply-To: <1434450415-11339-28-git-send-email-dgilbert@redhat.com> (David Alan Gilbert's message of "Tue, 16 Jun 2015 11:26:40 +0100") References: <1434450415-11339-1-git-send-email-dgilbert@redhat.com> <1434450415-11339-28-git-send-email-dgilbert@redhat.com> Date: Mon, 13 Jul 2015 14:10:13 +0200 Message-ID: <87egkcjm1m.fsf@neno.neno> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v7 27/42] postcopy: ram_enable_notify to switch on userfault Reply-To: quintela@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert (git)" Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, liang.z.li@intel.com, qemu-devel@nongnu.org, luis@cs.umu.se, amit.shah@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au "Dr. David Alan Gilbert (git)" wrote: > From: "Dr. David Alan Gilbert" > > Mark the area of RAM as 'userfault' > Start up a fault-thread to handle any userfaults we might receive > from it (to be filled in later) > > Signed-off-by: Dr. David Alan Gilbert > Reviewed-by: David Gibson > --- > include/migration/migration.h | 3 ++ > include/migration/postcopy-ram.h | 6 ++++ > migration/postcopy-ram.c | 69 +++++++++++++++++++++++++++++++++++++++- > migration/savevm.c | 9 ++++++ > 4 files changed, 86 insertions(+), 1 deletion(-) > > diff --git a/include/migration/migration.h b/include/migration/migration.h > index 98e2568..e6585c5 100644 > --- a/include/migration/migration.h > +++ b/include/migration/migration.h > @@ -69,6 +69,9 @@ struct MigrationIncomingState { > */ > QemuEvent main_thread_load_event; > > + QemuThread fault_thread; Best name ever? Well, it could be "wrong_thread" O:-) > +static void *postcopy_ram_fault_thread(void *opaque) > +{ > + MigrationIncomingState *mis = (MigrationIncomingState *)opaque; Uneeded cast. > + > + 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); > + qemu_sem_destroy(&mis->fault_thread_sem); > + > + /* Mark so that we get notified of accesses to unwritten areas */ > + if (qemu_ram_foreach_block(ram_block_enable_notify, mis)) { > + return -1; > + } > + > + return 0; > +} > + > #else > /* No target OS support, stubs just fail */ > - This belongs in a different patch O:-) If you have to resend, just change them. Reviewed-by: Juan Quintela