"Dr. David Alan Gilbert (git)" <dgilb...@redhat.com> wrote: > From: "Dr. David Alan Gilbert" <dgilb...@redhat.com> > > 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 <dgilb...@redhat.com> > Reviewed-by: David Gibson <da...@gibson.dropbear.id.au> > --- > 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 <quint...@redhat.com>