From: David van Moolenbroek Date: Tue, 14 Jul 2015 04:44:35 +0000 (+0200) Subject: VM: undo actions after live-update rollback X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=5a4672e300b511868df763b76e81f10b1ec153e5;p=minix.git VM: undo actions after live-update rollback During live update, the new instance of VM may make changes that, after a rollback, have to be undone by the old instance of VM, in particular because both instances share (read-write) all dynamically allocated pages. Change-Id: I2bcfa8e627ca6084b1991e0af7cccecc683894a2 --- diff --git a/minix/servers/vm/main.c b/minix/servers/vm/main.c index 5fb5fb6a2..6f37e676c 100644 --- a/minix/servers/vm/main.c +++ b/minix/servers/vm/main.c @@ -194,6 +194,29 @@ int main(void) return(OK); } +static void sef_cb_lu_state_changed(int old_state, int state) +{ +/* Called whenever the live-update state changes. We need to restore certain + * state in the old VM instance after a live update has failed, because some + * but not all memory is shared between the two VM instances. + */ + struct vmproc *vmp; + + if (state == SEF_LU_STATE_NULL) { + /* Undo some of the changes that may have been made by the new VM + * instance. If the new VM instance is us, nothing happens. + */ + vmp = &vmproc[VM_PROC_NR]; + + /* Rebind page tables. */ + pt_bind(&vmp->vm_pt, vmp); + pt_clearmapcache(); + + /* Readjust process references. */ + adjust_proc_refs(); + } +} + static void sef_local_startup(void) { /* Register init callbacks. */ @@ -206,6 +229,9 @@ static void sef_local_startup(void) if (__vm_init_fresh) sef_setcb_init_response(sef_cb_init_response_rs_asyn_once); + /* Register live update callbacks. */ + sef_setcb_lu_state_changed(sef_cb_lu_state_changed); + /* Register signal callbacks. */ sef_setcb_signal_handler(sef_cb_signal_handler);