2935 |
2935 |
qemu_mod_timer(gui_timer, GUI_REFRESH_INTERVAL + qemu_get_clock(rt_clock));
|
2936 |
2936 |
}
|
2937 |
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 |
|
2938 |
2976 |
/* XXX: support several handlers */
|
2939 |
|
VMStopHandler *vm_stop_cb;
|
2940 |
|
VMStopHandler *vm_stop_opaque;
|
|
2977 |
static VMStopHandler *vm_stop_cb;
|
|
2978 |
static void *vm_stop_opaque;
|
2941 |
2979 |
|
2942 |
2980 |
int qemu_add_vm_stop_handler(VMStopHandler *cb, void *opaque)
|
2943 |
2981 |
{
|
... | ... | |
2956 |
2994 |
if (!vm_running) {
|
2957 |
2995 |
cpu_enable_ticks();
|
2958 |
2996 |
vm_running = 1;
|
|
2997 |
vm_state_notify(1);
|
2959 |
2998 |
}
|
2960 |
2999 |
}
|
2961 |
3000 |
|
... | ... | |
2969 |
3008 |
vm_stop_cb(vm_stop_opaque, reason);
|
2970 |
3009 |
}
|
2971 |
3010 |
}
|
|
3011 |
vm_state_notify(0);
|
2972 |
3012 |
}
|
2973 |
3013 |
}
|
2974 |
3014 |
|
... | ... | |
3588 |
3628 |
QEMUMachine *machine;
|
3589 |
3629 |
char usb_devices[MAX_VM_USB_PORTS][128];
|
3590 |
3630 |
int usb_devices_index;
|
3591 |
|
|
|
3631 |
|
|
3632 |
LIST_INIT (&vm_change_state_head);
|
3592 |
3633 |
#if !defined(CONFIG_SOFTMMU)
|
3593 |
3634 |
/* we never want that malloc() uses mmap() */
|
3594 |
3635 |
mallopt(M_MMAP_THRESHOLD, 4096 * 1024);
|