/[qemu]/qemu/vl.c
ViewVC logotype

Diff of /qemu/vl.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.144 by bellard, Thu Nov 10 23:58:52 2005 UTC revision 1.145 by bellard, Fri Nov 11 00:00:38 2005 UTC
# Line 2935  void gui_update(void *opaque) Line 2935  void gui_update(void *opaque)
2935      qemu_mod_timer(gui_timer, GUI_REFRESH_INTERVAL + qemu_get_clock(rt_clock));      qemu_mod_timer(gui_timer, GUI_REFRESH_INTERVAL + qemu_get_clock(rt_clock));
2936  }  }
2937    
2938    struct vm_change_state_entry {
2939        VMChangeStateHandler *cb;
2940        void *opaque;
2941        LIST_ENTRY (vm_change_state_entry) entries;
2942    };
2943    
2944    static LIST_HEAD(vm_change_state_head, vm_change_state_entry) vm_change_state_head;
2945    
2946    VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
2947                                                         void *opaque)
2948    {
2949        VMChangeStateEntry *e;
2950    
2951        e = qemu_mallocz(sizeof (*e));
2952        if (!e)
2953            return NULL;
2954    
2955        e->cb = cb;
2956        e->opaque = opaque;
2957        LIST_INSERT_HEAD(&vm_change_state_head, e, entries);
2958        return e;
2959    }
2960    
2961    void qemu_del_vm_change_state_handler(VMChangeStateEntry *e)
2962    {
2963        LIST_REMOVE (e, entries);
2964        qemu_free (e);
2965    }
2966    
2967    static void vm_state_notify(int running)
2968    {
2969        VMChangeStateEntry *e;
2970    
2971        for (e = vm_change_state_head.lh_first; e; e = e->entries.le_next) {
2972            e->cb(e->opaque, running);
2973        }
2974    }
2975    
2976  /* XXX: support several handlers */  /* XXX: support several handlers */
2977  VMStopHandler *vm_stop_cb;  static VMStopHandler *vm_stop_cb;
2978  VMStopHandler *vm_stop_opaque;  static void *vm_stop_opaque;
2979    
2980  int qemu_add_vm_stop_handler(VMStopHandler *cb, void *opaque)  int qemu_add_vm_stop_handler(VMStopHandler *cb, void *opaque)
2981  {  {
# Line 2956  void vm_start(void) Line 2994  void vm_start(void)
2994      if (!vm_running) {      if (!vm_running) {
2995          cpu_enable_ticks();          cpu_enable_ticks();
2996          vm_running = 1;          vm_running = 1;
2997            vm_state_notify(1);
2998      }      }
2999  }  }
3000    
# Line 2969  void vm_stop(int reason) Line 3008  void vm_stop(int reason)
3008                  vm_stop_cb(vm_stop_opaque, reason);                  vm_stop_cb(vm_stop_opaque, reason);
3009              }              }
3010          }          }
3011            vm_state_notify(0);
3012      }      }
3013  }  }
3014    
# Line 3588  int main(int argc, char **argv) Line 3628  int main(int argc, char **argv)
3628      QEMUMachine *machine;      QEMUMachine *machine;
3629      char usb_devices[MAX_VM_USB_PORTS][128];      char usb_devices[MAX_VM_USB_PORTS][128];
3630      int usb_devices_index;      int usb_devices_index;
3631        
3632        LIST_INIT (&vm_change_state_head);
3633  #if !defined(CONFIG_SOFTMMU)  #if !defined(CONFIG_SOFTMMU)
3634      /* we never want that malloc() uses mmap() */      /* we never want that malloc() uses mmap() */
3635      mallopt(M_MMAP_THRESHOLD, 4096 * 1024);      mallopt(M_MMAP_THRESHOLD, 4096 * 1024);

Legend:
Removed from v.1.144  
changed lines
  Added in v.1.145

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26