From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43725) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEheM-00045W-5U for qemu-devel@nongnu.org; Mon, 13 Jul 2015 13:36:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZEheH-0008TU-Fz for qemu-devel@nongnu.org; Mon, 13 Jul 2015 13:36:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44310) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEheH-0008TE-AW for qemu-devel@nongnu.org; Mon, 13 Jul 2015 13:36:13 -0400 Date: Mon, 13 Jul 2015 18:36:06 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20150713173605.GL2492@work-vm> References: <1434450415-11339-1-git-send-email-dgilbert@redhat.com> <1434450415-11339-28-git-send-email-dgilbert@redhat.com> <87egkcjm1m.fsf@neno.neno> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87egkcjm1m.fsf@neno.neno> Subject: Re: [Qemu-devel] [PATCH v7 27/42] postcopy: ram_enable_notify to switch on userfault List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela 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 * Juan Quintela (quintela@redhat.com) wrote: > "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:-) Well they are 'user faults'! Not that we blame the user for them personally of course. > > +static void *postcopy_ram_fault_thread(void *opaque) > > +{ > > + MigrationIncomingState *mis = (MigrationIncomingState *)opaque; > > Uneeded cast. Thanks, gone. > > + > > + 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:-) Thanks, gone. > If you have to resend, just change them. > > Reviewed-by: Juan Quintela Dave -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK